pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/iliaal/php-src/pull/9/files

dia="all" rel="stylesheet" href="https://github.githubassets.com/assets/code-0eb15370f045c7e0.css" /> Fix GH-21478: Forward read_property to real instance for initialized lazy proxies by iliaal · Pull Request #9 · iliaal/php-src · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Zend/tests/lazy_objects/gh18038-004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var_dump($real->prop);
--EXPECTF--
init
string(19) "RealInstance::__get"
string(12) "Proxy::__get"

Warning: Undefined property: RealInstance::$prop in %s on line %d
NULL
Expand Down
1 change: 0 additions & 1 deletion Zend/tests/lazy_objects/gh18038-007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ var_dump(isset($real->prop['']));
--EXPECT--
init
string(21) "RealInstance::__isset"
string(14) "Proxy::__isset"
bool(false)
bool(false)
32 changes: 32 additions & 0 deletions Zend/tests/lazy_objects/gh21478.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
GH-21478 (Property access on lazy proxy may invoke magic method despite real instance guards)
--FILE--
<?php

class Foo {
public $_;

public function __get($name) {
global $proxy;
printf("__get(\$%s) on %s\n", $name, $this::class);
return $proxy->{$name};
}
}

class Bar extends Foo {}

$rc = new ReflectionClass(Bar::class);
$proxy = $rc->newLazyProxy(function () {
echo "Init\n";
return new Foo();
});

$real = $rc->initializeLazyObject($proxy);
$real->x;

?>
--EXPECTF--
Init
__get($x) on Foo

Warning: Undefined property: Foo::$x in %s on line %d
7 changes: 7 additions & 0 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,13 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int

retval = &EG(uninitialized_zval);

if (UNEXPECTED(zend_object_is_lazy_proxy(zobj)
&& zend_lazy_object_initialized(zobj)
&& (type == BP_VAR_R || type == BP_VAR_IS))) {
zend_object *instance = zend_lazy_object_get_instance(zobj);
return zend_std_read_property(instance, name, type, cache_slot, rv);
}

/* magic isset */
if ((type == BP_VAR_IS) && zobj->ce->__isset) {
zval tmp_result;
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy