Skip to content

Commit 2cab487

Browse files
committed
Merge branch 'PHP-8.2'
2 parents 75f3722 + 4052bbf commit 2cab487

File tree

4 files changed

+57
-1
lines changed

4 files changed

+57
-1
lines changed

Zend/zend_API.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3281,7 +3281,10 @@ ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_
32813281
if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
32823282
ce->refcount++;
32833283
}
3284-
zend_observer_class_linked_notify(ce, lcname);
3284+
// avoid notifying at MINIT time
3285+
if (ce->type == ZEND_USER_CLASS) {
3286+
zend_observer_class_linked_notify(ce, lcname);
3287+
}
32853288
return SUCCESS;
32863289
}
32873290
return FAILURE;

ext/opcache/ZendAccelerator.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "zend_inheritance.h"
3636
#include "zend_exceptions.h"
3737
#include "zend_mmap.h"
38+
#include "zend_observer.h"
3839
#include "main/php_main.h"
3940
#include "main/SAPI.h"
4041
#include "main/php_streams.h"
@@ -4480,6 +4481,7 @@ static int accel_preload(const char *config, bool in_child)
44804481
script->script.main_op_array.fn_flags |= ZEND_ACC_DONE_PASS_TWO;
44814482
script->script.main_op_array.last = 1;
44824483
script->script.main_op_array.last_literal = 1;
4484+
script->script.main_op_array.T = ZEND_OBSERVER_ENABLED;
44834485
#if ZEND_USE_ABS_CONST_ADDR
44844486
script->script.main_op_array.literals = (zval*)emalloc(sizeof(zval));
44854487
#else
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
class Foo {
4+
public static function test() {
5+
return "foo::test";
6+
}
7+
}
8+
9+
if (true) {
10+
function foo() {
11+
return 'I should be observable';
12+
}
13+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Observer: Test with basic preloading
3+
--EXTENSIONS--
4+
zend_test
5+
opcache
6+
--INI--
7+
opcache.enable=1
8+
opcache.enable_cli=1
9+
opcache.optimization_level=-1
10+
opcache.preload={PWD}/observer_preload.inc
11+
zend_test.observer.enabled=1
12+
zend_test.observer.observe_all=1
13+
zend_test.observer.observe_declaring=1
14+
zend_test.observer.show_return_value=1
15+
--FILE--
16+
<?php
17+
18+
Foo::test();
19+
foo();
20+
21+
echo 'Done' . PHP_EOL;
22+
?>
23+
--EXPECTF--
24+
<!-- declared class 'foo' -->
25+
<!-- init '%sobserver_preload.inc' -->
26+
<file '%sobserver_preload.inc'>
27+
<!-- declared function 'foo' -->
28+
</file '%sobserver_preload.inc'>
29+
<!-- init '%sobserver_preload.php' -->
30+
<file '%sobserver_preload.php'>
31+
<!-- init Foo::test() -->
32+
<Foo::test>
33+
</Foo::test:'foo::test'>
34+
<!-- init foo() -->
35+
<foo>
36+
</foo:'I should be observable'>
37+
Done
38+
</file '%sobserver_preload.php'>

0 commit comments

Comments
 (0)