]> granicus.if.org Git - php/commitdiff
- This one fixes rather strange problem - ZE allows multiple declarations of the...
authorAndi Gutmans <andi@php.net>
Fri, 10 Sep 2004 06:13:13 +0000 (06:13 +0000)
committerAndi Gutmans <andi@php.net>
Fri, 10 Sep 2004 06:13:13 +0000 (06:13 +0000)
- It could be a minor BC break, but I'm sure it's a bug. (Antony Dovgal aka tony2001)

Zend/zend_compile.c

index 57101156897317ab6c25b36033c54fa9e6e348ef..0e9ae9eafd8d6e4f3a4d1a5e8ce18640402e533a 100644 (file)
@@ -2641,7 +2641,7 @@ void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_ty
 void zend_do_declare_class_constant(znode *var_name, znode *value TSRMLS_DC)
 {
        zval *property;
-
+       
        if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
                zend_error(E_COMPILE_ERROR, "Arrays are not allowed in class constants");
        }
@@ -2655,8 +2655,10 @@ void zend_do_declare_class_constant(znode *var_name, znode *value TSRMLS_DC)
                property->type = IS_NULL;
        }
 
-       zend_hash_update(&CG(active_class_entry)->constants_table, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL);
-
+       if (zend_hash_add(&CG(active_class_entry)->constants_table, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL)==FAILURE) {
+               FREE_ZVAL(property);
+               zend_error(E_COMPILE_ERROR, "Cannot redefine class constant %s::%s", CG(active_class_entry)->name, var_name->u.constant.value.str.val);
+       }
        FREE_PNODE(var_name);
 }