php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45214 __autoload tries to load callback'ed self and parent (close to #37138; no dupe)
Submitted: 2008-06-09 13:34 UTC Modified: 2008-07-11 16:01 UTC
Votes:11
Avg. Score:4.4 ± 0.9
Reproduced:9 of 9 (100.0%)
Same Version:4 (44.4%)
Same OS:5 (55.6%)
From: webmaster at eiscp dot de Assigned:
Status: Wont fix Package: Class/Object related
PHP Version: 5.2.6 OS: Windows XP Professional SP 3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-06-09 13:34 UTC] webmaster at eiscp dot de
Description:
------------
Like #37138 __autoload tries to load callback'ed self and parent PHP tries to __autoload if callcack is used with self or parent in method name. Please note that this is not a dupe!

Reproduce code:
---------------
function __autoload($class) {
	echo __METHOD__, '(', $class, ')', PHP_EOL;
}

class A {
	function X() {
		echo __METHOD__, PHP_EOL;
	}

	function Y() {
		echo __METHOD__, PHP_EOL;
		call_user_func(array($this, 'self::X'));
	}
}

class B extends A {
	function X() {
		echo __METHOD__, PHP_EOL;
		call_user_func(array($this, 'parent::X'));
	}

	function Y() {
		echo __METHOD__, PHP_EOL;
		call_user_func(array($this, 'parent::Y'));
	}
}

// Test
$a = new A();
echo '--- Case 1 ---', PHP_EOL;
$a->X();
echo '--- Case 2 ---', PHP_EOL;
$a->Y();
$b = new B();
echo '--- Case 3 ---', PHP_EOL;
$b->X();
echo '--- Case 4 ---', PHP_EOL;
$b->Y();

Expected result:
----------------
--- Case 1 ---
A::X
--- Case 2 ---
A::Y
A::X
--- Case 3 ---
B::X
A::X
--- Case 4 ---
B::Y
A::Y
A::X


Actual result:
--------------
--- Case 1 ---
A::X
--- Case 2 ---
A::Y
__autoload(self)
A::X
--- Case 3 ---
B::X
__autoload(parent)
A::X
--- Case 4 ---
B::Y
__autoload(parent)
A::Y
__autoload(self)
A::X


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-11 16:01 UTC] jani@php.net
Fixed in HEAD/5.3, wont fix elsewhere.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jan 21 22:01:23 2021 UTC