dmitry                                   Wed, 01 Dec 2010 13:33:49 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=305886

Log:
Allowed indirect $this access (Scott)

Changed paths:
    A   php/php-src/trunk/Zend/tests/indirect_reference_this.phpt
    U   php/php-src/trunk/Zend/zend_compile.c

Added: php/php-src/trunk/Zend/tests/indirect_reference_this.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/indirect_reference_this.phpt                   
        (rev 0)
+++ php/php-src/trunk/Zend/tests/indirect_reference_this.phpt   2010-12-01 
13:33:49 UTC (rev 305886)
@@ -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) {
+}

Modified: php/php-src/trunk/Zend/zend_compile.c
===================================================================
--- php/php-src/trunk/Zend/zend_compile.c       2010-12-01 12:59:26 UTC (rev 
305885)
+++ php/php-src/trunk/Zend/zend_compile.c       2010-12-01 13:33:49 UTC (rev 
305886)
@@ -5543,6 +5543,10 @@
        }
        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);
+       }
 }
 /* }}} */


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to