-
-
Notifications
You must be signed in to change notification settings - Fork 449
Fix regression bug for duplicate block rendering with getSortedChildren() #4480
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
Thanks for that detailed description. 👍 Checks did not run, it is your first PR? |
Yes it's my first PR |
Thank you. Please run |
@bucha Thank you, looking at the code it looks fine since your new check is right before the other sorted children logic. And if the unit tests are passing then it seems all okay (thanks also for fixing that one test.) |
|
@all-contributors add bucha code |
I've put up a pull request to add @bucha! 🎉 |
Description (*)
This is a fix for regression bug I noticed while updating one of our projects from OpenMage 20.10.2 to 20.11.0 which I was able to trace back to #4337
Within this project we've basically implemented a holepunch-system in which we run the following code to replace a given block by another block:
Running OpenMage 20.10.2 this approach worked perfectly.
On OpenMage 20.11.0 however we experienced a problem:
One of the blocks we replace using this method is inside a list-block. A list-block will first sort its children and then render them in order to append their html output to its own output. We noticed that the output of the replacement-block was not in the list-block's output any longer. When looking at this phenomenon in an xdebug session I noticed that the list-block contained the replacement-block in its
$_children
but$_sortedChildren
was empty.It turns out that the recently introduced call to
$this->unsetChild($alias);
inMage_Core_Block_Abstract
was responsible for this behavior:https://github.com/OpenMage/magento-lts/blame/v20.11.0/app/code/core/Mage/Core/Block/Abstract.php#L468
I have therefor removed the call to
$this->unsetChild($alias);
and instead introduced a check ininsert()
whether a given block is already known in$_sortedChildren
and if so it will be removed from$_sortedChildren
(before then being appended again).This should be in line with @justinbeaty 's original intentions which I also checked against the unit-tests of #4337.
Related Pull Requests
Manual testing scenarios (*)
I've added another test within the unit tests: