Skip to content

Commit 17b0e49

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix class link observer with file_cache_only=1
2 parents 60b2c3f + 6622c54 commit 17b0e49

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

ext/opcache/zend_accelerator_util_funcs.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,10 @@ static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, Ha
232232
} else {
233233
zend_class_entry *ce = Z_PTR(p->val);
234234
_zend_hash_append_ptr_ex(target, p->key, Z_PTR(p->val), 1);
235-
if ((ce->ce_flags & ZEND_ACC_LINKED)
236-
&& ZSTR_HAS_CE_CACHE(ce->name)
237-
&& ZSTR_VAL(p->key)[0]) {
238-
ZSTR_SET_CE_CACHE_EX(ce->name, ce, 0);
235+
if ((ce->ce_flags & ZEND_ACC_LINKED) && ZSTR_VAL(p->key)[0]) {
236+
if (ZSTR_HAS_CE_CACHE(ce->name)) {
237+
ZSTR_SET_CE_CACHE_EX(ce->name, ce, 0);
238+
}
239239
if (UNEXPECTED(call_observers)) {
240240
_zend_observer_class_linked_notify(ce, p->key);
241241
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Observer: Observe function and class declarations with file_cache_only
3+
--EXTENSIONS--
4+
zend_test
5+
--INI--
6+
zend_test.observer.enabled=1
7+
zend_test.observer.observe_declaring=1
8+
opcache.enable_cli=1
9+
opcache.file_cache={TMP}
10+
opcache.file_cache_only=1
11+
--FILE--
12+
<?php
13+
14+
function a() {}
15+
class A {}
16+
class B extends A {}
17+
18+
?>
19+
--EXPECTF--
20+
<!-- declared function 'a' -->
21+
<!-- declared class 'a' -->
22+
<!-- declared class 'b' -->
23+
<!-- init '%s' -->

0 commit comments

Comments
 (0)