]> granicus.if.org Git - php/commitdiff
Fix UNKNOWN default values in ext/xsl
authorMáté Kocsis <kocsismate@woohoolabs.com>
Sun, 3 May 2020 10:18:55 +0000 (12:18 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Wed, 6 May 2020 17:15:38 +0000 (19:15 +0200)
ext/xsl/php_xsl.stub.php
ext/xsl/php_xsl_arginfo.h
ext/xsl/xsltprocessor.c

index 23f187fbddea769e371326cac1f5cf5884546406..9e79c9c63489cbc8cc251ea8fe76456d3b4295c7 100644 (file)
@@ -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) {}
index e9cc9009ae09d29c8e31ab054e26f6be8b28744c..8093a9316fc781c2ef7c796f4d53ef3736b9f68e 100644 (file)
@@ -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)
index 1ced2b7b74049c0674b31ee33cf27420ef9b0fde..815615dec44bbb4e1f6274b8b9ae86465da959bd 100644 (file)
@@ -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;
        }
 }