On January 30, 2004 12:03 pm, Rasmus Lerdorf wrote:
> Granted, I haven't looked closely at the code, but PHP knows that failure
> to open an include file is an E_WARNING not an E_ERROR.  An E_WARNING
> should never cause script execution to terminate.  If we already know it
> is non-fatal, why is the extra check needed?

A parse error is an interesting beast because unlike other fatal errors it is 
not handled by PHP's error handler inside main.c. It is not done there since 
that would leak the stdio stream opened in ZE. Inside the regular 
require/include we have very little data to see what happened, we only know 
what op_array is NULL. Whether this happend due to a parse error or a not 
found file is unknown. So there are 3 possibilities @ this point:
-> included file was not found
-> included file was found, but has a parse error
-> required file was found, but has a parse error
(if requires was was not found, ZE would've already bailed out).

Since we do not know which of the 3 occured, although I suppose the require 
situation can be optimized to: 
if (!new_op_array && ... == ZEND_REQUIRE)

For include situation we need to see if the error is due to the file not being 
there, in which case we can go forward with execution, or if the problem was 
due to a parse error, in which case we need to stop. The easiest way I saw of 
doing it (without modifying too much existing code) was to perform a 
zend_stream_open(), which would check if the file is avaliable.

Ilia

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to