-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Fix merging PrototypedArrayNode associative values #39847
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
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
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.
could you please add a test?
see https://github.com/symfony/symfony/pull/39686/files for similar PR
85fe26a
to
b4b55c7
Compare
Test added |
looks like the failed tests is related to your change |
b4b55c7
to
0ca9126
Compare
Yes, it was. Now, I've changed the argument
for which P.S. I'm not sure about that, but is that a normal behaviour that original key replaced when |
Indeed, the attributeAsKey should not be an expected subkey of the array. |
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
Outdated
Show resolved
Hide resolved
b1620a0
to
0186a39
Compare
@OskarStark yes, thanks for pointing. Did it in different environment, but now fixed it. |
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.
I am not convinced that this will always work. What if there is a queue where one option is named option
?
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.
@xabbuh I've added an option
key inside test config options array to prove that this will work.
@svityashchuk If you change your example to something like this, you will experience the same behavior: 'options' => [
'auto_setup' => true,
'queue' => [
'name' => 'Queue',
'option' => 'foo',
],
], |
@xabbuh thank you for providing an example. I've got that behaviour. So, in the circumstances I see the only possibility to use another keyword as keyAttribute. Otherwise, I won't be able to pass this check at foreach ($rightSide as $k => $v) {
// prototype, and key is irrelevant, append the element
if (null === $this->keyAttribute) {
$leftSide[] = $v;
continue;
} Moreover, now it seems for me like this condition protected function normalizeValue($value)
{
//...
$isAssoc = array_keys($value) !== range(0, \count($value) - 1);
//...
foreach ($value as $k => $v) {
//...
if (null !== $this->keyAttribute || $isAssoc) {
$normalized[$k] = $prototype->normalize($v);
} else {
$normalized[] = $prototype->normalize($v);
} Pay attention that |
This sounds like a solution that could work. Let's give that a try. For |
a2eabcc
to
566d16f
Compare
566d16f
to
3791db5
Compare
3791db5
to
35b930c
Compare
Now it seems like everything is ok :) I would be very happy if this is merged. |
src/Symfony/Component/Config/Definition/PrototypedArrayNode.php
Outdated
Show resolved
Hide resolved
a896d1b
to
004abd4
Compare
src/Symfony/Component/Config/Definition/PrototypedArrayNode.php
Outdated
Show resolved
Hide resolved
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.
Please update the PR title - it's not about Messenger :)
8851bd2
to
f939686
Compare
Hi! Is this PR going to be merged? I have the same issue. |
Thank you @svityashchuk. |
Now keys will not be considered as irrelevant.
The problem was because in ConfigTree
options
are defined asarrayNode
and has aprototype('variable')
. So for combining config togetherPrototypedArrayNode::mergeValues()
was called. And there was a trouble - for thatPrototypedArrayNode
$rightSide
values were added without keys:\Symfony\Component\Config\Definition\PrototypedArrayNode::mergeValues