Ticket #172 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

ignoring __construct

Reported by: hemna Assigned to: somebody
Priority: major Milestone: 0.9.5
Component: eAccelerator Version: 0.9.5
Keywords: constructor Cc:

Description (Last modified by bart)

eaccelerator incorrectly calls a method that shouldn't get called in php5. php5 w/o eaccelerator doesn't behave this way. my php5 class has a construct() method and happens to have a method with the same name of the class, but in lower case, but eaccelerator calls the class name method and not the construct() method during instantiation.

Hit the blow script twice to see the issue. The first time the script is hit, it works fine, but the second time eacclerator fails.

<?php

class Debug {
    protected $test = '';


    function __construct() {  
       echo "constructor!";
    }

    public static function singleton() {
        static $obj=NULL;
        if (is_null($obj)) {
            $obj = new Debug;
        }

        return $obj;
    }

    function debug($str) {
        //doo something with $str;
        echo "Debug::".$str;
    }

    function alert($str) {
        echo "Alert::".$str;
    }
}



$obj = Debug::singleton();
$obj->alert('foo');
$obj->debug('bar');

?>

this results in

Warning: Missing argument 1 for Debug::debug(), called in /home/wboring/devel/trunk/htdocs/admin/test.php on line 13 and defined in /home/wboring/devel/trunk/htdocs/admin/test.php on line 19 Call Stack # Function Location 1 {main}() /home/wboring/devel/trunk/htdocs/admin/test.php:0 2 Debug::singleton() /home/wboring/devel/trunk/htdocs/admin/test.php:31 3 Debug->debug() /home/wboring/devel/trunk/htdocs/admin/test.php:13

Notice: Undefined variable: str in /home/wboring/devel/trunk/htdocs/admin/test.php on line 21 Call Stack # Function Location 1 {main}() /home/wboring/devel/trunk/htdocs/admin/test.php:0 2 Debug::singleton() /home/wboring/devel/trunk/htdocs/admin/test.php:31 3 Debug->debug() /home/wboring/devel/trunk/htdocs/admin/test.php:13 Debug::Alert::fooDebug::bar

Change History

09/15/06 16:39:32 changed by bart

  • component changed from Control panel to eAccelerator.

09/15/06 16:41:02 changed by bart

  • description changed.

09/15/06 17:01:34 changed by bart

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone set to 0.9.5.

Thanks for your report. This has been fixed in revision [271]