[PATCH] User defined Error Handler's unable to include() class definitions in error handler functions

php.internals

Carl P. Corliss

20 years ago
Hi all :-) Please forgive my intrusion - I just wanted to submit this patch for a what others and I believe might be a bug . Basically, this patch fixes a problem where, if a class emits an error during declaration (ie: after active_class_entry is set in the function zend_do_begin_class_declaration but before it is nulled in function zend_do_end_class_declaration), and the user defined error handler function include()'s or require()'s a file containing another class definition, then the compiler will error out with an error stating "Class declarations may not be nested." For example code, see bug #35634 (http://bugs.php.net/bug.php?id=35634). The code in the example provided by the bug shows that the class ErrorClass is technically declared globally within the scope of the class TestClass as TestClass is being parsed during the E_STRICT emit. But the new class really *is* being declared within the scope of the error handler function which is the one including the 'errorClass' file. However, due to the fact that the error triggered happens during the class declaration, active_class_entry is still set, and thus, when the class being included within the user defined error handler is parsed, it finds that active_class_entry is already set (to TestClass), so instead of emitting the E_STRICT, it now emits an E_COMPILE_ERROR when it shouldn't. This patch makes a change to zend.c:zend_error() such that, *just prior* to calling a user defined error handler, it will store the value of active_class_entry in a temporary variable, and then NULL it, make the call to the error handler, and then restore the value of active_class_entry. Thank you for your time. :-) Cheers!,
-- Carl P. Corliss (aka Rabbitt)

Carl P. Corliss

20 years ago
Carl P. Corliss wrote:
> Hi all :-) > > Please forgive my intrusion - I just wanted to submit this patch > for a what others and I believe might be a bug . Basically, this patch > fixes a problem where, if a class emits an error during declaration (ie:
[snip] D'oh - looks like gmane strips attachments. you can see the patch here: http://www.xaraya.com/~rabbitt/zend.c.patch cheers!,
-- Carl

Carl P. Corliss

20 years ago
Carl P. Corliss wrote:
> Carl P. Corliss wrote: >> Hi all :-) >> >> Please forgive my intrusion - I just wanted to submit this patch >> for a what others and I believe might be a bug . Basically, this patch >> fixes a problem where, if a class emits an error during declaration (ie: > [snip] > > D'oh - looks like gmane strips attachments. you can see the patch here: > > http://www.xaraya.com/~rabbitt/zend.c.patch
Hi there! Just curious if anyone had a chance to look at this yet... :-) Cheers!,
-- Carl