Bug #65317 [Opn->Dup]: spl autoload won't work inside an autoload
Edit report at https://bugs.php.net/bug.php?id=65317&edit=1
ID: 65317
Updated by: tyrael@php.net
Reported by: tyrael@php.net
Summary: spl autoload won't work inside an autoload
-Status: Open
+Status: Duplicate
Type: Bug
Package: Scripting Engine problem
Operating System: linux
PHP Version: 5.4.17
Block user comment: N
Private report: N
New Comment:
I've created a new report with the updated info and testcase to avoid confusion,
see https://bugs.php.net/bug.php?id=65322
Previous Comments:
------------------------------------------------------------------------
[2013-07-23 17:29:32] tyrael@php.net
Btw. isn't the fact that the error handler is called proves that the compiler is eiher
reentrants or
that the compilation is done?
------------------------------------------------------------------------
[2013-07-23 17:13:58] tyrael@php.net
hm, that explains why nobody really reported it.
as far as I can remember most compile time errors are fatal which won't trigger
the error handler anyways, and the others are E_STRICT, which wasn't really used
before we included it to E_ALL in 5.4.
maybe we should reconsider adding new compile time non-fatal errors until we can
properly support it?
------------------------------------------------------------------------
[2013-07-23 17:09:26] laruence@php.net
my previous comment is not right.
it real reason is here, in (zend_lookup_class_ex):
/* The compiler is not-reentrant. Make sure we __autoload() only during run-
time
* (doesn't impact fuctionality of __autoload()
*/
if (!use_autoload || zend_is_compiling(TSRMLS_C)) {
if (!key) {
free_alloca(lc_free, use_heap);
}
return FAILURE;
}
so, the error is trigged in compiling MyAbstract...
so is in compile time...
so,,
------------------------------------------------------------------------
[2013-07-23 17:05:35] tyrael@php.net
it was introduced by Dmitry:
http://git.php.net/?p=php-
src.git;a=commitdiff;h=9305339d94c701e8eda93dbf0231d70918ef4a6a
"Changed "instanceof" and "catch" operators, is_a() and is_subclass_of()
functions to not call __autoload()."
so nothing about generic recursion protection or explicitly talking about calls
from another autloader method.
I would guess this specific scenario wasn't really intentional, but let's ask
Dmitry about his thoughts.
Personally I think that it is rather surprising and unintuitive and it was a
little bit tricky to figure it out why the code didn't worked as I've expected.
------------------------------------------------------------------------
[2013-07-23 16:51:46] laruence@php.net
Hey, it should be a intention behavior:
zend_class_entry *zend_fetch_class_by_name(const char *class_name, uint
class_name_len, const zend_literal *key, int fetch_type TSRMLS_DC) /* {{{ */
{
zend_class_entry **pce;
int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0;
it seems try to prevent some recursive autoload, then stack overflow
so.... won't fix IMO (it's really a edge case :))
maybe document it instead?
thanks
------------------------------------------------------------------------
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=65317
--
Edit this bug report at https://bugs.php.net/bug.php?id=65317&edit=1
Thread (7 messages)