Re: bug 48541 - critical for PHP 5.3
| From: | Greg Beaver | Date: | Sat, 13 Jun 2009 16:50:00 +0000 |
| Subject: | Re: bug 48541 - critical for PHP 5.3 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44262@lists.php.net to get a copy of this message | ||
Christian Seiler wrote:
> Hi Greg,
>
>> I can do it if someone can answer this question: how do closures
>> uniquely identify themselves? spl_autoload_register is mistakenly
>> treating all closures as if they were a single copy of the static method
>> "Closure::__invoke", and so only the first registered closure is ever
>> called (plus it leaks the other closures at shutdown). If the system
>> can be made to better identify the closure, then spl_autoload_register
>> can use that (and also properly free the refcount on a dupe).
>
> A closure can only be uniquely identified by the object storage id the
> object has. You cannot assume any identity with regard to, for example,
> file name and line where it was defined, since one could imagine the
> following:
>
> foreach ($dirs as $dir) {
> spl_autoload_register (function ($class) use ($dir) {
> include $dir.'/'.$class.'.php';
> });
> }
>
> (or something like it)
>
> If nobody else does it I'll fix this later today.
Hi,
Thanks Christian, I've got a patch and a test I'm about to commit, would
be great if you can review it.
Thanks,
Greg