Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/dom/document.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int dom_document_standalone_read(dom_object *obj, zval *retval)
return FAILURE;
}

ZVAL_BOOL(retval, docp->standalone);
ZVAL_BOOL(retval, docp->standalone > 0);
return SUCCESS;
}

Expand Down
4 changes: 2 additions & 2 deletions ext/dom/tests/domobject_debug_handler.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ DOMDocument Object
[actualEncoding] =>
[encoding] =>
[xmlEncoding] =>
[standalone] => 1
[xmlStandalone] => 1
[standalone] =>
[xmlStandalone] =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I'm going to be annoying, but could you maybe change the print_r() to a var_dump() so there are not the trailing white spaces. As this will cause issues with IDEs...

[version] => 1.0
[xmlVersion] => 1.0
[strictErrorChecking] => 1
Expand Down
39 changes: 39 additions & 0 deletions ext/dom/tests/gh11791.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--TEST--
GH-11791 (Wrong default value of DOMDocument.xmlStandalone)
--EXTENSIONS--
dom
--FILE--
<?php
$doc = new DOMDocument();
$doc->loadXML('<root/>');
var_dump($doc->xmlStandalone);
$doc->xmlStandalone = true;
var_dump($doc->xmlStandalone);

$doc = new DOMDocument();
$doc->loadXML('<?xml version="1.0"?><root/>');
var_dump($doc->xmlStandalone);
$doc->xmlStandalone = true;
var_dump($doc->xmlStandalone);

$doc = new DOMDocument();
$doc->loadXML('<?xml version="1.0" standalone="no"?><root/>');
var_dump($doc->xmlStandalone);
$doc->xmlStandalone = true;
var_dump($doc->xmlStandalone);

$doc = new DOMDocument();
$doc->loadXML('<?xml version="1.0" standalone="yes"?><root/>');
var_dump($doc->xmlStandalone);
$doc->xmlStandalone = false;
var_dump($doc->xmlStandalone);
?>
--EXPECT--
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(true)
bool(false)