svn: /php/php-src/branches/PHP_5_3/ NEWS ext/simplexml/simplexml.c ext/simplexml/tests/008.phpt
| From: | Christian Stocker | Date: | Thu, 01 Sep 2011 13:42:45 +0000 |
| Subject: | svn: /php/php-src/branches/PHP_5_3/ NEWS ext/simplexml/simplexml.c ext/simplexml/tests/008.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-66129@lists.php.net to get a copy of this message | ||
chregu Thu, 01 Sep 2011 13:42:45 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=315990
Log:
Merge from Trunk
simplexml->query returns empty array if no nodes were found
and false if libxml thinks the xpath-expression was invalid.
Behaves now the same like DomXPath and fixes Bug #48601
Adjusted a test to reflect that change
Bug: https://bugs.php.net/48601 (Re-Opened) xpath() returns
FALSE for legitimate query
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/simplexml/simplexml.c
U php/php-src/branches/PHP_5_3/ext/simplexml/tests/008.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2011-09-01 13:37:49 UTC (rev 315989)
+++ php/php-src/branches/PHP_5_3/NEWS 2011-09-01 13:42:45 UTC (rev 315990)
@@ -26,6 +26,12 @@
. Don't set $_SERVER['HTTPS'] on unsecure connection (bug #55403). (Uwe
Schindler)
+- SimpleXML:
+ . Reverted the SimpleXML->query() behaviour to returning empty arrays
+ instead of false when no nodes are found as it was since 5.3.3
+ (bug #48601). (chregu, rrichards)
+
+
23 Aug 2011, PHP 5.3.8
- Core:
Modified: php/php-src/branches/PHP_5_3/ext/simplexml/simplexml.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/simplexml/simplexml.c 2011-09-01 13:37:49 UTC (rev 315989)
+++ php/php-src/branches/PHP_5_3/ext/simplexml/simplexml.c 2011-09-01 13:42:45 UTC (rev 315990)
@@ -1264,8 +1264,9 @@
result = retval->nodesetval;
+ array_init(return_value);
+
if (result != NULL) {
- array_init(return_value);
for (i = 0; i < result->nodeNr; ++i) {
nodeptr = result->nodeTab[i];
if (nodeptr->type == XML_TEXT_NODE || nodeptr->type == XML_ELEMENT_NODE ||
nodeptr->type == XML_ATTRIBUTE_NODE) {
@@ -1286,8 +1287,6 @@
add_next_index_zval(return_value, value);
}
}
- } else {
- RETVAL_FALSE;
}
xmlXPathFreeObject(retval);
Modified: php/php-src/branches/PHP_5_3/ext/simplexml/tests/008.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/simplexml/tests/008.phpt 2011-09-01 13:37:49 UTC (rev 315989)
+++ php/php-src/branches/PHP_5_3/ext/simplexml/tests/008.phpt 2011-09-01 13:42:45 UTC (rev 315990)
@@ -25,7 +25,10 @@
$sxe = simplexml_load_string($xml);
var_dump($sxe->xpath("elem1/elem2/elem3/elem4"));
+//valid expression
var_dump($sxe->xpath("***"));
+//invalid expression
+var_dump($sxe->xpath("**"));
?>
--EXPECTF--
array(1) {
@@ -36,4 +39,10 @@
}
}
}
+array(0) {
+}
+
+Warning: SimpleXMLElement::xpath(): Invalid expression in %s on line %d
+
+Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in %s on line %d
bool(false)