-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[config] Fix issue when key removed and left value only #14082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[config] Fix issue when key removed and left value only #14082
Conversation
1d67c56
to
96f65cc
Compare
96f65cc
to
4e750d8
Compare
4e750d8
to
260cac4
Compare
beda431
to
28d2fbb
Compare
28d2fbb
to
7859855
Compare
* | ||
* @return mixed The prototype instance | ||
*/ | ||
protected function getPrototypeForChild($key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be private.
The examples you give in the description seems good to me. |
Apart from the minor formatting comments, 👍 @zerustech Can you rebase on current 2.3 so that tests can be re-run? Thanks. |
7859855
to
d4b2a2f
Compare
@fabpot Done, please check. Thanks. |
@zerustech Thanks, it looks like it breaks some tests. Can you check? |
@fabpot Looks like it was caused by Testing src/Symfony/Bundle/TwigBundle
.....EEF.......EE.......
Time: 17.06 seconds, Memory: 13.25Mb |
@zerustech Yeah, but this happens when the bunde's config is evaluated and the failures are related to the prototype handling from this PR. Status: Needs work |
d4b2a2f
to
66bd18d
Compare
@xabbuh @fabpot Fixed the following issues:
|
/** | ||
* @var NodeInterface[] An array of the prototypes of the simplified value children | ||
*/ | ||
protected $valuePrototypes = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be private IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabpot Fixed, please test.
👍 for merge in 2.7 after the small asked change. |
When a key attribute is mapped and the key is removed from the value array, if only 'value' element is left in the array, it should replace its wrapper array. Assume the original value array is as follows (key attribute is 'id'). ```php array( 'things' => array( array('id' => 'option1', 'value' => 'value1'), array('id' => 'option2', 'value' => 'value2') ) ) ``` After normalized, the above shall be converted to the following array. ```php array( 'things' => array( 'option1' => 'value1', 'option2' => 'value2' ) ) ``` It's also possible to mix 'value-only' and 'none-value-only' elements in the array: ```php array( 'things' => array( array('id' => 'option1', 'value' => 'value1'), array('id' => 'option2', 'value' => 'value2', 'foo' => 'foo2') ) ) ``` The above shall be converted to the following array. ```php array( 'things' => array( 'option1' => 'value1', 'option2' => array('value' => 'value2','foo' => 'foo2') ) ) ``` The 'value' element can also be array: ```php array( 'things' => array( array( 'id' => 'option1', 'value' => array('foo'=>'foo1', 'bar' => 'bar1') ) ) ) ``` The above shall be converted to the following array. ```php array( 'things' => array( 'option1' => array('foo' => 'foo1', 'bar' => 'bar1') ) ) ``` When using VariableNode for value element, it's also possible to mix different types of value elements: ```php array( 'things' => array( array('id' => 'option1', 'value' => array('foo'=>'foo1', 'bar' => 'bar1')), array('id' => 'option2', 'value' => 'value2') ) ) ``` The above shall be converted to the following array. ```php array( 'things' => array( 'option1' => array('foo'=>'foo1', 'bar' => 'bar1'), 'option2' => 'value2' ) ) ``` | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#15270 | License | MIT | Doc PR | n/a
66bd18d
to
12488c5
Compare
Thank you @zerustech. |
…erustech) This PR was submitted for the 2.3 branch but it was merged into the 2.7 branch instead (closes #14082). Discussion ---------- [config] Fix issue when key removed and left value only | Q | A | | --- | --- | | Bug fix? | yes | | New feature? | no | | BC breaks? | no | | Deprecations? | no | | Tests pass? | yes | | Fixed tickets | #15270 | | License | MIT | | Doc PR | n/a | When a key attribute is mapped and the key is removed from the value array, if only 'value' element is left in the array, it should replace its wrapper array. Assume the original value array is as follows (key attribute is 'id'). ``` php array( 'things' => array( array('id' => 'option1', 'value' => 'value1'), array('id' => 'option2', 'value' => 'value2') ) ) ``` After normalized, the above shall be converted to the following array. ``` php array( 'things' => array( 'option1' => 'value1', 'option2' => 'value2' ) ) ``` It's also possible to mix 'value-only' and 'none-value-only' elements in the array: ``` php array( 'things' => array( array('id' => 'option1', 'value' => 'value1'), array('id' => 'option2', 'value' => 'value2', 'foo' => 'foo2') ) ) ``` The above shall be converted to the following array. ``` php array( 'things' => array( 'option1' => 'value1', 'option2' => array('value' => 'value2','foo' => 'foo2') ) ) ``` The 'value' element can also be array: ``` php array( 'things' => array( array( 'id' => 'option1', 'value' => array('foo'=>'foo1', 'bar' => 'bar1') ) ) ) ``` The above shall be converted to the following array. ``` php array( 'things' => array( 'option1' => array('foo' => 'foo1', 'bar' => 'bar1') ) ) ``` When using VariableNode for value element, it's also possible to mix different types of value elements: ``` php array( 'things' => array( array('id' => 'option1', 'value' => array('foo'=>'foo1', 'bar' => 'bar1')), array('id' => 'option2', 'value' => 'value2') ) ) ``` The above shall be converted to the following array. ``` php array( 'things' => array( 'option1' => array('foo'=>'foo1', 'bar' => 'bar1'), 'option2' => 'value2' ) ) ``` Commits ------- b587a72 [config] Fix issue when key removed and left value only
@fabpot It's my pleasure. |
When a key attribute is mapped and the key is removed from the value array, if
only 'value' element is left in the array, it should replace its wrapper
array.
Assume the original value array is as follows (key attribute is 'id').
After normalized, the above shall be converted to the following array.
It's also possible to mix 'value-only' and 'none-value-only' elements in
the array:
The above shall be converted to the following array.
The 'value' element can also be array:
The above shall be converted to the following array.
When using VariableNode for value element, it's also possible to mix
different types of value elements:
The above shall be converted to the following array.