From: dean at omnivisiontechnology dot com
Operating system: Linux
PHP version: 7.0.16
Package: PHP options/info functions
Bug Type: Bug
Bug description:php command-line -c ini settings overridden by default .ini
Description:
------------
The expectation when using PHP from the command line with the -c
<my_ini_file> switch is that the settings in <my_ini_file> should take
priority over those in the default ini file (as defined by compile-time
configuration options --with-config-file-path and --sysconfdir).
Somewhere from moving from v5.x to v7.1.1, this appears to have broken,
with the default ini settings overriding the command-line ones.
Test script:
---------------
My server's default php.ini is located at
/opt/cpanel/ea-php71/root/etc/php.ini
It contains (amongst other things) the lines:
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
error_log = "/home/myusername/public_html/admin/PHP_ERROR_LOG.TXT"
Whereas, I have another .ini located at
/home/myusername/DB_BACKUP_SCRIPT/cron_php.ini
That one contains(amongst other things) the lines:
error_reporting = E_ALL
error_log = "/home/myusername/DB_BACKUP_SCRIPT/DB_BACKUP_ERROR_LOG.TXT"
When I execute: php -c /home/myusername/DB_BACKUP_SCRIPT/cron_php.ini
-i
The output includes the following:
-------------------------------
System => Linux myserver.com 3.10.0-327.28.2.el7.x86_64 #1 SMP Wed Aug 3
11:11:39 UTC 2016 x86_64
Build Date => Jan 25 2017 04:20:53
Configure Command => './configure' '--build=x86_64-redhat-linux-gnu'
'--host=x86_64-redhat-linux-gnu' '--program-prefix='
'--disable-dependency-tracking' '--prefix=/opt/cpanel/ea-php71/root/usr'
'--exec-prefix=/opt/cpanel/ea-php71/root/usr'
'--bindir=/opt/cpanel/ea-php71/root/usr/bin'
'--sbindir=/opt/cpanel/ea-php71/root/usr/sbin'
'--sysconfdir=/opt/cpanel/ea-php71/root/etc'
'--datadir=/opt/cpanel/ea-php71/root/usr/share'
'--includedir=/opt/cpanel/ea-php71/root/usr/include'
'--libdir=/opt/cpanel/ea-php71/root/usr/lib64'
'--libexecdir=/opt/cpanel/ea-php71/root/usr/libexec'
'--localstatedir=/opt/cpanel/ea-php71/root/usr/var'
'--sharedstatedir=/opt/cpanel/ea-php71/root/usr/com'
'--mandir=/opt/cpanel/ea-php71/root/usr/share/man'
'--infodir=/opt/cpanel/ea-php71/root/usr/share/info'
'--cache-file=../config.cache' '--with-libdir=lib64'
'--with-config-file-path=/opt/cpanel/ea-php71/root/etc'
'--with-config-file-scan-dir=/opt/cpanel/ea-php71/root/etc/php.d'
'--disable-debug' '--with-pic' '--without-pear' '--with-bz2'
'--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr'
'--enable-gd-native-ttf' '--without-gdbm' '--with-gettext'
'--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl'
'--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU'
'--enable-exif' '--enable-ftp' '--enable-sockets'
'--with-kerberos'
'--enable-shmop' '--with-libxml-dir=/usr' '--with-system-tzdata'
'--with-mhash' '--enable-dtrace'
'--libdir=/opt/cpanel/ea-php71/root/usr/lib64/php' '--enable-pcntl'
'--enable-opcache' '--disable-opcache-file' '--enable-phpdbg'
'--with-imap=shared,/opt/cpanel/ea-php71/root/usr' '--with-imap-ssl'
'--enable-mbstring=shared' '--enable-mbregex' '--with-webp-dir=/usr'
'--with-gd=shared' '--with-gmp=shared' '--enable-calendar=shared'
'--enable-bcmath=shared' '--with-bz2=shared' '--enable-ctype=shared'
'--enable-dba=shared' '--with-db4=/usr' '--with-tcadb=/usr'
'--enable-exif=shared' '--enable-ftp=shared' '--with-gettext=shared'
'--with-iconv=shared' '--enable-sockets=shared'
'--enable-tokenizer=shared' '--with-xmlrpc=shared'
'--with-ldap=shared'
'--with-ldap-sasl' '--enable-mysqlnd=shared'
'--with-mysqli=shared,mysqlnd'
'--with-mysql-sock=/var/lib/mysql/mysql.sock' '--enable-dom=shared'
'--with-pgsql=shared' '--enable-simplexml=shared'
'--enable-xml=shared'
'--enable-wddx=shared' '--with-snmp=shared,/usr'
'--enable-soap=shared'
'--with-xsl=shared,/usr' '--enable-xmlreader=shared'
'--enable-xmlwriter=shared' '--with-curl=shared,/usr'
'--enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC,/usr'
'--with-pdo-mysql=shared,mysqlnd' '--with-pdo-pgsql=shared,/usr'
'--with-pdo-sqlite=shared,/usr' '--with-sqlite3=shared,/usr'
'--enable-json=shared' '--enable-zip=shared' '--without-readline'
'--with-libedit' '--with-pspell=shared' '--enable-phar=shared'
'--with-mcrypt=shared,/opt/cpanel/libmcrypt' '--enable-sysvmsg=shared'
'--enable-sysvshm=shared' '--enable-sysvsem=shared'
'--enable-shmop=shared' '--enable-posix=shared'
'--with-unixODBC=shared,/usr' '--enable-intl=shared'
'--with-icu-dir=/usr' '--with-enchant=shared,/usr'
'--with-recode=shared,/usr' '--enable-fileinfo=shared'
'build_alias=x86_64-redhat-linux-gnu'
'host_alias=x86_64-redhat-linux-gnu' 'CFLAGS=-O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic
-fno-strict-aliasing -Wno-pointer-sign' 'CXXFLAGS=-O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /opt/cpanel/ea-php71/root/etc
Loaded Configuration File =>
/home/myusername/DB_BACKUP_SCRIPT/cron_php.ini
.
.
.
PHP Version => 7.1.1
Directive => Local Value => Master Value
error_log => /home/myusername/public_html/admin/PHP_ERROR_LOG.TXT =>
/home/myusername/public_html/admin/PHP_ERROR_LOG.TXT
error_reporting => 22519 => 22519
---------------------------------
Expected result:
----------------
As can be seen, the error_log and error_reporting values are those from
the default configuration .ini file, and NOT the .ini file passed to the
-c command line switch, as they should be.
Before switching to PHP v7.x, this was working correctly.
Note that including the -n command line switch as well fixes this
specific problem, but (predictably) causes lots of others (i.e. no DB,
graphics, curl, etc. library functions work any more, since they don't
get initialized properly). This shows though, that both .ini files are
being processed, just that settings from the wrong one are taking
precedence!
--
Edit bug report at https://bugs.php.net/bug.php?id=74123&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74123&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74123&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74123&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74123&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74123&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74123&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74123&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74123&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74123&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74123&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74123&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74123&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74123&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74123&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74123&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74123&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74123&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74123&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74123&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74123&r=mysqlcfg