php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #33430 auto_prepend_file not respected in command line environment
Submitted: 2005-06-22 09:38 UTC Modified: 2005-09-05 09:57 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: gk at proliberty dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.0.3 OS: RH 9 Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gk at proliberty dot com
New email:
PHP Version: OS:

 

 [2005-06-22 09:38 UTC] gk at proliberty dot com
Description:
------------
auto_prepend_file, auto_append_file values are not effective in command line (CLI-SAPI) code: php -r <code>

The value of auto_prepend_file is correctly reported as having been read from the php.ini file (or equivalent -d command line assignment), but the file is not 'prepended' prior to execution of command line code.

If this is by design, then this behavior is inconsistent with how other php.ini values are respected in the command line code environment and should be documented since it is not intuitive.

Please do not bogusify this report.
If not a design bug, then this is a documentation bug and a feature request.

Reproduce code:
---------------
cat /auto_prepend_file.php
<?php echo __FILE__."\n"; ?>

php -d auto_prepend_file=/auto_prepend_file.php -r 'echo "code";';

Expected result:
----------------
auto_prepend_file.php
code

Actual result:
--------------
code

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-04 18:35 UTC] csaba at alum dot mit dot edu
I'd like to add that this bug exists on my 2005 Aug 31 PHP 5.1 / Win XP Pro.

It seems that it is a bug and not a documentation problem, because each of php.exe, php-win.exe, and php-cgi.exe include the auto_prepend_file if invoked in interactive mode.  Please change the Category appropriately.

Here's how I tested (must be on a windows system):
Make one file, pop.php:
<?php
  function popup($text, $title="PHP popup") {
    $oWSH = new COM("WScript.Shell");
    if (is_null($text)) $text = "NULL";
    $oWSH->Popup($text, 4, $title, 131120);
  }
  popup ("inside pop.php");
?>

now it may be tested as follows from the command line (type in one single long line at the prompt from the directory of php.php):
echo "<?php popup('prepend OK');var_dump(get_included_files());exit(); ?>" | php.exe -d auto_prepend_file=pop.php -a

Of course you can replace php.exe with php-win.exe or php-cgi.exe  In all three cases you get the expected behaviour of two popups showing.

It would be very useful to have this bug fixed for my situation where I want to have an automatic include file for the CLI versions of PHP, but I want to disable that include file when I fall into PHP via Apache.  Which disabling I would do my means of the apache directive:
PHP_value auto_prepend_file none

Csaba Gabor from Vienna

PS.  I have verified that the -r version does not work by typing, from the command line:
php.exe -r pop.php
php-win.exe -r pop.php
(php-cgi.exe doesn't take a -r argument)
 [2005-09-04 19:13 UTC] csaba at alum dot mit dot edu
Oops, that's not how I verified (I was mixing tests there).  I verified using:
php.exe -d auto_prepend_file=pop.php -r popup('Hi');
php-win.exe -d auto_prepend_file=pop.php -r popup('Hi');
and these both failed since they didn't find popup defined.

Please see http://bugs.php.net/34367 for a distinct but related bug.

Csaba
 [2005-09-05 09:57 UTC] sniper@php.net
No need to have two reports about exactly same issue.

 [2012-05-17 00:09 UTC] php at keithtyler dot com
Uh, this is a different bug than the one at 34367. Pretty clearly.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 16:01:27 2024 UTC