|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78868 Calling __autoload() with incorrect EG(fake_scope) value
Submitted: 2019-11-25 10:22 UTC Modified: -
From: Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.3Git-2019-11-25 (Git) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2019-11-25 10:22 UTC]
__autoload() may be called with wrong EG(fake_scope) value

Test script:
class C {
	private $private = 1;

	function foo() {
		$this->private++; //fails with EG(fake_scope) != NULL && EG(fake_scope) != "C"

class A {
	static $foo = B::foo; //not resolved on include()

function main_autoload($class_name) {
	$c = new C;
	//doesn't affect the error
	eval("class B {const foo = 1;}");

spl_autoload_register('main_autoload', false);

$classA = new ReflectionClass("A");
$props = $classA->getProperties();
$props[0]->setValue(2); //causes constant resolving, which runs autoload, all with EG(fake_scope) == "A"

echo "OK\n";

Expected result:

Actual result:
PHP Fatal error:  Uncaught Error: Cannot access private property C::$private in bug.php


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-11-25 11:11 UTC]
Automatic comment on behalf of
Log: Fixed bug #78868 (Calling __autoload() with incorrect EG(fake_scope) value)
 [2019-11-25 11:11 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Sep 29 15:03:44 2022 UTC