From:
Operating system: Windows 7, Linux Slackware
PHP version: 5.3.3
Package: SPL related
Bug Type: Bug
Bug description:spl_autoload_register() can use protected/private methods if
called from class
Description:
------------
If spl_autoload_register() is called from class method, SPL autoloader can
use private and protected methods, although SPL is not a part of this
class. It works well if spl_autoload_register() is called from somewhere
else.
Test script:
---------------
<?php
class CallbackTest {
public function __construct() {
spl_autoload_register(array($this, 'publicCallback'));
spl_autoload_register(array($this,
'protectedCallback'));
spl_autoload_register(array($this, 'privateCallback'));
}
public function publicCallback($className) {
echo __METHOD__, "\n";
}
protected function protectedCallback($className) {
echo __METHOD__, "\n";
}
private function privateCallback($className) {
echo __METHOD__, "\n";
}
}
new CallbackTest();
new AutoloadTest();
Expected result:
----------------
PHP Fatal error: Uncaught exception 'LogicException' with message 'Passed
array does not specify a callable method (cannot access protected method
CallbackTest::protectedCallback())' in /home/binary/test.php:5
Stack trace:
#0 test.php(5): spl_autoload_register(Array)
#1 test.php(18): CallbackTest->__construct()
#2 {main}
thrown in test.php on line 5
Actual result:
--------------
CallbackTest::publicCallback
CallbackTest::protectedCallback
CallbackTest::privateCallback
PHP Fatal error: Class 'AutoloadTest' not found in test.php on line 19
--
Edit bug report at http://bugs.php.net/bug.php?id=52464&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52464&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52464&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52464&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52464&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52464&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52464&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52464&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52464&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52464&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52464&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52464&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52464&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52464&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52464&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52464&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52464&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52464&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52464&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52464&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52464&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52464&r=mysqlcfg