Skip to content

Commit 20e3692

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix failed assertion when promoting Serialize deprecation to exception
2 parents 91a07e7 + 756435a commit 20e3692

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Zend/tests/gh15907.phpt

Lines changed: 18 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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)