Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7432 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63723 invoked by uid 1010); 30 Jan 2004 18:37:49 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 63688 invoked from network); 30 Jan 2004 18:37:49 -0000 Received: from unknown (HELO asuka.nerv) (24.100.195.79) by pb1.pair.com with SMTP; 30 Jan 2004 18:37:49 -0000 Received: (qmail 1357 invoked from network); 30 Jan 2004 18:37:48 -0000 Received: from rei.nerv (HELO dummy.com) (rei@192.168.1.1) by asuka.nerv with SMTP; 30 Jan 2004 18:37:48 -0000 Reply-To: ilia@prohost.org Organization: Prohost.org To: Rasmus Lerdorf , internals@lists.php.net Date: Fri, 30 Jan 2004 13:37:52 -0500 User-Agent: KMail/1.5.94 References: <200401301317.43714.ilia@prohost.org> In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: Multipart/Mixed; boundary="Boundary-00=_ASqGA75APEZKaHg" Message-ID: <200401301337.52932.ilia@prohost.org> Subject: Re: [PHP-DEV] Warnings in include files suddenly treated as fatal From: ilia@prohost.org (Ilia Alshanetsky) --Boundary-00=_ASqGA75APEZKaHg Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Here is the ZE1 revision. Ilia On January 30, 2004 01:21 pm, you wrote: > On Fri, 30 Jan 2004, Ilia Alshanetsky wrote: > > 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. > > Uh, that is a ZE2 patch. We are talking about PHP 4.3.5 RC2 here. > > -Rasmus --Boundary-00=_ASqGA75APEZKaHg Content-Type: text/plain; charset="iso-8859-1"; name="zeinc1.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="zeinc1.txt" Index: zend_execute.c =================================================================== RCS file: /repository/Zend/Attic/zend_execute.c,v retrieving revision 1.316.2.28 diff -u -3 -p -r1.316.2.28 zend_execute.c --- zend_execute.c 30 Jan 2004 02:22:31 -0000 1.316.2.28 +++ zend_execute.c 30 Jan 2004 18:37:21 -0000 @@ -2152,7 +2152,24 @@ send_by_ref: 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)->opcode == 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 = {0}; + int can_open = (zend_open(inc_filename->value.str.val, &file_handle) == SUCCESS && ZEND_IS_VALID_FILE_HANDLE(&file_handle)); + zend_file_handle_dtor(&file_handle); + + /* file open succeeded but still no op-array, likely parse error */ + if (can_open) { +fatal_error: + zend_error(E_ERROR, "Parse error inside included file."); + } + } } break; case ZEND_EVAL: { --Boundary-00=_ASqGA75APEZKaHg--