|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-07-14 21:07 UTC] herrold at owlriver dot com
I have 150 material lines of analysis of a doco bug in the php command shell option parser, and related doco at:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=68798
Executive Summary -- the PHP.NET web doco is inaccurate, and the option parser of the -c option needs to so a trim() on the option text before applying it.
Failure to do so causes the load of the php.ini options to be skipped in the command line mode. This in turn causes subtle and hard to diagnose errors.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 00:00:02 2025 UTC |
The strace allowed me to see the bug --- This fails: [herrold@server3 herrold]$ head -50 ./birddaemon.php #!/usr/bin/php -c /etc/php.ini <?php // // test shim to show bug // // $db_server = "10.30.0.253"; $db_user = "root"; $db_passwd = "RedRedRobin"; $db_name = "birds"; // print "asdf"; // $link = mysql_connect($db_server, $db_user, $db_passwd) or die("Could not connect"); // $isdb = mysql_select_db($db_name) or die("Could not get database"); // $query = "update sightingstate set active = 'yes' where active = 'NULL"; $result = mysql_query($query); // exit ; // ?> \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ This works: [herrold@server3 herrold]$ head -50 ./birddaemon.php #!/usr/bin/php -c/etc/ <?php // \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ At the end of the Red hat bugzilla initially quoted: Additional comment by herrold@owlriver.com 2002-07-14 15:08:09 WTF: bash-2.05a$ strace ./birddaemon.php 2>&1 | grep ini open(" /etc/php.ini/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory) read(3, "#!/usr/bin/php -c /etc/php.ini"..., 4096) = 492 bash-2.05a$ ------------------------------ php man page says: bash-2.05a$ man php No manual entry for php bash-2.05a$ =============================== http://www.php.net/manual/en/features.commandline.php says: -c <path>|<file> Look for php.ini file in this directory ahhh .... directory ... bash-2.05a$ joe ./birddaemon.php Processing '/etc/joe/joerc'...done Processing '/etc/joe/joerc'...done File ./birddaemon.php not changed so no update needed. bash-2.05a$ ./birddaemon.php X-Powered-By: PHP/4.2.1 Content-type: text/html asdf<br /> <b>Fatal error</b>: Call to undefined function: mysql_connect() in <b>/home/herrold/birddaemon.php</b> on line <b>13</b><br /> bash-2.05a$ strace ./birddaemon.php 2>&1 | grep ini open(" /etc//php.ini", O_RDONLY) = -1 ENOENT (No such file or directory) bash-2.05a$ bash-2.05a$ strace ./birddaemon.php 2>&1 | grep ini open(" /etc/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory) bash-2.05a$ ls -al /etc/php.ini -rw-r--r-- 1 root root 28245 Jul 14 14:48 /etc/php.ini bash-2.05a$ WTF ... it is not finding a file with a space becore the parsed option ... bash-2.05a$ strace ./birddaemon.php 2>&1 | grep ini open("/etc/php.ini", O_RDONLY) = 3 lstat64("/etc/php.ini", {st_mode=S_IFREG|0644, st_size=28245, ...}) = 0 bash-2.05a$ It found the file ... nasty ; d*mn HTML documentation -- two days of my life wasted ... ============================= try against earlier version: [herrold@server3 herrold]$ ./birddaemon.php X-Powered-By: PHP/4.1.2 Content-type: text/html asdf[herrold@server3 herrold]$ ======================================================== So it is REALLY a bad docs bug for MY form of invocation ... =================================== Notwithstanding, can a trim() please be applied to get rid of improper leading spaces in the option parser code for the command mode handler? -- Russ Herrold Additional comment by herrold@owlriver.com 2002-07-14 15:29:39 old subject: php command shell module inclusion through php.ini broken New subject: php command shell -c option parser and doco inaccurate