mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Promote warnings in ext/xsl
This commit is contained in:
parent
1efbc2cf58
commit
2f601d84cd
3 changed files with 46 additions and 27 deletions
|
@ -11,9 +11,12 @@ if (!extension_loaded('xsl')) {
|
|||
|
||||
$xslt = new XSLTProcessor();
|
||||
$dummy = new stdClass();
|
||||
try {
|
||||
var_dump($xslt->importStylesheet($dummy));
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Invalid Document in %s on line %d
|
||||
bool(false)
|
||||
--EXPECT--
|
||||
XSLTProcessor::importStylesheet(): Argument #1 ($stylesheet) must be a valid XML node
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
--TEST--
|
||||
Calling XSLTProcessor::transformToDoc() without stylesheet
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
|
||||
$xsl = new XSLTProcessor;
|
||||
try {
|
||||
$xsl->transformToDoc($doc);
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
XSLTProcessor::transformToDoc() can only be called after a stylesheet has been imported
|
|
@ -66,11 +66,7 @@ static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params)
|
|||
memset((char *)params, 0, parsize);
|
||||
|
||||
ZEND_HASH_FOREACH_STR_KEY_VAL(parht, string_key, value) {
|
||||
if (string_key == NULL) {
|
||||
php_error_docref(NULL, E_WARNING, "Invalid argument or parameter array");
|
||||
efree(params);
|
||||
return NULL;
|
||||
} else {
|
||||
ZEND_ASSERT(string_key != NULL);
|
||||
if (Z_TYPE_P(value) != IS_STRING) {
|
||||
if (!try_convert_to_string(value)) {
|
||||
efree(params);
|
||||
|
@ -87,7 +83,6 @@ static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params)
|
|||
params[i++] = estrndup(ZSTR_VAL(string_key), ZSTR_LEN(string_key));
|
||||
params[i++] = xpath_expr;
|
||||
}
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
params[i++] = NULL;
|
||||
|
@ -336,8 +331,8 @@ PHP_METHOD(XSLTProcessor, importStylesheet)
|
|||
doc = nodep->doc;
|
||||
}
|
||||
if (doc == NULL) {
|
||||
php_error(E_WARNING, "Invalid Document");
|
||||
RETURN_FALSE;
|
||||
zend_argument_value_error(1, "must be a valid XML node");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
/* libxslt uses _private, so we must copy the imported
|
||||
|
@ -417,13 +412,17 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl
|
|||
if (node) {
|
||||
doc = node->doc;
|
||||
}
|
||||
|
||||
if (doc == NULL) {
|
||||
php_error_docref(NULL, E_WARNING, "Invalid Document");
|
||||
zend_argument_value_error(1, "must be a valid XML node");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (style == NULL) {
|
||||
php_error_docref(NULL, E_WARNING, "No stylesheet associated to this object");
|
||||
zend_string *name = get_active_function_or_method_name();
|
||||
zend_throw_error(NULL, "%s() can only be called after a stylesheet has been imported",
|
||||
ZSTR_VAL(name));
|
||||
zend_string_release(name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue