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
4 changes: 4 additions & 0 deletions Zend/Optimizer/escape_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ static bool is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, i
&& !ce->destructor
&& !ce->__get
&& !ce->__set
&& !ce->__isset
&& !ce->num_hooked_props
&& !(ce->ce_flags & forbidden_flags)
&& (ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
return 1;
Expand Down Expand Up @@ -242,6 +244,8 @@ static bool is_local_def(zend_op_array *op_array, zend_ssa *ssa, int def, int va
&& !ce->destructor
&& !ce->__get
&& !ce->__set
&& !ce->__isset
&& !ce->num_hooked_props
&& !ce->parent) {
return 1;
}
Expand Down
50 changes: 50 additions & 0 deletions ext/opcache/tests/opt/dce_016.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
--TEST--
DCE must not remove assignments to properties of an object escaping through __isset
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.file_update_protection=0
--EXTENSIONS--
opcache
--FILE--
<?php

class C {
public $x = 0;
function __isset($n) {
global $g;
$g = $this;
return true;
}
}

function f() {
$o = new C;
isset($o->foo);
$o->x = 42;
}

f();
var_dump($g->x);

#[AllowDynamicProperties]
class F {
function __isset($n) {
$this->x = 2;
return true;
}
}

function i() {
$o = new F;
$o->x = 1;
isset($o->foo);
var_dump($o->x);
}
i();

?>
--EXPECT--
int(42)
int(2)
55 changes: 55 additions & 0 deletions ext/opcache/tests/opt/dce_017.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--TEST--
DCE must not remove assignments to properties of an object escaping through a property hook
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.file_update_protection=0
--EXTENSIONS--
opcache
--FILE--
<?php

class D {
public $x = 0;
public $h {
get {
global $g;
$g = $this;
return 1;
}
}
}

function g() {
$o = new D;
$o->h;
$o->x = 42;
}

g();
var_dump($g->x);

class E {
public $x = 0;
public $h {
set {
global $g;
$g = $this;
}
}
}

function h() {
$o = new E;
$o->h = 1;
$o->x = 42;
}

h();
var_dump($g->x);

?>
--EXPECT--
int(42)
int(42)
Loading