-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Wrong default value of DOMDocument.xmlStandalone #11791
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
Comments
It doesn't look like this depends on the PHP version; PHP treats that libxml2 int standalone; /* standalone document (no external refs)
1 if standalone="yes"
0 if standalone="no"
-1 if there is no XML declaration
-2 if there is an XML declaration, but no
standalone attribute was specified */ The W3C DOM Level 3 specs declare it as boolean, and state "This is false when unspecified." So the PHP documentation would actually be correct, but not the implementation. However, the WHATWG DOM specification lists that interface member as removed. Given that the WHATWG DOM specification supersedes the respective W3C specifications, I don't think that fixing the actual bug makes sense, so we should (a) document the current behavior, and (b) deprecate FWIW, we only require libxml2 ≥ 2.7.6 as of PHP 7.4.0; previously, we required only libxml2 ≥ 2.6.11, so builds with these old libxml2 versions would show a different behavior. |
Yep, that's kind of what I meant...I started investigating especially after reading the W3C spec contradicting the PHP behaviour.
On the PHP side, apparently we've deprecated
But these are obviously out of the scope of the documentation. In my specific case, I think I'll change my implementation to save the root xml node and prepend the original xml declaration (instead of saving the entire document). |
Ugh. None of these properties are actually deprecated (
Indeed, another doc bug (at least).
Only |
That is correct, my bad. Doesn't that also mean |
I'm going to move this issue to php-src, as this is an implementation bug. |
At one point this was changed from a bool to an int in libxml2, with negative values meaning it is unspecified. Because it is cast to a bool this therefore returned true instead of the expected false.
At one point this was changed from a bool to an int in libxml2, with negative values meaning it is unspecified. Because it is cast to a bool this therefore returned true instead of the expected false.
* PHP-8.1: Fix GH-11791: Wrong default value of DOMDocument::xmlStandalone
* PHP-8.2: Fix GH-11791: Wrong default value of DOMDocument::xmlStandalone
At one point this was changed from a bool to an int in libxml2, with negative values meaning it is unspecified. Because it is cast to a bool this therefore returned true instead of the expected false. Closes phpGH-11793.
The documentation here says that xmlStandalone defaults to false when missing, but the following test fails on PHP 8.1*:
* I haven't tried it on other PHP versions and 3v4l.org sadly misses
DOMDocument
..The text was updated successfully, but these errors were encountered: