scottmac Fri, 10 Dec 2010 06:34:03 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=306169
Log:
MFH: Fix indirect reference of $this
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
A php/php-src/branches/PHP_5_3/Zend/tests/indirect_reference_this.phpt
U php/php-src/branches/PHP_5_3/Zend/zend_compile.c
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2010-12-10 05:16:47 UTC (rev 306168)
+++ php/php-src/branches/PHP_5_3/NEWS 2010-12-10 06:34:03 UTC (rev 306169)
@@ -8,6 +8,9 @@
- PDO Oracle driver:
. Fixed bug #39199 (Cannot load Lob data with more than 4000 bytes on
ORACLE 10). (spatar at mail dot nnov dot ru)
+
+- Indirect reference to $this fails to resolve if direct $this is never used
+ in method. (Scott)
09 Dec 2010, PHP 5.3.4
- Upgraded bundled Sqlite3 to version 3.7.3. (Ilia)
Added: php/php-src/branches/PHP_5_3/Zend/tests/indirect_reference_this.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/tests/indirect_reference_this.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_3/Zend/tests/indirect_reference_this.phpt
2010-12-10 06:34:03 UTC (rev 306169)
@@ -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) {
+}
\ No newline at end of file
Modified: php/php-src/branches/PHP_5_3/Zend/zend_compile.c
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_compile.c 2010-12-10 05:16:47 UTC
(rev 306168)
+++ php/php-src/branches/PHP_5_3/Zend/zend_compile.c 2010-12-10 06:34:03 UTC
(rev 306169)
@@ -4351,6 +4351,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 TSRMLS_CC);
+ }
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php