-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix #61597: SXE properties may lack attributes and content #5246
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
We must not treat a node as string if it has attributes, unless it is an entity declaration which is always treated as string by simplexml.
| } | ||
| ["elem1"]=> | ||
| string(10) "Bla bla 1." | ||
| object(SimpleXMLElement)#%d (3) { |
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.
Looks like the Bla bla 1. text got lost completely here?
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.
That is actually to be expected for mixed content; text nodes are dropped. That is already the case if these elements are var_dump()ed directly (in this case var_dump($sxe->elem1); only children of the SimpleXMLElement are treated wrong without this patch.
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.
That seems pretty weird ... but it's SimpleXML so 🤷♂️
|
Thanks! Applied as 7c081db. |
Upstream bug reports of the behavior change introduced in PHP 7.3.17 (and applied to PHP 7.4 branch as well): https://bugs.php.net/bug.php?id=79528 https://bugs.php.net/bug.php?id=79485 The reponsible commit in PHP was php/php-src#5246 This was a "bug fix" in the sense that SimpleXML used to discard the attributes on the namespace elements, which look like this: <namespace key="-2" case="first-letter">Media</namespace> SimpleXML used to return this as a string "Media" instead of a SimpleXMLElement... but ExportTest (inadvertently?) depended on that behavior. In any case, if we iterate over SimpleXMLElement::children() we always get SimpleXMLElements, not "sometimes strings", and so our code will correct correctly on PHP below 7.3.17 and above, regardless of how PHP decides to handle this "bug". Bug: T250568 Change-Id: I9c2cb6a86fd6e8023c1979ec6838071a87a7bcea
Upstream bug reports of the behavior change introduced in PHP 7.3.17 (and applied to PHP 7.4 branch as well): https://bugs.php.net/bug.php?id=79528 https://bugs.php.net/bug.php?id=79485 The reponsible commit in PHP was php/php-src#5246 This was a "bug fix" in the sense that SimpleXML used to discard the attributes on the namespace elements, which look like this: <namespace key="-2" case="first-letter">Media</namespace> SimpleXML used to return this as a string "Media" instead of a SimpleXMLElement... but ExportTest (inadvertently?) depended on that behavior. In any case, if we iterate over SimpleXMLElement::children() we always get SimpleXMLElements, not "sometimes strings", and so our code will correct correctly on PHP below 7.3.17 and above, regardless of how PHP decides to handle this "bug". Bug: T250568 Change-Id: I9c2cb6a86fd6e8023c1979ec6838071a87a7bcea (cherry picked from commit 7f1ad7d)
Upstream bug reports of the behavior change introduced in PHP 7.3.17 (and applied to PHP 7.4 branch as well): https://bugs.php.net/bug.php?id=79528 https://bugs.php.net/bug.php?id=79485 The reponsible commit in PHP was php/php-src#5246 This was a "bug fix" in the sense that SimpleXML used to discard the attributes on the namespace elements, which look like this: <namespace key="-2" case="first-letter">Media</namespace> SimpleXML used to return this as a string "Media" instead of a SimpleXMLElement... but ExportTest (inadvertently?) depended on that behavior. In any case, if we iterate over SimpleXMLElement::children() we always get SimpleXMLElements, not "sometimes strings", and so our code will correct correctly on PHP below 7.3.17 and above, regardless of how PHP decides to handle this "bug". Bug: T250568 Change-Id: I9c2cb6a86fd6e8023c1979ec6838071a87a7bcea (cherry picked from commit 7f1ad7d)
Upstream bug reports of the behavior change introduced in PHP 7.3.17 (and applied to PHP 7.4 branch as well): https://bugs.php.net/bug.php?id=79528 https://bugs.php.net/bug.php?id=79485 The reponsible commit in PHP was php/php-src#5246 This was a "bug fix" in the sense that SimpleXML used to discard the attributes on the namespace elements, which look like this: <namespace key="-2" case="first-letter">Media</namespace> SimpleXML used to return this as a string "Media" instead of a SimpleXMLElement... but ExportTest (inadvertently?) depended on that behavior. In any case, if we iterate over SimpleXMLElement::children() we always get SimpleXMLElements, not "sometimes strings", and so our code will correct correctly on PHP below 7.3.17 and above, regardless of how PHP decides to handle this "bug". Bug: T250568 Change-Id: I9c2cb6a86fd6e8023c1979ec6838071a87a7bcea (cherry picked from commit 7f1ad7d)
|
This "fix" is a breaking change from PHP 7.3.16 to 7.3.17. Differences: This can kill running systems that are uses XML. Please don't release "fixes" like this as an bugfix release. |
|
Sorry, that this happened; the bad fix has already been reverted, and PHP 7.3.18 (which will be released tomorrow) should be working again like before (not that the former behavior makes sense, though). |
|
Reverting is also a bad idea (for us), because we have fixed our bugs with version 7.3.17. |
|
🤷♂️ |
Upstream bug reports of the behavior change introduced in PHP 7.3.17 (and applied to PHP 7.4 branch as well): https://bugs.php.net/bug.php?id=79528 https://bugs.php.net/bug.php?id=79485 The reponsible commit in PHP was php/php-src#5246 This was a "bug fix" in the sense that SimpleXML used to discard the attributes on the namespace elements, which look like this: <namespace key="-2" case="first-letter">Media</namespace> SimpleXML used to return this as a string "Media" instead of a SimpleXMLElement... but ExportTest (inadvertently?) depended on that behavior. In any case, if we iterate over SimpleXMLElement::children() we always get SimpleXMLElements, not "sometimes strings", and so our code will correct correctly on PHP below 7.3.17 and above, regardless of how PHP decides to handle this "bug". Bug: T250568 Change-Id: I9c2cb6a86fd6e8023c1979ec6838071a87a7bcea (cherry picked from commit 7f1ad7d)
We must not treat a node as string if it has attributes, unless it is
an entity declaration which is always treated as string by simplexml.