Skip to content

Commit 756435a

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix failed assertion when promoting Serialize deprecation to exception
2 parents d854a54 + 5cff4a9 commit 756435a

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ PHP NEWS
1414
. Fixed bug GH-16054 (Segmentation fault when resizing hash table iterator
1515
list while adding). (nielsdos)
1616
. Fixed bug GH-15905 (Assertion failure for TRACK_VARS_SERVER). (cmb)
17+
. Fixed bug GH-15907 (Failed assertion when promoting Serialize deprecation to
18+
exception). (ilutov)
1719

1820
- DOM:
1921
. Fixed bug GH-16039 (Segmentation fault (access null pointer) in

Zend/tests/gh15907.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
GH-15907: Failed assertion when promoting inheritance error to exception
3+
--FILE--
4+
<?php
5+
6+
set_error_handler(function($errno, $msg) {
7+
throw new Exception($msg);
8+
});
9+
10+
class C implements Serializable {
11+
public function serialize() {}
12+
public function unserialize($serialized) {}
13+
}
14+
15+
?>
16+
--EXPECTF--
17+
Fatal error: During inheritance of C, while implementing Serializable: Uncaught Exception: C implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s:%d
18+
%a

Zend/zend_interfaces.c

+4
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,10 @@ static int zend_implement_serializable(zend_class_entry *interface, zend_class_e
478478
if (!(class_type->ce_flags & ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)
479479
&& (!class_type->__serialize || !class_type->__unserialize)) {
480480
zend_error(E_DEPRECATED, "%s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)", ZSTR_VAL(class_type->name));
481+
if (EG(exception)) {
482+
zend_exception_uncaught_error(
483+
"During inheritance of %s, while implementing Serializable", ZSTR_VAL(class_type->name));
484+
}
481485
}
482486
return SUCCESS;
483487
}

0 commit comments

Comments
 (0)