Skip to content

Conversation

@cmb69
Copy link
Member

@cmb69 cmb69 commented Mar 7, 2020

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.

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) {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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 🤷‍♂️

@cmb69 cmb69 added the Bug label Mar 9, 2020
@cmb69
Copy link
Member Author

cmb69 commented Mar 12, 2020

Thanks! Applied as 7c081db.

@cmb69 cmb69 closed this Mar 12, 2020
@cmb69 cmb69 deleted the cmb/61597 branch March 12, 2020 09:58
wmfgerrit pushed a commit to wikimedia/mediawiki that referenced this pull request Apr 30, 2020
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
wmfgerrit pushed a commit to wikimedia/mediawiki that referenced this pull request Apr 30, 2020
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)
wmfgerrit pushed a commit to wikimedia/mediawiki that referenced this pull request Apr 30, 2020
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)
wmfgerrit pushed a commit to wikimedia/mediawiki that referenced this pull request Apr 30, 2020
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)
@4d4ch4u32
Copy link

4d4ch4u32 commented May 13, 2020

This "fix" is a breaking change from PHP 7.3.16 to 7.3.17. Differences:

php 7.3.17
array:43 [
  "id" => array:2 [
    "@attributes" => array:1 [
      "type" => "integer"
    ]
    0 => "7090224"
  ]

php 7.3.16
array:43 [
  "id" => "7090241"
]

This can kill running systems that are uses XML. Please don't release "fixes" like this as an bugfix release.

@cmb69
Copy link
Member Author

cmb69 commented May 13, 2020

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).

@4d4ch4u32
Copy link

Reverting is also a bad idea (for us), because we have fixed our bugs with version 7.3.17.

@4d4ch4u32
Copy link

🤷‍♂️

mmeller-wikia pushed a commit to Wikia/mediawiki that referenced this pull request Feb 16, 2021
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants