Skip to content

Commit 0520bac

Browse files
committed
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5: Fix GH-23896: Assertion failure in zend_call_function() after a throwing deprecation
2 parents d746ea6 + e6775b3 commit 0520bac

3 files changed

Lines changed: 40 additions & 3 deletions

File tree

‎Zend/tests/gh23896.phpt‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
GH-23896 (Assertion failure in zend_call_function() when the error handler throws during parent:: callable resolution)
3+
--FILE--
4+
<?php
5+
set_error_handler(function ($severity, $m) {
6+
throw new Exception($m, $severity);
7+
});
8+
spl_autoload_register(function ($class) {
9+
if ($class === 'Loader') {
10+
throw new Exception("Cannot load $class");
11+
}
12+
});
13+
class P {}
14+
class C extends P {
15+
public function u(string $s) {
16+
return unserialize($s);
17+
}
18+
}
19+
foreach (['parent::my_unserialize', 'Loader::load'] as $callback) {
20+
ini_set('unserialize_callback_func', $callback);
21+
try {
22+
(new C)->u('O:3:"FOO":0:{}');
23+
} catch (Exception $e) {
24+
echo $e->getMessage(), "\n";
25+
var_dump($e->getPrevious());
26+
}
27+
}
28+
?>
29+
--EXPECT--
30+
Use of "parent" in callables is deprecated
31+
NULL
32+
Cannot load Loader
33+
NULL

‎Zend/zend_execute_API.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,12 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_
848848
}
849849

850850
if (!zend_is_callable_ex(&fci->function_name, fci->object, 0, NULL, fci_cache, &error)) {
851+
if (EG(exception)) {
852+
if (error) {
853+
efree(error);
854+
}
855+
return SUCCESS;
856+
}
851857
ZEND_ASSERT(error && "Should have error if not callable");
852858
zend_string *callable_name
853859
= zend_get_callable_name_ex(&fci->function_name, fci->object);

‎ext/xsl/tests/throw_in_autoload.phpt‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ $proc->registerPhpFunctions();
2828
$xsl = $proc->importStylesheet($xsl);
2929
try {
3030
$newdom = $proc->transformToDoc($inputdom);
31-
} catch (Error $e) {
31+
} catch (Exception $e) {
3232
echo $e->getMessage(), "\n";
33-
echo $e->getPrevious()->getMessage(), "\n";
3433
}
3534
?>
3635
===DONE===
3736
--EXPECT--
3837
string(4) "TeSt"
39-
Invalid callback TeSt::dateLang, class "TeSt" not found
4038
Autoload exception
4139
===DONE===

0 commit comments

Comments
 (0)