Skip to content

Commit

Permalink
Fix preloading of trait property attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jul 27, 2021
1 parent 5a7e1a7 commit 1bd6faf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ext/opcache/tests/preload.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class x extends c implements a, b {
}

trait T1 {
#[A]
public $prop;

static function foo() {
var_dump(__METHOD__);
}
Expand Down
6 changes: 6 additions & 0 deletions ext/opcache/zend_persist.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ static HashTable *zend_persist_attributes(HashTable *attributes)
return attributes;
}

/* Attributes for trait properties may be shared if preloading is used. */
HashTable *xlat = zend_shared_alloc_get_xlat_entry(attributes);
if (xlat) {
return xlat;
}

zend_hash_persist(attributes);

ZEND_HASH_FOREACH_VAL(attributes, v) {
Expand Down

0 comments on commit 1bd6faf

Please sign in to comment.