PHP 4.0 Bug #5076 Updated: command line php interpreter and command line arguments

From: Date: Tue, 05 Sep 2000 02:09:27 +0000
Subject: PHP 4.0 Bug #5076 Updated: command line php interpreter and command line arguments
Groups: php.dev 
Request: Send a blank email to php-dev+get-32047@lists.php.net to get a copy of this message
ID: 5076 Updated by: sniper Reported By: flebarbe@ocare.com Status: Analyzed Bug Type: Other Assigned To: Comments: Just tested this with latest CVS and seems like the -d include_path=.:/path/to/foo is totally ignored and only setting include_path in php.ini works. --Jani Previous Comments: [2000-06-16 11:23:43] flebarbe@ocare.com php built as cgi : ./configure --prefix=/usr --with-config-file-path=/etc/php --enable-force-cgi-redirect --without-pcre-regex --enable-debug=no --enable-safe-mode $grep include_path /etc/php/php.ini include_path = . $ls include/me.inc include/me.inc $php -q -d include_path=.:include <?php include ('me.inc'); ?> ^D <b>Warning</b>: Failed opening 'me.inc' for inclusion (include_path='.') in <b>-</b> on line <b>2</b><br> I had a look at the code in sapi/cgi/cgi_main.c, php_ini.c as well as configuration-parser.y. configuration-parser.y and cgi_main.c. They all call php_ini.c/php_alter_ini_entry. It's called a first time from configuration-parser with '.' coming from /etc/php/php.ini and then called from the command-line "analyser" (/sapi/cgi/cgi_main.c) Because the value is already set, the first test in alter_ini_entry fails and returns (php_ini.c:143) : if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==FAILURE) { return FAILURE; } I use the cgi version in command line for some cron scripts related to a whole web-based application, that's the reason why I need this. The workaround I've found ? Have php.ini in the directory the scripts are in with the variables correctly set in it. :-((( BTW, have a look at this (shell related) one : $cat ./script.php #!/usr/bin/php -q -d include_path=foo <?php echo "Hello World"; ?> --- Depending on wich shell you run it from, php receives "php" "-q -d include_path=foo" "./script.php" (linux) "php" "-q" "./script.php" (solaris) as argv, leading to problems... Solution ? Ahem... Nasty one : #!/bin/bash /usr/bin/php -q -d include_path=foo <<EOF <?php echo "Hello World"; ?> EOF Flavien Lebarbe. --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=5076

« previous php.dev (#32047) next »