com php-src: Make duplicate class constant error for internal class: Zend/zend_API.c Zend/zend_compile.c ext/intl/calend ar/calendar_class.cpp
| From: | Nikita Popov | Date: | Thu, 10 Dec 2015 21:22:49 +0000 |
| Subject: | com php-src: Make duplicate class constant error for internal class: Zend/zend_API.c Zend/zend_compile.c ext/intl/calend ar/calendar_class.cpp | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-90216@lists.php.net to get a copy of this message | ||
Commit: 04e3d82b5597630cc0a4ccdbafb75a4750c6506e
Author: Nikita Popov <nikic@php.net> Thu, 10 Dec 2015 22:22:49 +0100
Parents: 8e5e3301a1b9f685452f8709411674f3812b2a2d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=04e3d82b5597630cc0a4ccdbafb75a4750c6506e
Log:
Make duplicate class constant error for internal class
And drop two duplicate constant declarations from intl. These
were leaking previously.
Changed paths:
M Zend/zend_API.c
M Zend/zend_compile.c
M ext/intl/calendar/calendar_class.cpp
Diff:
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index fc49f33..8003fd7 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -3749,7 +3749,7 @@ ZEND_API int zend_declare_class_constant_ex(zend_class_entry *ce, zend_string
*n
}
if (zend_string_equals_literal_ci(name, "class")) {
- zend_error((ce->type == ZEND_INTERNAL_CLASS) ? E_CORE_ERROR : E_COMPILE_ERROR,
+ zend_error_noreturn(ce->type == ZEND_INTERNAL_CLASS ? E_CORE_ERROR : E_COMPILE_ERROR,
"A class constant must not be called 'class'; it is reserved for class name
fetching");
}
@@ -3765,8 +3765,13 @@ ZEND_API int zend_declare_class_constant_ex(zend_class_entry *ce, zend_string
*n
if (Z_CONSTANT_P(value)) {
ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED;
}
- return zend_hash_add_ptr(&ce->constants_table, name, c) ?
- SUCCESS : FAILURE;
+
+ if (!zend_hash_add_ptr(&ce->constants_table, name, c)) {
+ zend_error_noreturn(ce->type == ZEND_INTERNAL_CLASS ? E_CORE_ERROR : E_COMPILE_ERROR,
+ "Cannot redefine class constant %s::%s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
+ }
+
+ return SUCCESS;
}
/* }}} */
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 2e50271..3295451 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -5231,10 +5231,7 @@ void zend_compile_class_const_decl(zend_ast *ast) /* {{{ */
zend_const_expr_to_zval(&value_zv, value_ast);
name = zend_new_interned_string_safe(name);
- if (zend_declare_class_constant_ex(ce, name, &value_zv, ast->attr, doc_comment) !=
SUCCESS) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot redefine class constant %s::%s",
- ZSTR_VAL(ce->name), ZSTR_VAL(name));
- }
+ zend_declare_class_constant_ex(ce, name, &value_zv, ast->attr, doc_comment);
}
}
/* }}} */
diff --git a/ext/intl/calendar/calendar_class.cpp b/ext/intl/calendar/calendar_class.cpp
index 6b6feef..1f3a68b 100644
--- a/ext/intl/calendar/calendar_class.cpp
+++ b/ext/intl/calendar/calendar_class.cpp
@@ -505,8 +505,6 @@ void calendar_register_IntlCalendar_class(void)
CALENDAR_DECL_LONG_CONST("FIELD_AM_PM", UCAL_AM_PM);
CALENDAR_DECL_LONG_CONST("FIELD_HOUR", UCAL_HOUR);
CALENDAR_DECL_LONG_CONST("FIELD_HOUR_OF_DAY", UCAL_HOUR_OF_DAY);
- CALENDAR_DECL_LONG_CONST("FIELD_HOUR", UCAL_HOUR);
- CALENDAR_DECL_LONG_CONST("FIELD_HOUR_OF_DAY", UCAL_HOUR_OF_DAY);
CALENDAR_DECL_LONG_CONST("FIELD_MINUTE", UCAL_MINUTE);
CALENDAR_DECL_LONG_CONST("FIELD_SECOND", UCAL_SECOND);
CALENDAR_DECL_LONG_CONST("FIELD_MILLISECOND", UCAL_MILLISECOND);