Skip to content

Instantly share code, notes, and snippets.

@chregu
Created August 31, 2011 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chregu/1183212 to your computer and use it in GitHub Desktop.
Save chregu/1183212 to your computer and use it in GitHub Desktop.
Index: ext/simplexml/tests/008.phpt
===================================================================
--- ext/simplexml/tests/008.phpt (revision 315865)
+++ ext/simplexml/tests/008.phpt (working copy)
@@ -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)
Index: ext/simplexml/simplexml.c
===================================================================
--- ext/simplexml/simplexml.c (revision 315865)
+++ ext/simplexml/simplexml.c (working copy)
@@ -1294,8 +1294,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) {
@@ -1316,8 +1317,6 @@
add_next_index_zval(return_value, value);
}
}
- } else {
- RETVAL_FALSE;
}
xmlXPathFreeObject(retval);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment