php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63729 E_DEPRECATED errors is not handled properly
Submitted: 2012-12-08 20:32 UTC Modified: 2012-12-10 10:57 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dinoel at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.4.9 OS: windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dinoel at gmail dot com
New email:
PHP Version: OS:

 

 [2012-12-08 20:32 UTC] dinoel at gmail dot com
Description:
------------
Hi,

E_DEPRECATED is not handled properly if error handler / error reporting is set in same file.

pre-requirements : error_reporting set to E_ALL in php.ini file

I assume this is because E_DEPRECATED error is fired on "compile" time, not execution time.. 

Please notice that this problem happens only with " =& new ..." constructions (and probably some others) , other kind of E_DEPRECATED errors (like one which fired when i'm using deprecated functions, like ereg) are handled as expected. 

This bug is probably related : https://bugs.php.net/bug.php?id=61031 

Test script:
---------------
testfile.php 
<?php
error_reporting(0);
include('testfile1.php');
?>



testfile1.php
<?php
error_reporting(0);
class foo {
}

$a =& new foo();
echo "success";
?>

Expected result:
----------------
php -f testfile.php
success

php -f testfile1.php
success


Actual result:
--------------
php -f testfile.php
"success"

php -f testfile1.php
PHP Deprecated:  Assigning the return value of new by reference is deprecated in
 testfile1.php on line 6

Deprecated: Assigning the return value of new by reference is deprecated in testfile1.php on line 6
success


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-08 20:34 UTC] dinoel at gmail dot com
Happens on 5.3.19 also.
 [2012-12-10 02:22 UTC] aharvey@php.net
I can't reproduce this on 5.3 or 5.4: as expected, if I run testfile.php, the error reporting setting takes effect and hides the deprecation warning in the included file.

What extensions do you have loaded? In particular, opcode caches and debugging extensions like xdebug and scream would be interesting, but a full list would be good.
 [2012-12-10 02:22 UTC] aharvey@php.net
-Status: Open +Status: Feedback -Package: Output Control +Package: Scripting Engine problem
 [2012-12-10 10:19 UTC] dinoel at gmail dot com
-Status: Feedback +Status: Open
 [2012-12-10 10:19 UTC] dinoel at gmail dot com
Hi,

Yes, if you run testfile.php then error error reporting setting takes effect, but if you run testfile1.php then it does not. Please run testfile1.php (as explained in description) and you will see what i mean. 
This is clean install and no opcode caches/debug extensions been loaded.
 [2012-12-10 10:57 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2012-12-10 10:57 UTC] aharvey@php.net
Ah, I see. I didn't get that from your original post, sorry.

You are correct that certain E_DEPRECATED errors, such as assigning the return value of new by reference, occur at compile time, and hence before an error_reporting() call can take effect. This is expected behaviour — to control which compile errors are shown, you need to edit php.ini.

Not a bug → closing.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 18:01:33 2025 UTC