summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2010-12-01 13:33:49 +0000
committerDmitry Stogov <dmitry@php.net>2010-12-01 13:33:49 +0000
commita45631d9663a8a6af7b5a739e48966a604a7e961 (patch)
treee9f36ee0baa3339b94478f191e37eb7b035f8bf9 /Zend
parent8e65f5069885ea2e866f6c84f2b5bcad6dd8f3c8 (diff)
downloadphp-git-a45631d9663a8a6af7b5a739e48966a604a7e961.tar.gz
Allowed indirect $this access (Scott)
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/indirect_reference_this.phpt13
-rw-r--r--Zend/zend_compile.c4
2 files changed, 17 insertions, 0 deletions
diff --git a/Zend/tests/indirect_reference_this.phpt b/Zend/tests/indirect_reference_this.phpt
new file mode 100644
index 0000000000..c344bd03ff
--- /dev/null
+++ b/Zend/tests/indirect_reference_this.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Indirect referenced $this
+--FILE--
+<?php
+class X {
+ function f($x){var_dump($$x);}
+}
+$x = new X;
+$x->f("this");
+?>
+--EXPECTF--
+object(X)#%d (0) {
+}
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 9d61c004d6..30f8f6d5a1 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -5543,6 +5543,10 @@ void zend_do_indirect_references(znode *result, const znode *num_references, zno
}
zend_do_begin_variable_parse(TSRMLS_C);
fetch_simple_variable(result, variable, 1 TSRMLS_CC);
+ /* there is a chance someone is accessing $this */
+ if (CG(active_op_array)->scope && CG(active_op_array)->this_var == -1) {
+ CG(active_op_array)->this_var = lookup_cv(CG(active_op_array), estrndup("this", sizeof("this")-1), sizeof("this")-1);
+ }
}
/* }}} */