Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ PHP NEWS
. Fixed bug GH-21478 (Forward property operations to real instance for
initialized lazy proxies). (iliaal)
. Fixed bug GH-21605 (Missing addref for Countable::count()). (ilutov)
. Fixed bug GH-21699 (Assertion failure in shutdown_executor when resolving
self::/parent::/static:: callables if the error handler throws).

- Curl:
. Add support for brotli and zstd on Windows. (Shivam Mathur)
Expand Down
7 changes: 6 additions & 1 deletion Zend/tests/gh16799.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ Test::test();
--EXPECTF--
Fatal error: Uncaught Exception: Use of "static" in callables is deprecated in %s:%d
Stack trace:
#0 %s(%d): {closure:%s:%d}(8192, 'Use of "static"...', %s, %d)
#0 %s(%d): {closure:%s}(8192, 'Use of "static"%s', '%s', %d)
#1 %s(%d): Test::test()
#2 {main}

Next TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, (null) in %s:%d
Stack trace:
#0 %s(%d): Test::test()
#1 {main}
thrown in %s on line %d
31 changes: 31 additions & 0 deletions Zend/tests/gh_21699.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
GH-21699: Assertion failure in shutdown_executor when error handler throws during self:: callable resolution
--FILE--
<?php
set_error_handler(function () {
throw new Exception;
});
class bar {
public static function __callstatic($fusion, $b)
{
}
public function test()
{
call_user_func('self::y');
}
}
$x = new bar;
$x->test();
?>
--EXPECTF--
Fatal error: Uncaught Exception in %s:%d
Stack trace:
#0 %s(%d): {closure:%s}(%d, 'Use of "self" i%s', '%s', %d)
#1 %s(%d): bar->test()
#2 {main}

Next TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, (null) in %s:%d
Stack trace:
#0 %s(%d): bar->test()
#1 {main}
thrown in %s on line %d
32 changes: 32 additions & 0 deletions Zend/tests/gh_21699_parent.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
GH-21699 (parent::): no shutdown_executor trampoline assertion when error handler throws during parent:: callable resolution
--FILE--
<?php
set_error_handler(function () {
throw new Exception;
});
class Base {
public static function __callStatic($name, $args)
{
}
}
class Child extends Base {
public function test()
{
call_user_func('parent::missing');
}
}
(new Child)->test();
?>
--EXPECTF--
Fatal error: Uncaught Exception in %s:%d
Stack trace:
#0 %s(%d): {closure:%s}(%d, 'Use of "parent"%s', '%s', %d)
#1 %s(%d): Child->test()
#2 {main}

Next TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, (null) in %s:%d
Stack trace:
#0 %s(%d): Child->test()
#1 {main}
thrown in %s on line %d
31 changes: 31 additions & 0 deletions Zend/tests/gh_21699_static.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
GH-21699 (static::): no shutdown_executor trampoline assertion when error handler throws during static:: callable resolution
--FILE--
<?php
set_error_handler(function () {
throw new Exception;
});
class bar {
public static function __callstatic($fusion, $b)
{
}
public function test()
{
call_user_func('static::y');
}
}
$x = new bar;
$x->test();
?>
--EXPECTF--
Fatal error: Uncaught Exception in %s:%d
Stack trace:
#0 %s(%d): {closure:%s}(%d, 'Use of "static"%s', '%s', %d)
#1 %s(%d): bar->test()
#2 {main}

Next TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, (null) in %s:%d
Stack trace:
#0 %s(%d): bar->test()
#1 {main}
thrown in %s on line %d
4 changes: 4 additions & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -3849,6 +3849,10 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
if (error) zend_spprintf(error, 0, "class \"%.*s\" not found", (int)name_len, ZSTR_VAL(name));
}
ZSTR_ALLOCA_FREE(lcname, use_heap);
/* User error handlers may throw from deprecations above; do not report callable as valid. */
if (UNEXPECTED(EG(exception))) {
return false;
}
Comment on lines +3852 to +3855
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to have this be where the E_DEPRECATED are emitted. But then others may disagree so this is fine.

return ret;
}
/* }}} */
Expand Down