Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Zend/tests/partial_application/default_const_expr_shm.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
PFA: default value AST of an SHM-persisted partial
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.file_update_protection=0
--FILE--
<?php

// parse_ini_string() has a $scanner_mode param that defaults to INI_SCANNER_NORMAL,
// which is an IS_CONSTANT_AST.
$p = parse_ini_string(?, ...);
var_dump($p("a=1"));

$param = (new ReflectionFunction($p))->getParameters()[2];
var_dump($param->getDefaultValue());

?>
--EXPECT--
array(1) {
["a"]=>
string(1) "1"
}
int(0)
3 changes: 1 addition & 2 deletions Zend/zend_partial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,11 +1011,10 @@ static zend_op_array *zp_compile(zval *this_ptr, zend_function *function,
}
#endif

/* Takes ownership of closure_ast */
op_array = zend_accel_compile_pfa(closure_ast, declaring_filename,
declaring_lineno_ptr, function, pfa_name, flags & ZEND_PARTIAL_CACHEABLE_IN_SHM);

zend_ast_destroy(closure_ast);

clean:
zp_names_dtor(var_names, argc);
zend_arena_destroy(CG(ast_arena));
Expand Down
2 changes: 2 additions & 0 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,8 @@ zend_op_array *zend_accel_compile_pfa(zend_ast *ast,
zend_bailout();
} zend_end_try();

zend_ast_destroy(ast);

ZEND_ASSERT(op_array->num_dynamic_func_defs == 1);

zend_string_release(op_array->dynamic_func_defs[0]->function_name);
Expand Down
1 change: 1 addition & 0 deletions ext/opcache/ZendAccelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ uint32_t zend_accel_get_class_name_map_ptr(zend_string *type_name);
const zend_op_array *zend_accel_pfa_cache_get(
const uint32_t *declaring_lineno_ptr, const zend_function *called_function, bool cacheable_in_shm);

/* Compiles ast into an op_array, and caches it. Takes ownership of ast. */
zend_op_array *zend_accel_compile_pfa(zend_ast *ast,
zend_string *declaring_filename,
const uint32_t *declaring_lineno_ptr,
Expand Down
Loading