Skip to content

Commit 5269c4c

Browse files
committed
Fixed bug #74657 (Undefined constants in array properties result in broken properties)
1 parent 872e43d commit 5269c4c

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2017 PHP 7.0.21
44

5+
- Core:
6+
. Fixed bug #74658 (Undefined constants in array properties result in broken
7+
properties). (Laruence)
8+
59
- SPL:
610
. Fixed bug #74478 (null coalescing operator failing with SplFixedArray).
711
(jhdxr)

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
@@ -1087,8 +1087,6 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */
10871087
ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */
10881088
{
10891089
if (!(class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
1090-
class_type->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED;
1091-
10921090
if (class_type->parent) {
10931091
if (UNEXPECTED(zend_update_class_constants(class_type->parent) != SUCCESS)) {
10941092
return FAILURE;
@@ -1163,6 +1161,9 @@ ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */
11631161
*scope = old_scope;
11641162
}
11651163
}
1164+
1165+
class_type->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED;
1166+
11661167
return SUCCESS;
11671168
}
11681169
/* }}} */

0 commit comments

Comments
 (0)