Edit report at https://bugs.php.net/bug.php?id=61442&edit=1
ID: 61442
Updated by: laruence@php.net
Reported by: yks-uno at yandex dot ru
Summary: SPL autoload issues Fatal Error if a handler throws
exception
Status: Not a bug
Type: Bug
Package: SPL related
Operating System: Linux, FreeBSD
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
and the 5.3.0+ seems should be 5.3+ (I mean 5.4 works fine).
Previous Comments:
------------------------------------------------------------------------
[2012-09-19 10:03:24] laruence@php.net
http://us.php.net/autoload
"Note:
Prior to 5.3.0, exceptions thrown in the __autoload function could not be caught
in the catch block and would result in a fatal error. From 5.3.0+ exceptions
thrown in the __autoload function can be caught in the catch block, with 1
provision. If throwing a custom exception, then the custom exception class must
be available. The __autoload function may be used recursively to autoload the
custom exception class."
------------------------------------------------------------------------
[2012-09-19 08:54:26] yks-uno at yandex dot ru
And please would you mind to show the exact place in the PHP documentation where it is stated that
an autoload handler ALWAYS DIES regardless of exceptions or substituting another class if it does
not find the class it is trying to load?
Or there is "no information available, might only be in SVN" ???
------------------------------------------------------------------------
[2012-09-19 08:43:30] yks-uno at yandex dot ru
Sorry but you're wrong. Do you understand what the function spl_autoload_register() does? And
what the function x() does? The function x() is a handler for loading classes - That is what
autoload handler SHOULD DO, it should LOAD classes which are NOT LOADED yet. And at the moment of
loading, you can not tell whether a class EXISTS or not. The test script is calling a method of a
class which is NOT LOADED yet.
It SHOULD report an error if the class being loaded is not found. But it SHOULD NOT DIE on
throwing an exception!!! This IS A BUG because an exception is not thrown where it is explicitly
written.
You cleverly advise me to use class_exists on a NOT LOADED class, so it just AGAIN forwards an
autoload call to the handler (function "x") which eventually DIES.
If you are so clever then just remove the autoload handler from PHP and force use require_once.
Sorry for my being angry, but, damn, it was a HALF-YEAR since bug submitted to invent such a stupid
reason that it is not a bug!!!
------------------------------------------------------------------------
[2012-09-19 07:44:46] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
if you just want to check whether a class exists, use class_exists.
you test script is trying to call a method of a non-exists class, fatal error is
reasonable .
------------------------------------------------------------------------
[2012-09-19 07:15:33] yoorick at samovarchik dot info
If you try to use a class constant (e.g. Foo::BAR) of an unexisting class, autoloader will also fail
to throw an exception and the script will die with the "class not found" fatal error.
(PHP 5.3.16)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=61442--
Edit this bug report at https://bugs.php.net/bug.php?id=61442&edit=1