Here is the final revision of the patch for the situation, if there are no 
last minute objections, it'll go in the CVS and we'll proceed with RC2.

Ilia

On January 30, 2004 12:37 pm, Rasmus Lerdorf wrote:
> On Fri, 30 Jan 2004, Ilia Alshanetsky wrote:
> > 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.
>
> Since this only happens on an error condition I guess it is ok.  Just
> seems like we should be able to set some kind of hint in Zend to pass
> this information back up.
>
> -Rasmus
Index: zend_execute.c
===================================================================
RCS file: /repository/ZendEngine2/zend_execute.c,v
retrieving revision 1.592
diff -u -3 -p -r1.592 zend_execute.c
--- zend_execute.c      30 Jan 2004 02:22:17 -0000      1.592
+++ zend_execute.c      30 Jan 2004 18:16:32 -0000
@@ -3390,7 +3390,24 @@ int zend_include_or_eval_handler(ZEND_OP
                case ZEND_REQUIRE:
                        new_op_array = 
compile_filename(EX(opline)->op2.u.constant.value.lval, inc_filename TSRMLS_CC);
                        if (!new_op_array) {
-                               zend_error(E_ERROR, "Parse error inside included 
file.");
+                               /* small optimization for require() */
+                               if (EX(opline)->op2.u.constant.value.lval == 
ZEND_REQUIRE) {
+                                       goto fatal_error;
+                               } else {
+                                       /* This check is needed to ensure that 
included file has a parse error 
+                                        * and we are no dealing with a non-existant 
include, which is not considered
+                                        * to be a fatal error.
+                                        */
+                                       zend_file_handle file_handle;
+                                       zend_bool can_open = 
zend_stream_open(inc_filename->value.str.val, &file_handle TSRMLS_CC);
+                                       zend_file_handle_dtor(&file_handle);
+
+                                       /* file open succeeded but still no op-array, 
likely parse error */
+                                       if (can_open == SUCCESS) {
+fatal_error:
+                                               zend_error(E_ERROR, "Parse error 
inside included file.");
+                                       }
+                               }
                        }
                        break;
                case ZEND_EVAL: {

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

Reply via email to