|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-02-19 14:39 UTC] morpika at vipmail dot hu
Description:
------------
__autoload function is not called in user-defined error handler function in case of E_STRICT error. In case of any other type of errors (thet user-defined error handler function can handle) the autoload function is called properly.
Test script:
---------------
test.php:
<?php
set_error_handler('php_error');
function php_error($errno, $errcode) { t_class::t_function($errno, $errcode); }
function __autoload($class_name) { echo 'autoload called'; exit; }
require('nf.php');
?>
nf.php (to create an E_STRICT ERROR: Redefining already defined constructor):
<?php
class number_format {
public function __construct() {}
public function number_format($number) { echo number_format($number, 0, '.', '.'); }
}
?>
Expected result:
----------------
autoload called
Actual result:
--------------
Fatal error: Class 't_class' not found
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 20:00:01 2025 UTC |
The use of opcoding caching can cause this issue to not be reproducable. Test steps: ------------ 1. Enable opcode caching (APC), restart your httpd to ensure the opcode cache is clean. 2. Request testa.php to trigger the E_STRICT. Result: --- *error_handler(): "Declaration of Bar::baz() should be compatible with that of Foo::baz()" Fatal error: Class 'Error' not found in /<path>/trigger_e_strict.php on line 3 3. Uncomment line #25: "include('doesntexist');" and re-request testa.php to trigger the E_WARNING. Result: --- *error_handler(): "include(doesntexist): failed to open stream: No such file or directory" *__autoload(): "Error" *Error::output() *error_handler(): "include(): Failed opening 'doesntexist' for inclusion (include_path='.:/<path>:/usr/share/php')" *Error::output() *error_handler(): "Declaration of Bar::baz() should be compatible with that of Foo::baz()" *Error::output() 4. Recomment line #25: "include('doesntexist');" and re-request testa.php to trigger the E_STRICT. Result: --- *error_handler(): "Declaration of Bar::baz() should be compatible with that of Foo::baz()" *_autoload(): "Error" *Error::output() Expected result: ---- Steps 2. and 4. should output the same result as the code is identical. Actual result: ---- Steps 2. and 4. output different results. Step 2. behaves according to the "Actual result" of bug #54054. Step 4. behaves according to the Expected result" of bug #54054. Notes: ---- This behaviour should be noted when reproducing bug #54054 as it will cause the issue to not be reproducable. Environment: ---- PHP 5.3.2 Apache/2.2.14 Ubuntu 10.04.3 LTS Code: ---- testa.php --------- <?php error_reporting(-1); // Set error handler set_error_handler('error_handler'); // Error handler function error_handler($severity, $message) { echo "*error_handler(): \"$message\"\n"; return Error::output(); } // Autoloader function __autoload($class) { echo "*__autoload(): \"$class\"\n"; // Load class 'Error' eval("class $class { public static function output() { echo '*' . __CLASS__ . '::output()\n'; } }"); } // Trigger E_WARNING - Uncomment to alter opcode cache //include('doesntexist'); // Trigger E_STRICT include('testb.php'); ?> testb.php ----- <?php // Trigger E_STRICT class Foo { public function baz($var){} } class Bar extends Foo { public function baz() {} } ?>