com php-src: fix BC break introduced by #2346 (sebastianbergmann/phpunit#2454): ext/dom/document.c ext/dom/tests/DOMDocument_savexml_basic2.phpt
| From: | Joe Watkins | Date: | Mon, 30 Jan 2017 11:25:04 +0000 |
| Subject: | com php-src: fix BC break introduced by #2346 (sebastianbergmann/phpunit#2454): ext/dom/document.c ext/dom/tests/DOMDocument_savexml_basic2.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96908@lists.php.net to get a copy of this message | ||
Commit: 62938bf08806129b42b17e74d79a450c30d4ff30
Author: jhdxr <jhdxr@php.net> Mon, 30 Jan 2017 17:48:00 +0800
Committer: Joe Watkins <krakjoe@php.net> Mon, 30 Jan 2017 11:25:04 +0000
Parents: 4b1afc829c0d2a3fec999dbe7c32377b5ee91803
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=62938bf08806129b42b17e74d79a450c30d4ff30
Log:
fix BC break introduced by #2346 (sebastianbergmann/phpunit#2454)
Bugs:
https://bugs.php.net/2346
https://bugs.php.net/2454
Changed paths:
M ext/dom/document.c
A ext/dom/tests/DOMDocument_savexml_basic2.phpt
Diff:
diff --git a/ext/dom/document.c b/ext/dom/document.c
index c7e4f8e..d8e950d 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -1628,6 +1628,9 @@ PHP_FUNCTION(dom_document_savexml)
doc_props = dom_get_doc_props(intern->document);
format = doc_props->formatoutput;
+ if (format) {
+ options = options | XML_SAVE_FORMAT;
+ }
buf = xmlBufferCreate();
if (!buf) {
diff --git a/ext/dom/tests/DOMDocument_savexml_basic2.phpt
b/ext/dom/tests/DOMDocument_savexml_basic2.phpt
new file mode 100644
index 0000000..7c01014
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_savexml_basic2.phpt
@@ -0,0 +1,33 @@
+--TEST--
+DOM Document: saveXML with createElement and formatOutput
+--CREDITS--
+CHU Zhaowei <jhdxr@php.net>
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom = new domDocument('1.0', 'UTF-8');
+$dom->formatOutput = true;
+
+$root = $dom->createElement('root');
+$dom->appendChild($root);
+
+$child1 = $dom->createElement('testsuite');
+$root->appendChild($child1);
+
+$child11 = $dom->createElement('testcase');
+$child11->setAttribute('name', 'leaf1');
+$child12 = $dom->createElement('testcase');
+$child12->setAttribute('name', 'leaf2');
+$child1->appendChild($child11);
+$child1->appendChild($child12);
+
+echo $dom->saveXml();
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+ <testsuite>
+ <testcase name="leaf1"/>
+ <testcase name="leaf2"/>
+ </testsuite>
+</root>
\ No newline at end of file