Bogus bug??

php.internals

Robert Cummings

20 years ago
Could someone explain to my feeble mind how the bug reported at the following link is bogus? The added comment is pretty obtuse :( http://bugs.php.net/bug.php?id=35634&edit=2 Thanks, Rob.
-- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

Robert Cummings

20 years ago
On Sun, 2005-12-11 at 17:26, Robert Cummings wrote:
> Could someone explain to my feeble mind how the bug reported at the > following link is bogus? The added comment is pretty obtuse :( > > http://bugs.php.net/bug.php?id=35634&edit=2
I'd just like to add before a second person send me an RTFM type email, that I HAVE read the documentation for set_error_handler() and I am aware that it says that most E_STRICT errors can't be handled if they occur in the same file as the set_error_handler() call. The E_STRICT I'm attempting to catch however, is in another script. Maybe it's the same thing because I include the code, or I guess more than likely because it happens at parse time, but either way, I'm not nesting classes the parser just thinks I am which I thus categorize as a parser bug. Also it seems somewhat ironic that an attempt to catch an E_STRICT causes an E_FATAL *lol*. Thanks, Rob.
-- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

Bart de Boer

20 years ago
Robert Cummings wrote:
> On Sun, 2005-12-11 at 17:26, Robert Cummings wrote: > > Could someone explain to my feeble mind how the bug reported at the > following link is bogus? The added comment is pretty obtuse :( > > http://bugs.php.net/bug.php?id=35634&edit=2 > > Thanks, > Rob.
It looks like each time your errorHandler function is called it is trying to (re)declaring ErrorClass, causing the error. If you take require_once('errorClass.php'); out of the errorHandler function, it works as expected. Bart

Robert Cummings

20 years ago
On Sun, 2005-12-11 at 19:02, Bart de Boer wrote:
> Robert Cummings wrote: > > On Sun, 2005-12-11 at 17:26, Robert Cummings wrote: > > > > Could someone explain to my feeble mind how the bug reported at the > > following link is bogus? The added comment is pretty obtuse :( > > > > http://bugs.php.net/bug.php?id=35634&edit=2 > > > > It looks like each time your errorHandler function is called it is > trying to (re)declaring ErrorClass, causing the error. If you take > require_once('errorClass.php'); out of the errorHandler function, it > works as expected.
This sample on the bug report is actually a very whittled down version of where I first experienced the problem. In practice my error class is loaded on first error and subsequently acts as a singleton. My thoughts on the problem are that PHP encounters an E_STRICT exception in testClass.php during the parse, so it invokes the error handler, the error handler then loads the error class, but because the error itself occured during the parsing of a class PHP still thinks it's parsing the class and so when errorClass.php is parsed it fires the fatal error for class nesting. IMHO that's a parser bug since PHP should (as it normally does) consider an included/required class description to be outside the the inclusion scope. As an FYI, the reason i use this technique is because my framework uses a registry type system for modular system services that are lazy loaded, one of which is the exception service. I guess I missed this problem in earlier versions of PHP5 because I filter out E_STRICT notices in the wrapper function that I refuse to correct in my engine for PHP4 compatibility reasons (I currently filter 3). But it raises the issue that anytime a new E_STRICT type error is created that I may not have addressed yet, the result is a fatal error instead of an annoying E_STRICT :) Cheers, Rob.
-- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

Bart de Boer

20 years ago
Robert Cummings wrote:
> > This sample on the bug report is actually a very whittled down version > of where I first experienced the problem. In practice my error class is > loaded on first error and subsequently acts as a singleton. My thoughts > on the problem are that PHP encounters an E_STRICT exception in > testClass.php during the parse, so it invokes the error handler, the > error handler then loads the error class, but because the error itself > occured during the parsing of a class PHP still thinks it's parsing the > class and so when errorClass.php is parsed it fires the fatal error for > class nesting. IMHO that's a parser bug since PHP should (as it normally > does) consider an included/required class description to be outside the > the inclusion scope. > > As an FYI, the reason i use this technique is because my framework uses > a registry type system for modular system services that are lazy loaded, > one of which is the exception service. I guess I missed this problem in > earlier versions of PHP5 because I filter out E_STRICT notices in the > wrapper function that I refuse to correct in my engine for PHP4 > compatibility reasons (I currently filter 3). But it raises the issue > that anytime a new E_STRICT type error is created that I may not have > addressed yet, the result is a fatal error instead of an annoying > E_STRICT :) > > Cheers, > Rob.
It looks like it happens the way you say. And I'm afraid I don't know if this is by PHP's design or not. Regarding the FMY. Shouldn't error handling be something that is part of your framework? And not part of your plugin modules? That's the way I consider it with my modular apps at least. :) Bart