From: Máté Kocsis Date: Sun, 3 May 2020 10:18:55 +0000 (+0200) Subject: Fix UNKNOWN default values in ext/xsl X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=89d170758777f0f888006dcca8972966ca14ede4;p=php Fix UNKNOWN default values in ext/xsl --- diff --git a/ext/xsl/php_xsl.stub.php b/ext/xsl/php_xsl.stub.php index 23f187fbdd..9e79c9c634 100644 --- a/ext/xsl/php_xsl.stub.php +++ b/ext/xsl/php_xsl.stub.php @@ -41,10 +41,10 @@ class XSLTProcessor public function hasExsltSupport() {} /** - * @param string|array $restrict + * @param string|array|null $restrict * @return void */ - public function registerPHPFunctions($restrict = UNKNOWN) {} + public function registerPHPFunctions($restrict = null) {} /** @return bool */ public function setProfiling(?string $filename) {} diff --git a/ext/xsl/php_xsl_arginfo.h b/ext/xsl/php_xsl_arginfo.h index e9cc9009ae..8093a9316f 100644 --- a/ext/xsl/php_xsl_arginfo.h +++ b/ext/xsl/php_xsl_arginfo.h @@ -35,7 +35,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_hasExsltSupport, 0, 0, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_registerPHPFunctions, 0, 0, 0) - ZEND_ARG_INFO(0, restrict) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, restrict, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_setProfiling, 0, 0, 1) diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index 1ced2b7b74..815615dec4 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -760,13 +760,19 @@ PHP_METHOD(XSLTProcessor, registerPHPFunctions) { zval *id = ZEND_THIS; xsl_object *intern; - zval *array_value, *entry, new_string; - zend_string *name; + zval *entry, new_string; + zend_string *restrict_str = NULL; + HashTable *restrict_ht = NULL; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "a", &array_value) == SUCCESS) { - intern = Z_XSL_P(id); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(restrict_str, restrict_ht) + ZEND_PARSE_PARAMETERS_END(); + + intern = Z_XSL_P(id); - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array_value), entry) { + if (restrict_ht) { + ZEND_HASH_FOREACH_VAL(restrict_ht, entry) { zend_string *str = zval_try_get_string(entry); if (UNEXPECTED(!str)) { return; @@ -777,15 +783,11 @@ PHP_METHOD(XSLTProcessor, registerPHPFunctions) } ZEND_HASH_FOREACH_END(); intern->registerPhpFunctions = 2; - } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "S", &name) == SUCCESS) { - intern = Z_XSL_P(id); - - ZVAL_LONG(&new_string,1); - zend_hash_update(intern->registered_phpfunctions, name, &new_string); + } else if (restrict_str) { + ZVAL_LONG(&new_string, 1); + zend_hash_update(intern->registered_phpfunctions, restrict_str, &new_string); intern->registerPhpFunctions = 2; - - } else if (zend_parse_parameters_none() == SUCCESS) { - intern = Z_XSL_P(id); + } else { intern->registerPhpFunctions = 1; } }