Skip to content

Commit 89d1707

Browse files
committed
Fix UNKNOWN default values in ext/xsl
1 parent daa5b26 commit 89d1707

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

ext/xsl/php_xsl.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public function removeParameter(string $namespace, string $name) {}
4141
public function hasExsltSupport() {}
4242

4343
/**
44-
* @param string|array $restrict
44+
* @param string|array|null $restrict
4545
* @return void
4646
*/
47-
public function registerPHPFunctions($restrict = UNKNOWN) {}
47+
public function registerPHPFunctions($restrict = null) {}
4848

4949
/** @return bool */
5050
public function setProfiling(?string $filename) {}

ext/xsl/php_xsl_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_hasExsltSupport, 0, 0, 0)
3535
ZEND_END_ARG_INFO()
3636

3737
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_registerPHPFunctions, 0, 0, 0)
38-
ZEND_ARG_INFO(0, restrict)
38+
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, restrict, "null")
3939
ZEND_END_ARG_INFO()
4040

4141
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XSLTProcessor_setProfiling, 0, 0, 1)

ext/xsl/xsltprocessor.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -760,13 +760,19 @@ PHP_METHOD(XSLTProcessor, registerPHPFunctions)
760760
{
761761
zval *id = ZEND_THIS;
762762
xsl_object *intern;
763-
zval *array_value, *entry, new_string;
764-
zend_string *name;
763+
zval *entry, new_string;
764+
zend_string *restrict_str = NULL;
765+
HashTable *restrict_ht = NULL;
765766

766-
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "a", &array_value) == SUCCESS) {
767-
intern = Z_XSL_P(id);
767+
ZEND_PARSE_PARAMETERS_START(0, 1)
768+
Z_PARAM_OPTIONAL
769+
Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(restrict_str, restrict_ht)
770+
ZEND_PARSE_PARAMETERS_END();
771+
772+
intern = Z_XSL_P(id);
768773

769-
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array_value), entry) {
774+
if (restrict_ht) {
775+
ZEND_HASH_FOREACH_VAL(restrict_ht, entry) {
770776
zend_string *str = zval_try_get_string(entry);
771777
if (UNEXPECTED(!str)) {
772778
return;
@@ -777,15 +783,11 @@ PHP_METHOD(XSLTProcessor, registerPHPFunctions)
777783
} ZEND_HASH_FOREACH_END();
778784

779785
intern->registerPhpFunctions = 2;
780-
} else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "S", &name) == SUCCESS) {
781-
intern = Z_XSL_P(id);
782-
783-
ZVAL_LONG(&new_string,1);
784-
zend_hash_update(intern->registered_phpfunctions, name, &new_string);
786+
} else if (restrict_str) {
787+
ZVAL_LONG(&new_string, 1);
788+
zend_hash_update(intern->registered_phpfunctions, restrict_str, &new_string);
785789
intern->registerPhpFunctions = 2;
786-
787-
} else if (zend_parse_parameters_none() == SUCCESS) {
788-
intern = Z_XSL_P(id);
790+
} else {
789791
intern->registerPhpFunctions = 1;
790792
}
791793
}

0 commit comments

Comments
 (0)