com php-src: Link anonymous classes during preloading: ext/opcache/ZendAccelerator.c ext/opcache/tests/preload.inc ext/opcache/tests/preload_008.phpt
| From: | Nikita Popov | Date: | Fri, 15 Feb 2019 16:50:40 +0000 |
| Subject: | com php-src: Link anonymous classes during preloading: ext/opcache/ZendAccelerator.c ext/opcache/tests/preload.inc ext/opcache/tests/preload_008.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104672@lists.php.net to get a copy of this message | ||
Commit: e15d657c1a8a4861a6b617398c7d34a6b3983480
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 15 Feb 2019 17:50:40 +0100
Parents: 970dcd240f4ecd3e19a12f940aa85bbc29c3f146
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e15d657c1a8a4861a6b617398c7d34a6b3983480
Log:
Link anonymous classes during preloading
Changed paths:
M ext/opcache/ZendAccelerator.c
M ext/opcache/tests/preload.inc
A ext/opcache/tests/preload_008.phpt
Diff:
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index d03a8b3..c83f23d 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -3277,7 +3277,7 @@ static void preload_link(void)
if (ce->type == ZEND_INTERNAL_CLASS) {
break;
}
- if ((ce->ce_flags & ZEND_ACC_TOP_LEVEL)
+ if ((ce->ce_flags & (ZEND_ACC_TOP_LEVEL|ZEND_ACC_ANON_CLASS))
&& !(ce->ce_flags & ZEND_ACC_LINKED)) {
parent = NULL;
diff --git a/ext/opcache/tests/preload.inc b/ext/opcache/tests/preload.inc
index 6a4df58..414e457 100644
--- a/ext/opcache/tests/preload.inc
+++ b/ext/opcache/tests/preload.inc
@@ -42,3 +42,7 @@ class Z {
public $foo;
public a $bar;
}
+
+function get_anon() {
+ return new class {};
+}
diff --git a/ext/opcache/tests/preload_008.phpt b/ext/opcache/tests/preload_008.phpt
new file mode 100644
index 0000000..2e630be
--- /dev/null
+++ b/ext/opcache/tests/preload_008.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Preloading of anonymous class
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.preload={PWD}/preload..inc
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+var_dump(get_anon());
+?>
+--EXPECT--
+object(class@anonymous)#1 (0) {
+}