dmitry Thu May 5 13:36:54 2005 EDT
Added files: (Branch: PHP_5_0)
/ZendEngine2/tests bug31525.phpt
Modified files:
/php-src NEWS
/ZendEngine2 zend_compile.c zend_execute.c
/php-src/tests/lang bug20175.phpt bug21600.phpt
Log:
Fixed bug #31525 (object reference being dropped. $this getting lost)
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1760.2.370&r2=1.1760.2.371&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1760.2.370 php-src/NEWS:1.1760.2.371
--- php-src/NEWS:1.1760.2.370 Thu May 5 09:30:30 2005
+++ php-src/NEWS Thu May 5 13:36:51 2005
@@ -68,6 +68,8 @@
- Fixed bug #31636 (another crash when echoing a COM object). (Wez)
- Fixed bug #31583 (php_std_date() uses short day names in non-y2k_compliance
mode). (mike at php dot net)
+- Fixed bug #31525 (object reference being dropped. $this getting lost).
+ (Stas, Dmitry)
- Fixed bug #31502 (Wrong deserialization from session when using WDDX
serializer). (Dmitry)
- Fixed bug #31363 (broken non-blocking flock()). ian at snork dot net
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.567.2.17&r2=1.567.2.18&ty=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.567.2.17
ZendEngine2/zend_compile.c:1.567.2.18
--- ZendEngine2/zend_compile.c:1.567.2.17 Wed Apr 27 10:30:32 2005
+++ ZendEngine2/zend_compile.c Thu May 5 13:36:52 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.567.2.17 2005/04/27 14:30:32 dmitry Exp $ */
+/* $Id: zend_compile.c,v 1.567.2.18 2005/05/05 17:36:52 dmitry Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -483,6 +483,12 @@
}
}
+static inline zend_bool zend_is_function_or_method_call(znode *variable)
+{
+ zend_uint type = variable->u.EA.type;
+
+ return ((type & ZEND_PARSED_METHOD_CALL) || (type ==
ZEND_PARSED_FUNCTION_CALL));
+}
void zend_do_assign_ref(znode *result, znode *lvar, znode *rvar TSRMLS_DC)
{
@@ -494,6 +500,11 @@
if (opline_is_fetch_this(last_op TSRMLS_CC)) {
zend_error(E_COMPILE_ERROR, "Cannot re-assign $this");
}
+ if (zend_is_function_or_method_call(rvar)) {
+ opline->extended_value = ZEND_RETURNS_FUNCTION;
+ } else {
+ opline->extended_value = 0;
+ }
if (result) {
opline->result.op_type = IS_VAR;
opline->result.u.EA.type = 0;
@@ -717,13 +728,6 @@
}
}
-static inline zend_bool zend_is_function_or_method_call(znode *variable)
-{
- zend_uint type = variable->u.EA.type;
-
- return ((type & ZEND_PARSED_METHOD_CALL) || (type ==
ZEND_PARSED_FUNCTION_CALL));
-}
-
void zend_do_begin_variable_parse(TSRMLS_D)
{
zend_llist fetch_list;
http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.652.2.30&r2=1.652.2.31&ty=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.652.2.30
ZendEngine2/zend_execute.c:1.652.2.31
--- ZendEngine2/zend_execute.c:1.652.2.30 Wed May 4 11:25:42 2005
+++ ZendEngine2/zend_execute.c Thu May 5 13:36:52 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.652.2.30 2005/05/04 15:25:42 stas Exp $ */
+/* $Id: zend_execute.c,v 1.652.2.31 2005/05/05 17:36:52 dmitry Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -2281,6 +2281,15 @@
{
zval **value_ptr_ptr = get_zval_ptr_ptr(&opline->op2, EX(Ts), BP_VAR_W);
+ if (opline->op2.op_type == IS_VAR &&
+ !(*value_ptr_ptr)->is_ref &&
+ opline->extended_value == ZEND_RETURNS_FUNCTION &&
+ !EX_T(opline->op2.u.var).var.fcall_returned_reference) {
+ zend_error(E_STRICT, "Only variables should be assigned by
reference");
+ PZVAL_LOCK(*value_ptr_ptr); /* undo the effect of
get_zval_ptr_ptr() */
+ return zend_assign_handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
+ }
+
zend_assign_to_variable_reference(&opline->result,
get_zval_ptr_ptr(&opline->op1, EX(Ts), BP_VAR_W), value_ptr_ptr, EX(Ts)
TSRMLS_CC);
NEXT_OPCODE();
http://cvs.php.net/diff.php/php-src/tests/lang/bug20175.phpt?r1=1.7&r2=1.7.2.1&ty=u
Index: php-src/tests/lang/bug20175.phpt
diff -u php-src/tests/lang/bug20175.phpt:1.7
php-src/tests/lang/bug20175.phpt:1.7.2.1
--- php-src/tests/lang/bug20175.phpt:1.7 Mon Feb 3 11:33:13 2003
+++ php-src/tests/lang/bug20175.phpt Thu May 5 13:36:53 2005
@@ -2,6 +2,8 @@
Bug #20175 (Static vars can't store ref to new instance)
--SKIPIF--
<?php if (version_compare(zend_version(),'2.0.0-dev','<')) die('skip ZE1 does
not have static class members'); ?>
+--INI--
+error_reporting=4095
--FILE--
<?php
print zend_version()."\n";
@@ -145,10 +147,11 @@
foo:1
bar_static()
bar_global()
+
+Strict Standards: Only variables should be assigned by reference in
%sbug20175.php on line 47
bar:1
bar_static()
-bar_global()
-bar:2
+bar:1
wow_static()
wow_global()
wow:1
http://cvs.php.net/diff.php/php-src/tests/lang/bug21600.phpt?r1=1.3&r2=1.3.2.1&ty=u
Index: php-src/tests/lang/bug21600.phpt
diff -u php-src/tests/lang/bug21600.phpt:1.3
php-src/tests/lang/bug21600.phpt:1.3.2.1
--- php-src/tests/lang/bug21600.phpt:1.3 Mon Feb 24 11:50:35 2003
+++ php-src/tests/lang/bug21600.phpt Thu May 5 13:36:53 2005
@@ -1,5 +1,7 @@
--TEST--
Bug #21600 (assign by reference function call changes variable contents)
+--INI--
+error_reporting=4095
--FILE--
<?php
$tmp = array();
@@ -23,11 +25,14 @@
return $text;
}
?>
---EXPECT--
+--EXPECTF--
+Strict Standards: Only variables should be assigned by reference in
%sbug21600.php on line 4
array(1) {
["foo"]=>
- &string(4) "test"
+ string(4) "test"
}
+
+Strict Standards: Only variables should be assigned by reference in
%sbug21600.php on line 11
array(1) {
["foo"]=>
string(4) "test"
http://cvs.php.net/co.php/ZendEngine2/tests/bug31525.phpt?r=1.1&p=1
Index: ZendEngine2/tests/bug31525.phpt
+++ ZendEngine2/tests/bug31525.phpt
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php