mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Improve error messages for XSLTProcessor::transformToDoc() (#12332)
* Improve error messages for XSLTProcessor::transformToDoc() Also adds a relevant test file, as these branches were untested before.
This commit is contained in:
parent
41ea14b154
commit
f88368cfc8
2 changed files with 39 additions and 9 deletions
|
@ -497,14 +497,14 @@ PHP_METHOD(XSLTProcessor, transformToDoc)
|
|||
zval *id, *docp = NULL;
|
||||
xmlDoc *newdocp;
|
||||
xsltStylesheetPtr sheetp;
|
||||
zend_string *ret_class = NULL;
|
||||
zend_class_entry *ret_class = NULL;
|
||||
xsl_object *intern;
|
||||
|
||||
id = ZEND_THIS;
|
||||
intern = Z_XSL_P(id);
|
||||
sheetp = (xsltStylesheetPtr) intern->ptr;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|S!", &docp, &ret_class) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|C!", &docp, &ret_class) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
|
@ -513,7 +513,7 @@ PHP_METHOD(XSLTProcessor, transformToDoc)
|
|||
if (newdocp) {
|
||||
if (ret_class) {
|
||||
zend_string *curclass_name;
|
||||
zend_class_entry *curce, *ce;
|
||||
zend_class_entry *curce;
|
||||
php_libxml_node_object *interndoc;
|
||||
|
||||
curce = Z_OBJCE_P(docp);
|
||||
|
@ -522,16 +522,15 @@ PHP_METHOD(XSLTProcessor, transformToDoc)
|
|||
curce = curce->parent;
|
||||
}
|
||||
|
||||
ce = zend_lookup_class(ret_class);
|
||||
if (ce == NULL || !instanceof_function(ce, curce)) {
|
||||
if (!instanceof_function(ret_class, curce)) {
|
||||
xmlFreeDoc(newdocp);
|
||||
zend_argument_type_error(2, "must be a class name compatible with %s, \"%s\" given",
|
||||
ZSTR_VAL(curclass_name), ZSTR_VAL(ret_class)
|
||||
zend_argument_type_error(2, "must be a class name compatible with %s, %s given",
|
||||
ZSTR_VAL(curclass_name), ZSTR_VAL(ret_class->name)
|
||||
);
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
object_init_ex(return_value, ce);
|
||||
object_init_ex(return_value, ret_class);
|
||||
|
||||
interndoc = Z_LIBXML_NODE_P(return_value);
|
||||
php_libxml_increment_doc_ref(interndoc, newdocp);
|
||||
|
@ -542,7 +541,6 @@ PHP_METHOD(XSLTProcessor, transformToDoc)
|
|||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
/* }}} end XSLTProcessor::transformToDoc */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue