-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assertion failure in Zend/zend_compile.c #15907
Comments
Relevant commit: c8fa477 Maybe the assertion is just too presumptious, given that an error handler may throw. Removing it, makes the given script pass. But that requires more thorough investigation, and I'm somewhat concerned that existing observers might make the same assumption. Tentatively qualifying this as bug. |
I mean, this is a common programming idiom, so this is definitely a bug. Technically it doesn't seem strictly necessary to bail here, since inheritance wasn't aborted. However, note that inheritance may still accidentally abort due to After removing the set_error_handler(function($_, $msg) {
throw new Exception($msg);
});
spl_autoload_register(function() {});
class P {
public function test(): X {}
}
class UnSerializable extends P implements Serializable {
public function serialize() {}
public function unserialize($serialized) {}
public function test(): Y {}
}
Not sure what the best resolution is. |
You are referring to throwing from an error handler? Yeah, that would be common. But imagine there were no error handlers … |
I don't follow. 🙂 |
If there were no error handlers, this ticket would be invalid, and more generally section 3.5 of https://biagiocosenza.com/papers/PopovCC17.pdf would no longer apply (and yes, I'm aware that |
Ah ^^ I agree that error handlers were a bad idea. I spent quite a bit of time last year trying to solve related issues. I also looked into alternatives with the possibility of deprecating them, but Nicolas Grekas didn't consider the alternative to be feature-complete. |
I would suggest adding a php-src/Zend/zend_interfaces.c Line 480 in 43dc2eb
Analogous to the code in c8fa477. Given the example from this comment, it isn't currently possible to handle this gracefully, as other code paths can still trigger a fatal error when promoting these warnings to exceptions. WDYT? |
That could be Zend/zend_interfaces.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c
index f3fb4151a5..7fc8a7bcfb 100644
--- a/Zend/zend_interfaces.c
+++ b/Zend/zend_interfaces.c
@@ -478,6 +478,9 @@ 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("While implementing the Serializable interface");
+ }
}
return SUCCESS;
} I think this makes perfect sense. |
Description
The following code:
Resulted in this output:
PHP Version
PHP 8.4.0-dev
Operating System
ubuntu 22.04
The text was updated successfully, but these errors were encountered: