php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74515 ini setting for error_reporting not initialized by default
Submitted: 2017-04-30 09:51 UTC Modified: 2017-05-02 19:29 UTC
Votes:2
Avg. Score:2.5 ± 1.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: raat1979 at gmail dot com Assigned:
Status: Verified Package: *Configuration Issues
PHP Version: 7.1.4 OS: Ubuntu Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-04-30 09:51 UTC] raat1979 at gmail dot com
Description:
------------
If no error_reporting is defined ( not in php.ini, not in .htaccess, not in source)
then ini_get('error_reporting') returns an empty string.
however, error_reporting() does return a value ("22519" on 7.1.4)

in addition phpinfo()  shows 

master value: "no value"  
local Value: "22519"

after setting error_reporting to the current error_reporting() value 
the ini value is suddenly set 




Test script:
---------------
<?php
echo "<pre>";

var_dump(ini_get('error_reporting'));
var_dump(error_reporting());

error_reporting(error_reporting());

var_dump(ini_get('error_reporting'));
var_dump(error_reporting());


Expected result:
----------------
/var/www/127.0.0.1/index.php:4:string '22519' (length=5)
/var/www/127.0.0.1/index.php:5:int 22519

/var/www/127.0.0.1/index.php:8:string '22519' (length=5)
/var/www/127.0.0.1/index.php:9:int 22519


Actual result:
--------------
/var/www/127.0.0.1/index.php:4:string '' (length=0)
/var/www/127.0.0.1/index.php:5:int 22519

/var/www/127.0.0.1/index.php:8:string '22519' (length=5)
/var/www/127.0.0.1/index.php:9:int 22519


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-30 10:13 UTC] kelunik@php.net
-Status: Open +Status: Verified
 [2017-05-01 19:18 UTC] raat1979 at gmail dot com
It get's even more weird if we check ini_get_all() 
<?php
print_r(ini_get_all()['error_reporting']);
error_reporting(error_reporting());
print_r(ini_get_all()['error_reporting']);
?>
outputs:
Array
(
    [global_value] => 
    [local_value] => 
    [access] => 7
)
Array
(
    [global_value] => 22519
    [local_value] => 22519
    [access] => 7
)
 [2017-05-02 19:29 UTC] raat1979 at gmail dot com
I have zero experience with the PHP source but perhaps one should check https://github.com/php/php-src/blob/master/Zend/zend.c

at +/- line 148

ZEND_INI_BEGIN()

- ZEND_INI_ENTRY("error_reporting",NULL,ZEND_INI_ALL,OnUpdateErrorReporting)

+ ZEND_INI_ENTRY("error_reporting",E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED,ZEND_INI_ALL,OnUpdateErrorReporting)

Perhaps this would fix it ?

Best would be to define a constant like E_DEFAULT so it can be referenced where needed (see also static ZEND_INI_MH(OnUpdateErrorReporting) around line 88 for constant usage)
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Aug 20 06:01:28 2019 UTC