Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

The recursivity of normalizeData method in TreeGrid class is potentially endless with only-numbers string as key and parentKey #31

Open
ovargas71 opened this issue Oct 4, 2023 · 1 comment

Comments

@ovargas71
Copy link

ovargas71 commented Oct 4, 2023

The problem:

If the values of keyColumnName and parentColumnName fields are strings with only numeric character, the recursivity of normalizeData method in TreeGrid class is potentially endless.

Example case:

For example, if we have the follow data (informal code):

Node1: [key = "1", parentKey = null]

Node2: [key = "01", parentKey = "1"]

Node3: [key = "001", parentKey = "01"]

When is searching then Node2's children (value of $parentId parameter is "01"), because Node2's parentKey is "1", the condition ArrayHelper::getValue($element, $this->parentColumnName) == $parentId is evaluated true, therefore a new call to normalizeData is thrown to search (again) the Node2's children.

Suggested modification:

Use the type-strict comparation operator (===) instead the double equal operator (==).

ArrayHelper::getValue($element, $this->parentColumnName) === $parentId

@ovargas71 ovargas71 changed the title The recursivity of normalizeData method does not work fine with numeric as string The recursivity of normalizeData method is potentially endless with only-numbers string as key and parentKey Oct 4, 2023
@ovargas71 ovargas71 changed the title The recursivity of normalizeData method is potentially endless with only-numbers string as key and parentKey The recursivity of normalizeData method in TreeGrid class is potentially endless with only-numbers string as key and parentKey Oct 5, 2023
@leandrogehlen
Copy link
Owner

I have not used the Yii framework
Fell free to submit a PR to address the issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants