Skip to content

Commit ef416fa

Browse files
committed
Review
1 parent 79256fa commit ef416fa

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

ext/dom/document.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ zend_result dom_document_encoding_write(dom_object *obj, zval *newval)
161161
}
162162
docp->encoding = xmlStrdup((const xmlChar *) ZSTR_VAL(str));
163163
} else {
164-
zend_value_error("Invalid Document Encoding");
164+
zend_value_error("Invalid document encoding");
165165
return FAILURE;
166166
}
167167

ext/dom/node.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{
15941594
xmlXPathFreeObject(xpathobjp);
15951595
}
15961596
xmlXPathFreeContext(ctxp);
1597-
zend_throw_error(NULL, "XPath query did not return a nodeset.");
1597+
zend_throw_error(NULL, "XPath query did not return a nodeset");
15981598
RETURN_THROWS();
15991599
}
16001600
}
@@ -1606,12 +1606,11 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{
16061606

16071607
tmp = zend_hash_str_find(ht, "query", sizeof("query")-1);
16081608
if (!tmp) {
1609-
// TODO Use argument version after checking which num arg it is
1610-
zend_value_error("\"query\" option must be in XPath array");
1609+
zend_argument_value_error(3, "\"query\" option must be in XPath array");
16111610
RETURN_THROWS();
16121611
}
16131612
if (Z_TYPE_P(tmp) != IS_STRING) {
1614-
zend_type_error("\"query\" option must be a string, %s given", zend_zval_type_name(tmp));
1613+
zend_argument_type_error(3, "\"query\" option must be a string, %s given", zend_zval_type_name(tmp));
16151614
RETURN_THROWS();
16161615
}
16171616
xquery = Z_STRVAL_P(tmp);

ext/dom/php_dom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ PHP_FUNCTION(dom_import_simplexml)
468468
if (nodep && nodeobj && (nodep->type == XML_ELEMENT_NODE || nodep->type == XML_ATTRIBUTE_NODE)) {
469469
DOM_RET_OBJ((xmlNodePtr) nodep, &ret, (dom_object *)nodeobj);
470470
} else {
471-
zend_argument_value_error(1, "cannot import invalid node type");
471+
zend_argument_value_error(1, "is not a valid node type");
472472
RETURN_THROWS();
473473
}
474474
}

ext/dom/tests/DOMDocument_encoding_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ echo "UTF-16 Encoding Read: {$dom->encoding}\n";
4444
?>
4545
--EXPECT--
4646
Empty Encoding Read: ''
47-
Invalid Document Encoding
47+
Invalid document encoding
4848
Adding ISO-8859-1 encoding: ISO-8859-1
4949
ISO-8859-1 Encoding Read: ISO-8859-1
5050
Adding UTF-8 encoding: UTF-8

ext/dom/tests/bug77569.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ try {
1515
}
1616
?>
1717
--EXPECT--
18-
Invalid Document Encoding
18+
Invalid document encoding

ext/dom/tests/domxpath.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,17 @@ $root->appendChild($dom->createElementNS("urn::default", "testnode", 5));
5050

5151
$avg = $xpath->evaluate('number(php:function("MyAverage", //def:testnode))');
5252
var_dump($avg);
53+
54+
try {
55+
$xpath->registerPHPFunctions('non_existent');
56+
$avg = $xpath->evaluate('number(php:function("non_existent", //def:testnode))');
57+
} catch (\Error $e) {
58+
echo $e->getMessage() . \PHP_EOL;
59+
}
5360
?>
5461
--EXPECT--
5562
myval
5663
float(1)
5764
bool(true)
5865
float(4)
66+
Unable to call handler non_existent()

ext/dom/xpath.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
138138
if (obj->stringval == NULL) {
139139
zend_type_error("Handler name must be a string");
140140
xmlXPathFreeObject(obj);
141-
if (fci.param_count > 0) {
142-
for (i = 0; i < nargs - 1; i++) {
143-
zval_ptr_dtor(&fci.params[i]);
144-
}
145-
efree(fci.params);
146-
}
147-
return;
141+
goto cleanup;
148142
}
149143
ZVAL_STRING(&fci.function_name, (char *) obj->stringval);
150144
xmlXPathFreeObject(obj);
@@ -155,10 +149,10 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
155149

156150
if (!zend_make_callable(&fci.function_name, &callable)) {
157151
zend_throw_error(NULL, "Unable to call handler %s()", ZSTR_VAL(callable));
158-
return;
152+
goto cleanup;
159153
} else if (intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) {
160154
zend_throw_error(NULL, "Not allowed to call handler '%s()'.", ZSTR_VAL(callable));
161-
return;
155+
goto cleanup;
162156
} else {
163157
result = zend_call_function(&fci, NULL);
164158
if (result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
@@ -186,6 +180,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
186180
zval_ptr_dtor(&retval);
187181
}
188182
}
183+
cleanup:
189184
zend_string_release_ex(callable, 0);
190185
zval_ptr_dtor_str(&fci.function_name);
191186
if (fci.param_count > 0) {
@@ -372,7 +367,7 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
372367
}
373368

374369
if (nodep && docp != nodep->doc) {
375-
zend_throw_error(NULL, "Node From Wrong Document");
370+
zend_throw_error(NULL, "Node from wrong document");
376371
RETURN_THROWS();
377372
}
378373

0 commit comments

Comments
 (0)