Skip to content

Commit 11d1f23

Browse files
committed
Add missing COMPILE_IGNORE_OTHER_FILES check for static calls
1 parent c3acfb1 commit 11d1f23

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
@@ -3996,6 +3996,27 @@ static bool fbc_is_finalized(zend_function *fbc) {
39963996
return !ZEND_USER_CODE(fbc->type) || (fbc->common.fn_flags & ZEND_ACC_DONE_PASS_TWO);
39973997
}
39983998

3999+
static bool zend_compile_ignore_class(zend_class_entry *ce, zend_string *filename)
4000+
{
4001+
if (ce->type == ZEND_INTERNAL_CLASS) {
4002+
return CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES;
4003+
} else {
4004+
return (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES)
4005+
&& ce->info.user.filename != filename;
4006+
}
4007+
}
4008+
4009+
static bool zend_compile_ignore_function(zend_function *fbc, zend_string *filename)
4010+
{
4011+
if (fbc->type == ZEND_INTERNAL_FUNCTION) {
4012+
return CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS;
4013+
} else {
4014+
return (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS)
4015+
|| ((CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES)
4016+
&& fbc->op_array.filename != filename);
4017+
}
4018+
}
4019+
39994020
static zend_result zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t num_args) /* {{{ */
40004021
{
40014022
zend_string *name, *lcname;
@@ -4010,11 +4031,9 @@ static zend_result zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast,
40104031
lcname = zend_string_tolower(name);
40114032

40124033
fbc = zend_hash_find_ptr(CG(function_table), lcname);
4013-
if (!fbc || !fbc_is_finalized(fbc)
4014-
|| (fbc->type == ZEND_INTERNAL_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS))
4015-
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS))
4016-
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) && fbc->op_array.filename != CG(active_op_array)->filename)
4017-
) {
4034+
if (!fbc
4035+
|| !fbc_is_finalized(fbc)
4036+
|| zend_compile_ignore_function(fbc, CG(active_op_array)->filename)) {
40184037
zend_string_release_ex(lcname, 0);
40194038
return FAILURE;
40204039
}
@@ -4538,11 +4557,9 @@ static void zend_compile_call(znode *result, zend_ast *ast, uint32_t type) /* {{
45384557
return;
45394558
}
45404559

4541-
if (!fbc || !fbc_is_finalized(fbc)
4542-
|| (fbc->type == ZEND_INTERNAL_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS))
4543-
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS))
4544-
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) && fbc->op_array.filename != CG(active_op_array)->filename)
4545-
) {
4560+
if (!fbc
4561+
|| !fbc_is_finalized(fbc)
4562+
|| zend_compile_ignore_function(fbc, CG(active_op_array)->filename)) {
45464563
zend_string_release_ex(lcname, 0);
45474564
zend_compile_dynamic_call(result, &name_node, args_ast, ast->lineno);
45484565
return;
@@ -4709,7 +4726,11 @@ static void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type
47094726
if (opline->op1_type == IS_CONST) {
47104727
zend_string *lcname = Z_STR_P(CT_CONSTANT(opline->op1) + 1);
47114728
ce = zend_hash_find_ptr(CG(class_table), lcname);
4712-
if (!ce && CG(active_class_entry)
4729+
if (ce) {
4730+
if (zend_compile_ignore_class(ce, CG(active_op_array)->filename)) {
4731+
ce = NULL;
4732+
}
4733+
} else if (CG(active_class_entry)
47134734
&& zend_string_equals_ci(CG(active_class_entry)->name, lcname)) {
47144735
ce = CG(active_class_entry);
47154736
}
@@ -7990,9 +8011,7 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)
79908011
ce->parent_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
79918012

79928013
if (parent_ce
7993-
&& ((parent_ce->type != ZEND_INTERNAL_CLASS) || !(CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES))
7994-
&& ((parent_ce->type != ZEND_USER_CLASS) || !(CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) || (parent_ce->info.user.filename == ce->info.user.filename))) {
7995-
8014+
&& !zend_compile_ignore_class(parent_ce, ce->info.user.filename)) {
79968015
if (zend_try_early_bind(ce, parent_ce, lcname, NULL)) {
79978016
zend_string_release(lcname);
79988017
return;

0 commit comments

Comments
 (0)