php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67741 auto_prepend_file messes up __LINE__
Submitted: 2014-08-02 00:02 UTC Modified: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: dwilks at intacct dot com Assigned:
Status: Closed Package: CGI/CLI related
PHP Version: 5.4.31 OS: OSX 10.9.4
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dwilks at intacct dot com
New email:
PHP Version: OS:

 

 [2014-08-02 00:02 UTC] dwilks at intacct dot com
Description:
------------
In scripts that begin with a shebang (#!) line, __LINE__ is off-by-one when an auto_prepend_file is configured and is correct without an auto_prepend_file.  This happens when the script is executed by the shell or by passing it to php with the -f parameter.

I assume this is happening because auto_prepend_file is triggering a call to  zend_language_scanner:compile_file before the main script is compiled.  This causes the auto-prepended-file to trigger open_file_for_scanning's processing of start_lineno that is set in the cli sapi and by the time the main script is compiled start_lineno has been cleared.

This is pretty similar to https://bugs.php.net/bug.php?id=54081.

Test script:
---------------
#!/usr/local/php5/bin/php -q
<?php
echo "Line 3 is really line " . __LINE__ . "\n";


Expected result:
----------------
Line 3 is really line 3


Actual result:
--------------
Line 3 is really line 2


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-03 03:47 UTC] reeze@php.net
Automatic comment on behalf of reeze
Revision: http://git.php.net/?p=php-src.git;a=commit;h=34f09b62408759e9d8754ccdd790c6586507a4d2
Log: Fixed bug #67741 (auto_prepend_file messes up __LINE__)
 [2015-03-03 03:47 UTC] reeze@php.net
-Status: Open +Status: Closed
 [2015-03-03 03:47 UTC] reeze@php.net
Automatic comment on behalf of reeze
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4e2c87edb34c4f151da6899d523c93b8e8565975
Log: Fixed bug #67741 (auto_prepend_file messes up __LINE__)
 [2015-03-03 03:47 UTC] reeze@php.net
Automatic comment on behalf of reeze
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4e2c87edb34c4f151da6899d523c93b8e8565975
Log: Fixed bug #67741 (auto_prepend_file messes up __LINE__)
 [2015-03-03 06:38 UTC] reeze@php.net
Automatic comment on behalf of reeze
Revision: http://git.php.net/?p=php-src.git;a=commit;h=34f09b62408759e9d8754ccdd790c6586507a4d2
Log: Fixed bug #67741 (auto_prepend_file messes up __LINE__)
 [2015-03-03 07:19 UTC] dmitry@php.net
Automatic comment on behalf of reeze
Revision: http://git.php.net/?p=php-src.git;a=commit;h=34f09b62408759e9d8754ccdd790c6586507a4d2
Log: Fixed bug #67741 (auto_prepend_file messes up __LINE__)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC