summaryrefslogtreecommitdiff
path: root/ext/dom/xpath.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dom/xpath.c')
-rw-r--r--ext/dom/xpath.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c
index cc3cbf8433..1f97601c42 100644
--- a/ext/dom/xpath.c
+++ b/ext/dom/xpath.c
@@ -136,15 +136,9 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
obj = valuePop(ctxt);
if (obj->stringval == NULL) {
- php_error_docref(NULL, E_WARNING, "Handler name must be a string");
+ zend_type_error("Handler name must be a string");
xmlXPathFreeObject(obj);
- if (fci.param_count > 0) {
- for (i = 0; i < nargs - 1; i++) {
- zval_ptr_dtor(&fci.params[i]);
- }
- efree(fci.params);
- }
- return;
+ goto cleanup;
}
ZVAL_STRING(&fci.function_name, (char *) obj->stringval);
xmlXPathFreeObject(obj);
@@ -154,11 +148,11 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
fci.retval = &retval;
if (!zend_make_callable(&fci.function_name, &callable)) {
- php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable));
+ zend_throw_error(NULL, "Unable to call handler %s()", ZSTR_VAL(callable));
+ goto cleanup;
} else if (intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) {
- php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'.", ZSTR_VAL(callable));
- /* Push an empty string, so that we at least have an xslt result... */
- valuePush(ctxt, xmlXPathNewString((xmlChar *)""));
+ zend_throw_error(NULL, "Not allowed to call handler '%s()'.", ZSTR_VAL(callable));
+ goto cleanup;
} else {
result = zend_call_function(&fci, NULL);
if (result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
@@ -176,8 +170,8 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
} else if (Z_TYPE(retval) == IS_FALSE || Z_TYPE(retval) == IS_TRUE) {
valuePush(ctxt, xmlXPathNewBoolean(Z_TYPE(retval) == IS_TRUE));
} else if (Z_TYPE(retval) == IS_OBJECT) {
- php_error_docref(NULL, E_WARNING, "A PHP Object cannot be converted to a XPath-string");
- valuePush(ctxt, xmlXPathNewString((xmlChar *)""));
+ zend_type_error("A PHP Object cannot be converted to a XPath-string");
+ return;
} else {
zend_string *str = zval_get_string(&retval);
valuePush(ctxt, xmlXPathNewString((xmlChar *) ZSTR_VAL(str)));
@@ -186,6 +180,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
zval_ptr_dtor(&retval);
}
}
+cleanup:
zend_string_release_ex(callable, 0);
zval_ptr_dtor_str(&fci.function_name);
if (fci.param_count > 0) {
@@ -228,7 +223,7 @@ PHP_METHOD(DOMXPath, __construct)
ctx = xmlXPathNewContext(docp);
if (ctx == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
intern = Z_XPATHOBJ_P(ZEND_THIS);
@@ -308,8 +303,8 @@ PHP_METHOD(DOMXPath, registerNamespace)
ctxp = (xmlXPathContextPtr) intern->dom.ptr;
if (ctxp == NULL) {
- php_error_docref(NULL, E_WARNING, "Invalid XPath Context");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Invalid XPath Context");
+ RETURN_THROWS();
}
if (xmlXPathRegisterNs(ctxp, prefix, ns_uri) != 0) {
@@ -352,8 +347,8 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
ctxp = (xmlXPathContextPtr) intern->dom.ptr;
if (ctxp == NULL) {
- php_error_docref(NULL, E_WARNING, "Invalid XPath Context");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Invalid XPath Context");
+ RETURN_THROWS();
}
docp = (xmlDocPtr) ctxp->doc;
@@ -371,8 +366,8 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
}
if (nodep && docp != nodep->doc) {
- php_error_docref(NULL, E_WARNING, "Node From Wrong Document");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Node from wrong document");
+ RETURN_THROWS();
}
ctxp->node = nodep;
@@ -401,6 +396,7 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
}
if (! xpathobjp) {
+ /* TODO Add Warning? */
RETURN_FALSE;
}