File tree Expand file tree Collapse file tree 6 files changed +53
-4
lines changed Expand file tree Collapse file tree 6 files changed +53
-4
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ abstract class ParentClass {
3
+ use TraitA;
4
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ class TheClass extends ParentClass {
3
+ use TraitA;
4
+
5
+ public function test () {
6
+ return self ::$ non_empty_array ;
7
+ }
8
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ trait TraitA {
3
+ protected static $ non_empty_array = ['non-empty ' ];
4
+ }
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-13433 (Segmentation Fault in zend_class_init_statics when using opcache.preload)
3
+ --INI--
4
+ opcache.enable=1
5
+ opcache.enable_cli=1
6
+ opcache.optimization_level=0
7
+ opcache.preload={PWD}/preload.inc
8
+ --EXTENSIONS--
9
+ opcache
10
+ --SKIPIF--
11
+ <?php
12
+ if (PHP_OS_FAMILY == 'Windows ' ) die ('skip Preloading is not supported on Windows ' );
13
+ ?>
14
+ --FILE--
15
+ <?php
16
+ $ instance = new TheClass ;
17
+ var_dump ($ instance );
18
+ var_dump ($ instance ->test ());
19
+ ?>
20
+ OK
21
+ --EXPECT--
22
+ object(TheClass)#1 (0) {
23
+ }
24
+ array(1) {
25
+ [0]=>
26
+ string(9) "non-empty"
27
+ }
28
+ OK
Original file line number Diff line number Diff line change
1
+ <?php
2
+ require __DIR__ .'/TraitA.inc ' ;
3
+ require __DIR__ .'/ParentClass.inc ' ;
4
+ require __DIR__ .'/TheClass.inc ' ;
Original file line number Diff line number Diff line change @@ -904,10 +904,11 @@ zend_class_entry *zend_persist_class_entry(zend_class_entry *orig_ce)
904
904
ce -> default_static_members_table = zend_shared_memdup_free (ce -> default_static_members_table , sizeof (zval ) * ce -> default_static_members_count );
905
905
906
906
/* Persist only static properties in this class.
907
- * Static properties from parent classes will be handled in class_copy_ctor */
908
- i = (ce -> parent && (ce -> ce_flags & ZEND_ACC_LINKED )) ? ce -> parent -> default_static_members_count : 0 ;
909
- for (; i < ce -> default_static_members_count ; i ++ ) {
910
- zend_persist_zval (& ce -> default_static_members_table [i ]);
907
+ * Static properties from parent classes will be handled in class_copy_ctor and are marked with IS_INDIRECT */
908
+ for (i = 0 ; i < ce -> default_static_members_count ; i ++ ) {
909
+ if (Z_TYPE (ce -> default_static_members_table [i ]) != IS_INDIRECT ) {
910
+ zend_persist_zval (& ce -> default_static_members_table [i ]);
911
+ }
911
912
}
912
913
if (ce -> ce_flags & ZEND_ACC_IMMUTABLE ) {
913
914
if (ce -> ce_flags & ZEND_ACC_LINKED ) {
You can’t perform that action at this time.
0 commit comments