Search code examples
phpphp-5.6fpm

PHP-FPM unable to override error_reporting?


I have a problem that's driving me crazy in the last couple of hours: I can't override the default value of error_reporting directive on my development machine (Debian 8 + php-fpm 5.6.29 + Nginx/1.6.2)

The php packages i'm using:

$ dpkg --get-selections | grep php
libapache2-mod-php5             install
php-console-table               install
php5                        install
php5-cli                    install
php5-common                 install
php5-curl                   install
php5-fpm                    install
php5-gd                     install
php5-intl                   install
php5-json                   install
php5-mcrypt                 install
php5-mysql                  install
php5-readline                   install
php5-xmlrpc                 install
php5-xsl                    install

Considering the following dead-simple script:

<?php
$initial_value = error_reporting(); // Just read the current value

error_reporting(E_PARSE); // Lets set it to something else.

$update_value = error_reporting(); // Read again.

printf(
  "Initial value: %s\nFinal value: %s",
  $initial_value,
  $update_value
);

if I run it from cli, it works:

$ php test.php
// output: Initial value: 22527 Final value: 4

But if I run this under php5-fpm, the output is:

Initial value: 32767 Final value: 32767

What I've tried:

  • Set the value inside php.ini (and checked all php.ini's files listed into phpinfo();, just in case) but nothing.
  • Im not using .user.ini fiels (checked twice)
  • Tried both with error_reporting(E_PARSE) and ini_set('error_reporting', E_PARSE);. Those directive should override the ini files, right?

Of course after every edits to ini files I did restart php5-fpm process (tried also stop and then start instead of restart/reload)

A strange thing is that I can actually override other parameters (display_errors for example, works both from ini files and from ini_set calls).

So, what am I missing so far?


Solution

  • This smells like php_admin_value. Check your fpm/php.ini or fpm/pool.d/* or fpm/conf.d/* for:

    php_admin_value[error_reporting] = E_ALL
    

    It's un-overwritable and produces the same output as you described. Can also be set from nginx configs, check for:

    fastcgi_param PHP_ADMIN_VALUE ...