mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.4'
* PHP-8.4: Free the trampoline when deprecation on materializing `__callStatic()` of trait throws (#17729)
This commit is contained in:
commit
6024122e54
2 changed files with 34 additions and 6 deletions
24
Zend/tests/gh_17728.phpt
Normal file
24
Zend/tests/gh_17728.phpt
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
--TEST--
|
||||||
|
GH-17728: Assertion failure when calling static method of trait with `__callStatic()` with throwing error handler
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) {
|
||||||
|
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
|
||||||
|
});
|
||||||
|
|
||||||
|
trait Foo {
|
||||||
|
public static function __callStatic($method, $args) {
|
||||||
|
var_dump($method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Foo::bar();
|
||||||
|
} catch (ErrorException $e) {
|
||||||
|
echo $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
Calling static trait method Foo::bar is deprecated, it should only be called on a class using the trait
|
|
@ -1898,23 +1898,27 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
|
||||||
if (EXPECTED(fbc)) {
|
if (EXPECTED(fbc)) {
|
||||||
if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_ABSTRACT)) {
|
if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_ABSTRACT)) {
|
||||||
zend_abstract_method_call(fbc);
|
zend_abstract_method_call(fbc);
|
||||||
if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
|
goto fail;
|
||||||
zend_string_release_ex(fbc->common.function_name, 0);
|
|
||||||
zend_free_trampoline(fbc);
|
|
||||||
}
|
|
||||||
fbc = NULL;
|
|
||||||
} else if (UNEXPECTED(fbc->common.scope->ce_flags & ZEND_ACC_TRAIT)) {
|
} else if (UNEXPECTED(fbc->common.scope->ce_flags & ZEND_ACC_TRAIT)) {
|
||||||
zend_error(E_DEPRECATED,
|
zend_error(E_DEPRECATED,
|
||||||
"Calling static trait method %s::%s is deprecated, "
|
"Calling static trait method %s::%s is deprecated, "
|
||||||
"it should only be called on a class using the trait",
|
"it should only be called on a class using the trait",
|
||||||
ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
|
ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fbc;
|
return fbc;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
|
||||||
|
zend_string_release_ex(fbc->common.function_name, 0);
|
||||||
|
zend_free_trampoline(fbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue