Browse Source

fix bug #48601 (xpath() returns FALSE for legitimate query)

add test
experimental/lemon
Rob Richards 16 years ago
parent
commit
8a0450698d
  1. 6
      ext/simplexml/simplexml.c
  2. 20
      ext/simplexml/tests/bug48601.phpt

6
ext/simplexml/simplexml.c

@ -1258,13 +1258,10 @@ SXE_METHOD(xpath)
}
result = retval->nodesetval;
if (!result) {
xmlXPathFreeObject(retval);
RETURN_FALSE;
}
array_init(return_value);
if (result != NULL) {
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) {
@ -1285,6 +1282,7 @@ SXE_METHOD(xpath)
add_next_index_zval(return_value, value);
}
}
}
xmlXPathFreeObject(retval);
}

20
ext/simplexml/tests/bug48601.phpt

@ -0,0 +1,20 @@
--TEST--
Bug #48601 (xpath() returns FALSE for legitimate query)
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
<?php
$sxe = simplexml_load_string('<root><node1>1</node1></root>');
$nodes = $sxe->xpath("/root/node2/@test");
if (! is_array($nodes)) {
echo "An error occured\n";
} else {
echo "Result Count: " . count($nodes) . "\n";
}
?>
--EXPECTF--
Result Count: 0
Loading…
Cancel
Save