Re: Warnings in include files suddenly treated as fatal

From: Date: Sun, 01 Feb 2004 17:30:52 +0000
Subject: Re: Warnings in include files suddenly treated as fatal
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-7460@lists.php.net to get a copy of this message
This sounds like a bug. The behavior should be that unless there was a parse error include/include_once should not halt but give a warning if the file doesn't exist. require/require_once should halt if the file doesn't exist. I understand from the comments here that your patch wasn't very successful. Any chance you can: a) Revert the patch. b) Send me a short reproducing example of the combination which doesn't currently work? I tried to include a file which has a parse error and it did stop execution right away (which it should). I guess I didn't quite understand which combination doesn't work. Thanks, Andi At 02:04 AM 2/1/2004 -0500, Ilia Alshanetsky wrote:
The basic problem is as follows. If you have a parse error inside an included or required file, the execution stops just for that file and continues for the main script. The result is that normally a fatal (parse) error becomes a warning. Consequently, it may result in undefined behavior since whatever code was inside the included file was not entirely parsed and executed. Ilia On January 31, 2004 04:17 pm, you wrote: I think I missed out on the original problem. What does the fix, fix? Isn't a parse error automatically a fatal error? If you revert your patch what won't work? Andi At 09:59 AM 1/30/2004 -0500, Ilia Alshanetsky wrote:
It seems like the only way to distinguish between a parse error and a non-existant file for regular include() is by doing a zend_stream_open() upon failure to determine if the file is avaliable. If it is, then we return a parse error and if it does not we continue execution. This does add a small overhead for failed includes, but IMHO if a non-existant files are being included performance is not a big consideration. That said, if there is much opposition to the approach I would be happy to revert the code to the previous state. Ilia P.S. Suggested 'fix' is attached. On January 30, 2004 05:29 am, Rasmus Lerdorf wrote:
Ilia, I think there is a problem with your latest fixes on the 4_3 branch. Stuff that used to work is now broken. Stuff like this: main.php: include 'inc1.inc'; inc1.inc: @include 'inc2.inc'; If inc2.inc does not exist we now get an error similar to: Warning: main(./lang/serendipity_lang_.inc.php): failed to open stream: No such file or directory in /var/www/s9y/serendipity_lang.inc.php on line 5 Warning: main(): Failed opening './inc2.inc' for inclusion (include_path='.:/usr/local/lib/php') on line {the include line #} Fatal error: Parse error inside included file. in /var/www/htdocs/inc1.inc on line {the include line #} Remember that it is ok for an include to not find the file. We issue a warning and move on. It should in no way be treated as a fatal error. -Rasmus
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#7460) next »