From 182314c3173c9eddb80db4bc1ad3ad612e88634b Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Wed, 9 Nov 2022 16:36:05 +0100 Subject: [PATCH 1/2] Do not report MINIT stage internal class aliases in extensions Signed-off-by: Bob Weinand --- Zend/zend_API.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 54bcad825a5..f613121ee4a 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3281,7 +3281,10 @@ ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_ if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE)) { ce->refcount++; } - zend_observer_class_linked_notify(ce, lcname); + // avoid notifying at MINIT time + if (ce->type == ZEND_USER_CLASS) { + zend_observer_class_linked_notify(ce, lcname); + } return SUCCESS; } return FAILURE; From 4052bbf0e323977edbd6f7f2402f7207e456fbbe Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Wed, 9 Nov 2022 16:36:28 +0100 Subject: [PATCH 2/2] Fix opcache preload with observers enabled Signed-off-by: Bob Weinand --- ext/opcache/ZendAccelerator.c | 2 ++ ext/zend_test/tests/observer_preload.inc | 13 ++++++++ ext/zend_test/tests/observer_preload.phpt | 38 +++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 ext/zend_test/tests/observer_preload.inc create mode 100644 ext/zend_test/tests/observer_preload.phpt diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index f78ae8755f3..f2138a63fe2 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -35,6 +35,7 @@ #include "zend_inheritance.h" #include "zend_exceptions.h" #include "zend_mmap.h" +#include "zend_observer.h" #include "main/php_main.h" #include "main/SAPI.h" #include "main/php_streams.h" @@ -4480,6 +4481,7 @@ static int accel_preload(const char *config, bool in_child) script->script.main_op_array.fn_flags |= ZEND_ACC_DONE_PASS_TWO; script->script.main_op_array.last = 1; script->script.main_op_array.last_literal = 1; + script->script.main_op_array.T = ZEND_OBSERVER_ENABLED; #if ZEND_USE_ABS_CONST_ADDR script->script.main_op_array.literals = (zval*)emalloc(sizeof(zval)); #else diff --git a/ext/zend_test/tests/observer_preload.inc b/ext/zend_test/tests/observer_preload.inc new file mode 100644 index 00000000000..7652014f91b --- /dev/null +++ b/ext/zend_test/tests/observer_preload.inc @@ -0,0 +1,13 @@ + +--EXPECTF-- + + + + + + + + + + + + + +Done + \ No newline at end of file