From:             
Operating system: ALL
PHP version:      5.3.10
Package:          *General Issues
Bug Type:         Bug
Bug description:call_user_func sends scrambled class name to autoload

Description:
------------
I have discovered weird behaviour of call_user_func that breaks class
autoloader by providing scrambled class name for example instead of
"myObject" it provides "zw87zl18".
This event only occurs if you are using custom class autoloader and
requesting static method that is not declared as static.

Test script:
---------------
//FILE: myObject.php
class myObject {
    public static function method1(){var_dump(__METHOD__);}
    public function method2(){var_dump(__METHOD__);}
}

//FILE: index.php
ini_set('display_errors', TRUE);

function __autoload($className) {
   include sprintf('%s/%s.php', getcwd(), $className);
}

call_user_func(array('myObject', 'method1'));//works fine

call_user_func(array('myObject', 'method2'));//produce an error

Expected result:
----------------
string(17) "myObject::method1"
string(17) "myObject::method2"

Actual result:
--------------
string(17) "myObject::method1"
Warning: include(/www/zw87zl18.php) [function.include]: failed to open
stream: No such file or directory in /www/index.php on line 9

Warning: include() [function.include]: Failed opening '/www/zw87zl18.php'
for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in
/www/index.php on line 9

Warning: include(/www/zw87zl18.php) [function.include]: failed to open
stream: No such file or directory in /www/index.php on line 9

Warning: include() [function.include]: Failed opening '/www/zw87zl18.php'
for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in
/www/index.php on line 9
string(17) "myObject::method2" 

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

Reply via email to