com php-src: Fixed bug #67741 (auto_prepend_file messes up __LINE__): main/main.c sapi/cli/tests /bug67741.phpt sapi/cli/tests/bug67741 _stub.inc

From: Date: Tue, 03 Mar 2015 03:25:30 +0000
Subject: com php-src: Fixed bug #67741 (auto_prepend_file messes up __LINE__): main/main.c sapi/cli/tests /bug67741.phpt sapi/cli/tests/bug67741 _stub.inc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85148@lists.php.net to get a copy of this message
Commit: 34f09b62408759e9d8754ccdd790c6586507a4d2 Author: Reeze Xia <reeze@php.net> Tue, 3 Mar 2015 11:25:30 +0800 Parents: fc1f24b7a6e614e83ab29f640c883839bc4e4696 Branches: PHP-5.5 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=34f09b62408759e9d8754ccdd790c6586507a4d2 Log: Fixed bug #67741 (auto_prepend_file messes up __LINE__) This also fixes bug #54081 Bugs: https://bugs.php.net/67741 https://bugs.php.net/54081 Changed paths: M main/main.c A sapi/cli/tests/bug67741.phpt A sapi/cli/tests/bug67741_stub.inc Diff: diff --git a/main/main.c b/main/main.c index 8f5bac1..9f7c153 100644 --- a/main/main.c +++ b/main/main.c @@ -2507,8 +2507,21 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC) #endif zend_set_timeout(INI_INT("max_execution_time"), 0); } - retval = (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 3, prepend_file_p, primary_file, append_file_p) == SUCCESS); + { + /* + If cli primary file has shabang line and there is a prepend file, + the start_lineno will be used by prepend file but not primary file, + save it and restore after prepend file been executed. + */ + int orig_start_lineno = CG(start_lineno); + + CG(start_lineno) = 0; + retval = (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 1, prepend_file_p) == SUCCESS); + CG(start_lineno) = orig_start_lineno; + + retval = retval && (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 2, primary_file, append_file_p) == SUCCESS); + } } zend_end_try(); #if HAVE_BROKEN_GETCWD diff --git a/sapi/cli/tests/bug67741.phpt b/sapi/cli/tests/bug67741.phpt new file mode 100644 index 0000000..df09814 --- /dev/null +++ b/sapi/cli/tests/bug67741.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #67741 (auto_prepend_file messes up __LINE__) +--INI-- +include_path={PWD} +auto_prepend_file=bug67741_stub.inc +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +#!/bin/env php +<?php +echo "primary lineno: ", __LINE__, "\n"; +?> +--EXPECT-- +prepend lineno: 2 +primary lineno: 3 \ No newline at end of file diff --git a/sapi/cli/tests/bug67741_stub.inc b/sapi/cli/tests/bug67741_stub.inc new file mode 100644 index 0000000..4d7470e --- /dev/null +++ b/sapi/cli/tests/bug67741_stub.inc @@ -0,0 +1,3 @@ +<?php +echo "prepend lineno: ", __LINE__, "\n"; +?>

« previous php.cvs (#85148) next »