Skip to content

Commit 5249993

Browse files
committed
Fixed bug #78747
1 parent 8daf96c commit 5249993

File tree

4 files changed

+42
-13
lines changed

4 files changed

+42
-13
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ PHP NEWS
1919
- OpCache:
2020
. Fixed bug #78654 (Incorrectly computed opcache checksum on files with
2121
non-ascii characters). (mhagstrand)
22+
. Fixed bug #78747 (OpCache corrupts custom extension result). (Nikita)
2223

2324
- Reflection:
2425
. Fixed bug #78697 (ReflectionClass::ImplementsInterface - inaccurate error

ext/opcache/Optimizer/zend_func_info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ uint32_t zend_get_func_info(const zend_call_info *call_info, const zend_ssa *ssa
12151215
if (call_info->callee_func->type == ZEND_INTERNAL_FUNCTION) {
12161216
func_info_t *info;
12171217

1218-
if ((info = zend_hash_find_ptr(&func_info, Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline->op2, ssa->rt_constants)))) != NULL) {
1218+
if (!call_info->callee_func->common.scope && (info = zend_hash_find_ptr(&func_info, Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline->op2, ssa->rt_constants)))) != NULL) {
12191219
if (UNEXPECTED(zend_optimizer_is_disabled_func(info->name, info->name_len))) {
12201220
ret = MAY_BE_NULL;
12211221
} else if (info->info_func) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Internal static methods should not be confused with global functions
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('zend-test')) die('skip requires zend-test');
6+
?>
7+
--FILE--
8+
<?php
9+
10+
var_dump(is_bool(_ZendTestClass::is_object()));
11+
12+
?>
13+
--EXPECT--
14+
bool(false)

ext/zend_test/test.c

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,20 @@ static zend_function *zend_test_class_method_get(zend_object **object, zend_stri
149149
/* }}} */
150150

151151
static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, zend_string *name) /* {{{ */ {
152-
zend_internal_function *fptr = emalloc(sizeof(zend_internal_function));
153-
fptr->type = ZEND_OVERLOADED_FUNCTION;
154-
fptr->num_args = 1;
155-
fptr->arg_info = NULL;
156-
fptr->scope = ce;
157-
fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC;
158-
fptr->function_name = name;
159-
fptr->handler = ZEND_FN(zend_test_func);
160-
zend_set_function_arg_flags((zend_function*)fptr);
161-
162-
return (zend_function*)fptr;
152+
if (zend_string_equals_literal_ci(name, "test")) {
153+
zend_internal_function *fptr = emalloc(sizeof(zend_internal_function));
154+
fptr->type = ZEND_OVERLOADED_FUNCTION;
155+
fptr->num_args = 1;
156+
fptr->arg_info = NULL;
157+
fptr->scope = ce;
158+
fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC;
159+
fptr->function_name = name;
160+
fptr->handler = ZEND_FN(zend_test_func);
161+
zend_set_function_arg_flags((zend_function*)fptr);
162+
163+
return (zend_function*)fptr;
164+
}
165+
return zend_std_get_static_method(ce, name, NULL);
163166
}
164167
/* }}} */
165168

@@ -169,11 +172,22 @@ static int zend_test_class_call_method(zend_string *method, zend_object *object,
169172
}
170173
/* }}} */
171174

175+
/* Internal function returns bool, we return int. */
176+
static ZEND_METHOD(_ZendTestClass, is_object) /* {{{ */ {
177+
RETURN_LONG(42);
178+
}
179+
/* }}} */
180+
172181
static ZEND_METHOD(_ZendTestTrait, testMethod) /* {{{ */ {
173182
RETURN_TRUE;
174183
}
175184
/* }}} */
176185

186+
static const zend_function_entry zend_test_class_methods[] = {
187+
ZEND_ME(_ZendTestClass, is_object, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
188+
ZEND_FE_END
189+
};
190+
177191
static zend_function_entry zend_test_trait_methods[] = {
178192
ZEND_ME(_ZendTestTrait, testMethod, NULL, ZEND_ACC_PUBLIC)
179193
ZEND_FE_END
@@ -186,7 +200,7 @@ PHP_MINIT_FUNCTION(zend_test)
186200
INIT_CLASS_ENTRY(class_entry, "_ZendTestInterface", NULL);
187201
zend_test_interface = zend_register_internal_interface(&class_entry);
188202
zend_declare_class_constant_long(zend_test_interface, ZEND_STRL("DUMMY"), 0);
189-
INIT_CLASS_ENTRY(class_entry, "_ZendTestClass", NULL);
203+
INIT_CLASS_ENTRY(class_entry, "_ZendTestClass", zend_test_class_methods);
190204
zend_test_class = zend_register_internal_class_ex(&class_entry, NULL);
191205
zend_class_implements(zend_test_class, 1, zend_test_interface);
192206
zend_test_class->create_object = zend_test_class_new;

0 commit comments

Comments
 (0)