From 60daeb824116e877275075c65884d55257475e92 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 19 Sep 2024 00:44:44 +0200 Subject: [PATCH] Fix failed assertion when promoting Serialize deprecation to exception Fixes GH-15907 --- Zend/tests/gh15907.phpt | 18 ++++++++++++++++++ Zend/zend_interfaces.c | 4 ++++ 2 files changed, 22 insertions(+) create mode 100644 Zend/tests/gh15907.phpt diff --git a/Zend/tests/gh15907.phpt b/Zend/tests/gh15907.phpt new file mode 100644 index 0000000000000..8d6dada36ad08 --- /dev/null +++ b/Zend/tests/gh15907.phpt @@ -0,0 +1,18 @@ +--TEST-- +GH-15907: Failed assertion when promoting inheritance error to exception +--FILE-- + +--EXPECTF-- +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 +%a diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index b8cc5e94caca8..39d647c7e29f3 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -473,6 +473,10 @@ static int zend_implement_serializable(zend_class_entry *interface, zend_class_e if (!(class_type->ce_flags & ZEND_ACC_EXPLICIT_ABSTRACT_CLASS) && (!class_type->__serialize || !class_type->__unserialize)) { 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)); + if (EG(exception)) { + zend_exception_uncaught_error( + "During inheritance of %s, while implementing Serializable", ZSTR_VAL(class_type->name)); + } } return SUCCESS; }