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

- Thread: https://externals.io/message/25247
- Original archive: https://news-web.php.net/php.internals/25247
- Started by Carl P. Corliss on 2006-08-08T18:58:51+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #25247 — Carl P. Corliss — 2006-08-08T18:58:51+00:00

URL: https://externals.io/message/25247#25247

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)

---

## #25248 — Carl P. Corliss — 2006-08-08T19:07:19+00:00

URL: https://externals.io/message/25247#25248 · In reply to: #25247

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

---

## #25349 — Carl P. Corliss — 2006-08-14T16:46:19+00:00

URL: https://externals.io/message/25247#25349 · In reply to: #25248

Carl P. Corliss wrote:
> Carl P. Corliss wrote:
> > […]
> [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
