Skip to content

Commit cd3520c

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fixed bug #74657 (Undefined constants in array properties result in broken properties)
2 parents fc87715 + 5269c4c commit cd3520c

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

Zend/tests/bug74657.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #74657 (Undefined constants in array properties result in broken properties)
3+
--FILE--
4+
<?php
5+
6+
interface I {
7+
}
8+
9+
class C {
10+
const FOO = I::FOO;
11+
12+
public $options = [self::FOO => "bar"];
13+
}
14+
15+
try {
16+
var_dump((new C)->options);
17+
} catch (Throwable $e) {}
18+
19+
var_dump((new C)->options);
20+
?>
21+
--EXPECTF--
22+
Fatal error: Uncaught Error: Undefined class constant 'I::FOO' in %sbug74657.php:%d
23+
Stack trace:
24+
#0 {main}
25+
thrown in %sbug74657.php on line %d
26+

Zend/zend_API.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,6 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */
10881088
ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */
10891089
{
10901090
if (!(class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
1091-
class_type->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED;
1092-
10931091
if (class_type->parent) {
10941092
if (UNEXPECTED(zend_update_class_constants(class_type->parent) != SUCCESS)) {
10951093
return FAILURE;
@@ -1159,6 +1157,9 @@ ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */
11591157
}
11601158
}
11611159
}
1160+
1161+
class_type->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED;
1162+
11621163
return SUCCESS;
11631164
}
11641165
/* }}} */

0 commit comments

Comments
 (0)