Index: Zend/zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.647.2.27.2.41.2.84 diff -u -r1.647.2.27.2.41.2.84 zend_compile.c --- Zend/zend_compile.c 24 Aug 2008 18:22:33 -0000 1.647.2.27.2.41.2.84 +++ Zend/zend_compile.c 28 Aug 2008 12:36:00 -0000 @@ -3767,7 +3767,7 @@ *result = CG(active_op_array)->opcodes[new_token->u.opline_num].result; } -static zend_constant* zend_get_ct_const(const zval *const_name, int mode TSRMLS_DC) /* {{{ */ +static zend_constant* zend_get_ct_const(const zval *const_name, zend_bool only_ct_subst TSRMLS_DC) /* {{{ */ { zend_constant *c = NULL; @@ -3786,9 +3786,8 @@ if (c->flags & CONST_CT_SUBST) { return c; } - if (mode == ZEND_RT && - (c->flags & CONST_PERSISTENT) && - !CG(current_namespace) && + if ((c->flags & CONST_PERSISTENT) && + !only_ct_subst && !(CG(compiler_options) & ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION) && Z_TYPE(c->value) != IS_CONSTANT && Z_TYPE(c->value) != IS_CONSTANT_ARRAY) { @@ -3798,9 +3797,9 @@ } /* }}} */ -static int zend_constant_ct_subst(znode *result, zval *const_name, int mode TSRMLS_DC) /* {{{ */ +static int zend_constant_ct_subst(znode *result, zval *const_name, zend_bool only_ct_subst TSRMLS_DC) /* {{{ */ { - zend_constant *c = zend_get_ct_const(const_name, mode TSRMLS_CC); + zend_constant *c = zend_get_ct_const(const_name, only_ct_subst TSRMLS_CC); if (c) { zval_dtor(const_name); @@ -3827,9 +3826,13 @@ zval_dtor(&constant_container->u.constant); check_namespace = 1; constant_container = NULL; - fetch_type = ZEND_FETCH_CLASS_RT_NS_CHECK | IS_CONSTANT_RT_NS_CHECK;; + fetch_type = ZEND_FETCH_CLASS_RT_NS_CHECK | IS_CONSTANT_RT_NS_CHECK; } + if (!CG(current_namespace)) { + check_namespace = 0; + } + switch (mode) { case ZEND_CT: if (constant_container) { @@ -3843,8 +3846,8 @@ zend_do_build_full_name(NULL, constant_container, constant_name TSRMLS_CC); *result = *constant_container; result->u.constant.type = IS_CONSTANT | fetch_type; - } else if (fetch_type || !zend_constant_ct_subst(result, &constant_name->u.constant, ZEND_CT TSRMLS_CC)) { - if (check_namespace && CG(current_namespace)) { + } else if (fetch_type || !zend_constant_ct_subst(result, &constant_name->u.constant, 1 TSRMLS_CC)) { + if (check_namespace) { /* We assume we use constant from the current namespace if it is not prefixed. */ tmp.op_type = IS_CONST; @@ -3860,7 +3863,7 @@ break; case ZEND_RT: if (constant_container || - !zend_constant_ct_subst(result, &constant_name->u.constant, ZEND_RT TSRMLS_CC)) { + !zend_constant_ct_subst(result, &constant_name->u.constant, check_namespace TSRMLS_CC)) { zend_op *opline; if (constant_container) { @@ -3871,7 +3874,7 @@ zend_do_fetch_class(&tmp, constant_container TSRMLS_CC); constant_container = &tmp; } - } else if (check_namespace && CG(current_namespace)) { + } else if (check_namespace) { /* We assume we use constant from the current namespace if it is not prefixed. */ tmp.op_type = IS_CONST; @@ -5166,7 +5169,7 @@ zend_error(E_COMPILE_ERROR, "Arrays are not allowed as constants"); } - if (zend_get_ct_const(&name->u.constant, ZEND_CT TSRMLS_CC)) { + if (zend_get_ct_const(&name->u.constant, 1 TSRMLS_CC)) { zend_error(E_COMPILE_ERROR, "Cannot redeclare constant '%s'", Z_STRVAL(name->u.constant)); }