cvs: ZendEngine2 / zend_execute_API.c zend_vm_def.h zend_vm_execute.h /tests bug41633_1.phpt bug41633_2.phpt

From: Date: Wed, 13 Jun 2007 14:50:33 +0000
Subject: cvs: ZendEngine2 / zend_execute_API.c zend_vm_def.h zend_vm_execute.h /tests bug41633_1.phpt bug41633_2.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-5850@lists.php.net to get a copy of this message
dmitry Wed Jun 13 14:50:33 2007 UTC Modified files: /ZendEngine2 zend_execute_API.c zend_vm_def.h zend_vm_execute.h /ZendEngine2/tests bug41633_1.phpt bug41633_2.phpt Log: Fixed some class constant issues related to bug #41633 http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.402&r2=1.403&diff_format=u Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.402 ZendEngine2/zend_execute_API.c:1.403 --- ZendEngine2/zend_execute_API.c:1.402 Mon May 21 07:12:34 2007 +++ ZendEngine2/zend_execute_API.c Wed Jun 13 14:50:33 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.402 2007/05/21 07:12:34 tony2001 Exp $ */ +/* $Id: zend_execute_API.c,v 1.403 2007/06/13 14:50:33 dmitry Exp $ */ #include <stdio.h> #include <signal.h> @@ -474,6 +474,7 @@ zval *p = *pp; zend_bool inline_change = (zend_bool) (zend_uintptr_t) arg; zval const_value; + zstr colon; if (Z_TYPE_P(p) == IS_CONSTANT) { int refcount; @@ -486,6 +487,10 @@ is_ref = p->is_ref; if (!zend_u_get_constant(ZEND_STR_TYPE, Z_UNIVAL_P(p), Z_UNILEN_P(p), &const_value, scope TSRMLS_CC)) { + if ((UG(unicode) && (colon.u = u_memchr(Z_USTRVAL_P(p), ':', Z_USTRLEN_P(p))) && colon.u[1] == ':') || + (!UG(unicode) && (colon.s = memchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p))) && colon.s[1] == ':')) { + zend_error(E_ERROR, "Undefined class constant '%v'", Z_UNIVAL_P(p)); + } zend_error(E_NOTICE, "Use of undefined constant %v - assumed '%v'", Z_UNIVAL_P(p), Z_UNIVAL_P(p)); @@ -525,6 +530,10 @@ continue; } if (!zend_u_get_constant(ZEND_STR_TYPE, str_index, str_index_len-1, &const_value, scope TSRMLS_CC)) { + if ((UG(unicode) && (colon.u = u_memchr(str_index.u, ':', str_index_len-1)) && colon.u[1] == ':') || + (!UG(unicode) && (colon.s = memchr(str_index.s, ':', str_index_len-1)) && colon.s[1] == ':')) { + zend_error(E_ERROR, "Undefined class constant '%v'", str_index); + } zend_error(E_NOTICE, "Use of undefined constant %v - assumed '%v'", str_index, str_index); zend_hash_move_forward(Z_ARRVAL_P(p)); continue; http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.168&r2=1.169&diff_format=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.168 ZendEngine2/zend_vm_def.h:1.169 --- ZendEngine2/zend_vm_def.h:1.168 Fri May 18 13:12:47 2007 +++ ZendEngine2/zend_vm_def.h Wed Jun 13 14:50:33 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.168 2007/05/18 13:12:47 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.169 2007/06/13 14:50:33 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -2671,7 +2671,11 @@ ce = EX_T(opline->op1.u.var).class_entry; if (zend_u_hash_find(&ce->constants_table, Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant)+1, (void **) &value) == SUCCESS) { + zend_class_entry *old_scope = EG(scope); + + EG(scope) = ce; zval_update_constant(value, (void *) 1 TSRMLS_CC); + EG(scope) = old_scope; EX_T(opline->result.u.var).tmp_var = **value; zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); } else { http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.171&r2=1.172&diff_format=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.171 ZendEngine2/zend_vm_execute.h:1.172 --- ZendEngine2/zend_vm_execute.h:1.171 Fri May 18 13:12:47 2007 +++ ZendEngine2/zend_vm_execute.h Wed Jun 13 14:50:33 2007 @@ -2753,7 +2753,11 @@ ce = EX_T(opline->op1.u.var).class_entry; if (zend_u_hash_find(&ce->constants_table, Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant)+1, (void **) &value) == SUCCESS) { + zend_class_entry *old_scope = EG(scope); + + EG(scope) = ce; zval_update_constant(value, (void *) 1 TSRMLS_CC); + EG(scope) = old_scope; EX_T(opline->result.u.var).tmp_var = **value; zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); } else { @@ -16048,7 +16052,11 @@ ce = EX_T(opline->op1.u.var).class_entry; if (zend_u_hash_find(&ce->constants_table, Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant)+1, (void **) &value) == SUCCESS) { + zend_class_entry *old_scope = EG(scope); + + EG(scope) = ce; zval_update_constant(value, (void *) 1 TSRMLS_CC); + EG(scope) = old_scope; EX_T(opline->result.u.var).tmp_var = **value; zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); } else { http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug41633_1.phpt?r1=1.1&r2=1.2&diff_format=u Index: ZendEngine2/tests/bug41633_1.phpt diff -u /dev/null ZendEngine2/tests/bug41633_1.phpt:1.2 --- /dev/null Wed Jun 13 14:50:33 2007 +++ ZendEngine2/tests/bug41633_1.phpt Wed Jun 13 14:50:33 2007 @@ -0,0 +1,12 @@ +--TEST-- +Bug #41633.1 (self:: doesn't work for constants) +--FILE-- +<?php +class Foo { + const A = self::B; + const B = "ok"; +} +echo Foo::A."\n"; +?> +--EXPECT-- +ok http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug41633_2.phpt?r1=1.1&r2=1.2&diff_format=u Index: ZendEngine2/tests/bug41633_2.phpt diff -u /dev/null ZendEngine2/tests/bug41633_2.phpt:1.2 --- /dev/null Wed Jun 13 14:50:33 2007 +++ ZendEngine2/tests/bug41633_2.phpt Wed Jun 13 14:50:33 2007 @@ -0,0 +1,11 @@ +--TEST-- +Bug #41633.2 (Undefined class constants must not be substituted by strings) +--FILE-- +<?php +class Foo { + const A = self::B; +} +echo Foo::A."\n"; +?> +--EXPECTF-- +Fatal error: Undefined class constant 'self::B' in %sbug41633_2.php on line 5

« previous php.zend-engine.cvs (#5850) next »