php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74032 The code should throw a DEPRECATED message and it doesn't
Submitted: 2017-02-02 12:23 UTC Modified: 2017-02-02 17:59 UTC
From: roma dot chikunov at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.0.15 OS: Xubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: roma dot chikunov at gmail dot com
New email:
PHP Version: OS:

 

 [2017-02-02 12:23 UTC] roma dot chikunov at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/migration70.deprecated
---

In the manual page it is written that PHP 4 constructor is deprecated, therefore an error should be logged of PHP DEPRECATED, unfortunately it doesn't happen. 

The sample code is taken as is (except for the error_reporting method) from the documentation. 

Test script:
---------------
<?php

error_reporting(-1);

class foo {
    function foo() {
        echo 'I am the constructor';
    }
}

$obj = new foo();


?>

Expected result:
----------------
The expected result is for an error to be logged for using a deprecated constructor.

Actual result:
--------------
Works like a charm without any error \ warning

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-02 12:34 UTC] requinix@php.net
-Status: Open +Status: Feedback -Type: Documentation Problem +Type: Bug -Package: Documentation problem +Package: Scripting Engine problem
 [2017-02-02 12:34 UTC] requinix@php.net
Works for me. https://3v4l.org/p0K0l

Do you have display_errors on? Maybe you're logging errors to a file?
 [2017-02-02 12:46 UTC] roma dot chikunov at gmail dot com
-Status: Feedback +Status: Open
 [2017-02-02 12:46 UTC] roma dot chikunov at gmail dot com
Thanks for the prompt response!

I am logging to to the default apache error.log file.

As far as I know, error_reporting(-1) should log everything.

Just out of curiosity I have checked other deprecated stuff and it worked for me (specifically options in password_hash()), hence I don't think there's an issue with the logging.

Anyhow, I have also added ini_set('display_errors', '1'); to the code and there's no difference.
 [2017-02-02 12:58 UTC] nikic@php.net
This deprecation is generated at compile-time, while error_reporting() and ini_set() are called at run-time. Try wrapping the class declaration in an eval() to see if that's the issue.
 [2017-02-02 13:07 UTC] roma dot chikunov at gmail dot com
eval() worked!

Question is - why it doesn't work without eval? Obviously, no developer will insert their classes into eval to check for a deprecated error.
 [2017-02-02 17:59 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2017-02-02 17:59 UTC] cmb@php.net
> Question is - why it doesn't work without eval?

As nikic has explained, error_reporting() and ini_set() can't
catch compile time errors. Set the appropriate directives in
php.ini during development.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 07:01:32 2024 UTC