Skip to content

Commit 7dc3a12

Browse files
committed
Test ZEND_ACC_NEVER_CACHE behavior
1 parent ed2c408 commit 7dc3a12

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Inline cache can not be used for ZEND_ACC_NEVER_CACHE functions
3+
--FILE--
4+
<?php
5+
6+
$fns = [
7+
'return function ($x) { var_dump("A"); };',
8+
'return function ($x) { var_dump("B"); };',
9+
];
10+
11+
function f($f) {
12+
$f(0);
13+
}
14+
15+
foreach ($fns as $f) {
16+
f(eval($f));
17+
}
18+
19+
foreach ($fns as $f) {
20+
$f = eval($f);
21+
// Closure::__invoke() is ZEND_ACC_NEVER_CACHE
22+
f($f->__invoke(?));
23+
}
24+
25+
?>
26+
--EXPECT--
27+
string(1) "A"
28+
string(1) "B"
29+
string(1) "A"
30+
string(1) "B"

Zend/zend_partial.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ static const zend_op_array *zp_get_op_array(zval *this_ptr, zend_function *funct
10541054
if (EXPECTED(function->type == ZEND_INTERNAL_FUNCTION
10551055
? cache_slot[0] == function
10561056
: cache_slot[0] == function->op_array.opcodes)) {
1057+
ZEND_ASSERT(!(function->common.fn_flags & ZEND_ACC_NEVER_CACHE));
10571058
return cache_slot[1];
10581059
}
10591060

0 commit comments

Comments
 (0)