summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--ext/opcache/tests/bug65915.phpt26
-rw-r--r--ext/opcache/zend_accelerator_util_funcs.c12
3 files changed, 40 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 1577cc0dd0..e8ab470d5a 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,9 @@ PHP NEWS
. Fixed bug #66094 (unregister_tick_function tries to cast a Closure to a
string). (Laruence)
+- OPCache
+ . Fixed bug #65915 (Inconsistent results with require return value). (Dmitry)
+
- readline
. Fixed Bug #65714 (PHP cli forces the tty to cooked mode). (Remi)
diff --git a/ext/opcache/tests/bug65915.phpt b/ext/opcache/tests/bug65915.phpt
new file mode 100644
index 0000000000..6496ee3253
--- /dev/null
+++ b/ext/opcache/tests/bug65915.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #65915 (Inconsistent results with require return value)
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$tmp = __DIR__ . "/bug65915.inc.php";
+
+file_put_contents($tmp, '<?php return function(){ return "a";};');
+$f = require $tmp;
+var_dump($f());
+
+opcache_invalidate($tmp, true);
+
+file_put_contents($tmp, '<?php return function(){ return "b";};');
+$f = require $tmp;
+var_dump($f());
+
+@unlink($tmp);
+?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index 894da63aaa..53a54b5100 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -835,7 +835,17 @@ static int zend_hash_unique_copy(HashTable *target, HashTable *source, unique_co
}
} else {
if (p->nKeyLength > 0 && p->arKey[0] == 0) {
- /* Mangled key, ignore and wait for runtime */
+ /* Mangled key */
+ if (((zend_function*)p->pData)->common.fn_flags & ZEND_ACC_CLOSURE) {
+ /* update closure */
+ if (zend_hash_quick_update(target, p->arKey, p->nKeyLength, p->h, p->pData, size, &t) == SUCCESS) {
+ if (pCopyConstructor) {
+ pCopyConstructor(t);
+ }
+ }
+ } else {
+ /* ignore and wait for runtime */
+ }
} else if (!ignore_dups && zend_hash_quick_find(target, p->arKey, p->nKeyLength, p->h, &t) == SUCCESS) {
*fail_data = p->pData;
*conflict_data = t;