From:             
Operating system: Windows 7x64
PHP version:      5.3.9
Package:          SPL related
Bug Type:         Bug
Bug description:spl_autoload_register fails with __call magic

Description:
------------
When registering a callback object/method pair to spl_autoload_register(),
if 
the 
method is not defined, though the object class has defined __call() magic,
the 
method will not be called during an autoload attempt.

In a larger project, I found that the PHP executable was crashing out 
altogether, 
appending no output to the logs, and offering minimal information. When I 
isolated 
what I suspected to be the problem, it was in fact the 
spl_autoload_register()/__call() combination. In isolation, it did not
crash out 
spectacularly as in my project, however it still failed.

While I marked this 5.3.9, these failures have been observed on 5.3.8,
5.3.9, 
and 
5.4.0.RC3.

While this is a bit of an edge case, I doubt that this is expected or
acceptable 
behaviour, and have not been able to find mention of this elsewhere.

Test script:
---------------
<?php

    class Loader
    {
        public function __call($name, $arguments)
        {
            var_dump(get_defined_vars());
        }
    }
        
    spl_autoload_register(array(new Loader(), 'load_class'));
    $foo = new Bar();

Expected result:
----------------
    array(2) {
      ["name"]=>
      string(10) "load_class"
      ["arguments"]=>
      array(1) {
        [0]=>
        string(3) "Bar"
      }
    }
    Fatal error: Class 'Bar' not found in - on line 12

Actual result:
--------------
    Fatal error: Class 'Bar' not found in - on line 12


As you can see, while this test script made no attempt to actually load the
class, 
it should at least be dumping the array before failing, as in the expected
output.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=60816&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=60816&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=60816&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=60816&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=60816&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=60816&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=60816&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=60816&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=60816&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=60816&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=60816&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=60816&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=60816&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=60816&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=60816&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=60816&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60816&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=60816&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=60816&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=60816&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=60816&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=60816&r=mysqlcfg

Reply via email to