php.net |  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: dmitry@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.3Git-2019-11-25 (Git) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dmitry@php.net
New email:
PHP Version: OS:

 

 [2019-11-25 10:22 UTC] dmitry@php.net
Description:
------------
__autoload() may be called with wrong EG(fake_scope) value

Test script:
---------------
<?php
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;
	$c->foo();
	//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:
----------------
OK

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-11-25 11:11 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bb30fe9e2b86a46a167c88daaae0c650cb01afa2
Log: Fixed bug #78868 (Calling __autoload() with incorrect EG(fake_scope) value)
 [2019-11-25 11:11 UTC] dmitry@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC