Skip to content

Commit 7a10b97

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Add missing COMPILE_IGNORE_OTHER_FILES check for static calls
2 parents 1f8c899 + 3d86d9a commit 7a10b97

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

Zend/zend_compile.c

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4128,6 +4128,27 @@ static bool fbc_is_finalized(zend_function *fbc) {
41284128
return !ZEND_USER_CODE(fbc->type) || (fbc->common.fn_flags & ZEND_ACC_DONE_PASS_TWO);
41294129
}
41304130

4131+
static bool zend_compile_ignore_class(zend_class_entry *ce, zend_string *filename)
4132+
{
4133+
if (ce->type == ZEND_INTERNAL_CLASS) {
4134+
return CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES;
4135+
} else {
4136+
return (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES)
4137+
&& ce->info.user.filename != filename;
4138+
}
4139+
}
4140+
4141+
static bool zend_compile_ignore_function(zend_function *fbc, zend_string *filename)
4142+
{
4143+
if (fbc->type == ZEND_INTERNAL_FUNCTION) {
4144+
return CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS;
4145+
} else {
4146+
return (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS)
4147+
|| ((CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES)
4148+
&& fbc->op_array.filename != filename);
4149+
}
4150+
}
4151+
41314152
static zend_result zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t num_args) /* {{{ */
41324153
{
41334154
zend_string *name, *lcname;
@@ -4142,11 +4163,9 @@ static zend_result zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast,
41424163
lcname = zend_string_tolower(name);
41434164

41444165
fbc = zend_hash_find_ptr(CG(function_table), lcname);
4145-
if (!fbc || !fbc_is_finalized(fbc)
4146-
|| (fbc->type == ZEND_INTERNAL_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS))
4147-
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS))
4148-
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) && fbc->op_array.filename != CG(active_op_array)->filename)
4149-
) {
4166+
if (!fbc
4167+
|| !fbc_is_finalized(fbc)
4168+
|| zend_compile_ignore_function(fbc, CG(active_op_array)->filename)) {
41504169
zend_string_release_ex(lcname, 0);
41514170
return FAILURE;
41524171
}
@@ -4818,11 +4837,9 @@ static void zend_compile_call(znode *result, zend_ast *ast, uint32_t type) /* {{
48184837
return;
48194838
}
48204839

4821-
if (!fbc || !fbc_is_finalized(fbc)
4822-
|| (fbc->type == ZEND_INTERNAL_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS))
4823-
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS))
4824-
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) && fbc->op_array.filename != CG(active_op_array)->filename)
4825-
) {
4840+
if (!fbc
4841+
|| !fbc_is_finalized(fbc)
4842+
|| zend_compile_ignore_function(fbc, CG(active_op_array)->filename)) {
48264843
zend_string_release_ex(lcname, 0);
48274844
zend_compile_dynamic_call(result, &name_node, args_ast, ast->lineno);
48284845
return;
@@ -4995,7 +5012,11 @@ static void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type
49955012
if (opline->op1_type == IS_CONST) {
49965013
zend_string *lcname = Z_STR_P(CT_CONSTANT(opline->op1) + 1);
49975014
ce = zend_hash_find_ptr(CG(class_table), lcname);
4998-
if (!ce && CG(active_class_entry)
5015+
if (ce) {
5016+
if (zend_compile_ignore_class(ce, CG(active_op_array)->filename)) {
5017+
ce = NULL;
5018+
}
5019+
} else if (CG(active_class_entry)
49995020
&& zend_string_equals_ci(CG(active_class_entry)->name, lcname)) {
50005021
ce = CG(active_class_entry);
50015022
}
@@ -8390,9 +8411,7 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)
83908411
ce->parent_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
83918412

83928413
if (parent_ce
8393-
&& ((parent_ce->type != ZEND_INTERNAL_CLASS) || !(CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES))
8394-
&& ((parent_ce->type != ZEND_USER_CLASS) || !(CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) || (parent_ce->info.user.filename == ce->info.user.filename))) {
8395-
8414+
&& !zend_compile_ignore_class(parent_ce, ce->info.user.filename)) {
83968415
if (zend_try_early_bind(ce, parent_ce, lcname, NULL)) {
83978416
zend_string_release(lcname);
83988417
return;

0 commit comments

Comments
 (0)