php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63013 Error not thrown with constructor call
Submitted: 2012-09-05 10:37 UTC Modified: 2012-09-06 12:32 UTC
From: samu dot voutilainen at gmail dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 5.4.6 OS: Linux
Private report: No CVE-ID:
 [2012-09-05 10:37 UTC] samu dot voutilainen at gmail dot com
Description:
------------
When inheriting from a class and calling constructor with invalid arguments, it won’t throw any error, but die silently. There is no information in web server log or PHP-FPM’s logs and nothing is returned to client either.



Test script:
---------------
class SlamObject {

}

class Utility extends SlamObject {

}

abstract class AbstractHandler extends Utility {

    protected $version;

    protected $session;

    protected $output;

    public function __construct($session, $output, $version) {
        $this->session = $session;
        $this->output = $output;
        $this->version = $version;
    }

}

class Foo extends AbstractClass {

}

$foo = new Foo();

Expected result:
----------------
At the point of Foo, fatal error is thrown telling that you called constructor with wrong arguments.

Actual result:
--------------
Silent death at this point with no information anywhere.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-05 10:41 UTC] samu dot voutilainen at gmail dot com
Also the code I have uses namespaces.
 [2012-09-05 13:20 UTC] laruence@php.net
PHP will warn you:

PHP Warning:  Missing argument 1 for AbstractHandler::__construct(), called in 
/tmp/1.php on line 30 and defined in /tmp/1.php on line 18
PHP Warning:  Missing argument 2 for AbstractHandler::__construct(), called in 
/tmp/1.php on line 30 and defined in /tmp/1.php on line 18
PHP Warning:  Missing argument 3 for AbstractHandler::__construct(), called in 
/tmp/1.php on line 30 and defined in /tmp/1.php on line 18
 [2012-09-05 14:24 UTC] samu dot voutilainen at gmail dot com
I don’t get the warnings for the case I had; this simpler example does though. I’ll construct an example with proper namespaces to see if it causes it.
 [2012-09-06 01:40 UTC] aharvey@php.net
I can't reproduce this either. We'll have to wait for the new example.

Can you also provide your display_errors and error_reporting settings, please?
 [2012-09-06 01:40 UTC] aharvey@php.net
-Status: Open +Status: Feedback
 [2012-09-06 12:32 UTC] samu dot voutilainen at gmail dot com
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = On

Looks like I accidentally didn’t have only E_ALL (that should be all errors that exists, no?)

Anyway, now I’m not able to reproduce the problem even with original error_reporting, so I think it comes up randomly. I guess this one can be closed as invalid and if I manage to reproduce it, try to do proper test case. 

I did spot this before (no errors where should’ve been, just immediate death), so I think there is something, but need first manage to reproduce it...
 [2012-09-06 12:32 UTC] samu dot voutilainen at gmail dot com
-Status: Feedback +Status: Closed
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 03:02:42 2014 UTC