Re: Re: alternative to the fopen() hack in autoloaders
| From: | Stanislav Malyshev | Date: | Wed, 09 Dec 2009 00:04:30 +0000 |
| Subject: | Re: Re: alternative to the fopen() hack in autoloaders | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-46359@lists.php.net to get a copy of this message | ||
Hi!
I think stream_resolve_include_path() should be changed to work through zend_resolve_path, in any case. Also, what is the reason it can't be in 5.3 too?
I'd like to both fix stream_resolve_include_path() and get it into 5.3, any objections to that?
If that was done, only problem with using stream_resolve_include_path() is this manner:
$realpath = stream_resolve_include_path($filename);
if ($realpath && is_readable($realpath)) {
include $realpath;} else {
throw new Exception("What do you mean by $filename?");
}
This has disadvantage of using stat twice, but is_readable may be optional.
This however does not solve the problem fully - since include could fail even though is_readable worked. But in that case I think it's OK for autoload to fail too - if there's a file in the path that exists, it's probably what you meant to include, so you probably don't want to try another one instead - you want it to fail.
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com