mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3'
* PHP-8.3: Add missing COMPILE_IGNORE_OTHER_FILES check for static calls
This commit is contained in:
@@ -4128,6 +4128,27 @@ static bool fbc_is_finalized(zend_function *fbc) {
|
||||
return !ZEND_USER_CODE(fbc->type) || (fbc->common.fn_flags & ZEND_ACC_DONE_PASS_TWO);
|
||||
}
|
||||
|
||||
static bool zend_compile_ignore_class(zend_class_entry *ce, zend_string *filename)
|
||||
{
|
||||
if (ce->type == ZEND_INTERNAL_CLASS) {
|
||||
return CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES;
|
||||
} else {
|
||||
return (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES)
|
||||
&& ce->info.user.filename != filename;
|
||||
}
|
||||
}
|
||||
|
||||
static bool zend_compile_ignore_function(zend_function *fbc, zend_string *filename)
|
||||
{
|
||||
if (fbc->type == ZEND_INTERNAL_FUNCTION) {
|
||||
return CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS;
|
||||
} else {
|
||||
return (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS)
|
||||
|| ((CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES)
|
||||
&& fbc->op_array.filename != filename);
|
||||
}
|
||||
}
|
||||
|
||||
static zend_result zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t num_args) /* {{{ */
|
||||
{
|
||||
zend_string *name, *lcname;
|
||||
@@ -4142,11 +4163,9 @@ static zend_result zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast,
|
||||
lcname = zend_string_tolower(name);
|
||||
|
||||
fbc = zend_hash_find_ptr(CG(function_table), lcname);
|
||||
if (!fbc || !fbc_is_finalized(fbc)
|
||||
|| (fbc->type == ZEND_INTERNAL_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS))
|
||||
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS))
|
||||
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) && fbc->op_array.filename != CG(active_op_array)->filename)
|
||||
) {
|
||||
if (!fbc
|
||||
|| !fbc_is_finalized(fbc)
|
||||
|| zend_compile_ignore_function(fbc, CG(active_op_array)->filename)) {
|
||||
zend_string_release_ex(lcname, 0);
|
||||
return FAILURE;
|
||||
}
|
||||
@@ -4818,11 +4837,9 @@ static void zend_compile_call(znode *result, zend_ast *ast, uint32_t type) /* {{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fbc || !fbc_is_finalized(fbc)
|
||||
|| (fbc->type == ZEND_INTERNAL_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS))
|
||||
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS))
|
||||
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) && fbc->op_array.filename != CG(active_op_array)->filename)
|
||||
) {
|
||||
if (!fbc
|
||||
|| !fbc_is_finalized(fbc)
|
||||
|| zend_compile_ignore_function(fbc, CG(active_op_array)->filename)) {
|
||||
zend_string_release_ex(lcname, 0);
|
||||
zend_compile_dynamic_call(result, &name_node, args_ast, ast->lineno);
|
||||
return;
|
||||
@@ -4995,7 +5012,11 @@ static void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type
|
||||
if (opline->op1_type == IS_CONST) {
|
||||
zend_string *lcname = Z_STR_P(CT_CONSTANT(opline->op1) + 1);
|
||||
ce = zend_hash_find_ptr(CG(class_table), lcname);
|
||||
if (!ce && CG(active_class_entry)
|
||||
if (ce) {
|
||||
if (zend_compile_ignore_class(ce, CG(active_op_array)->filename)) {
|
||||
ce = NULL;
|
||||
}
|
||||
} else if (CG(active_class_entry)
|
||||
&& zend_string_equals_ci(CG(active_class_entry)->name, lcname)) {
|
||||
ce = CG(active_class_entry);
|
||||
}
|
||||
@@ -8390,9 +8411,7 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)
|
||||
ce->parent_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
|
||||
|
||||
if (parent_ce
|
||||
&& ((parent_ce->type != ZEND_INTERNAL_CLASS) || !(CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES))
|
||||
&& ((parent_ce->type != ZEND_USER_CLASS) || !(CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) || (parent_ce->info.user.filename == ce->info.user.filename))) {
|
||||
|
||||
&& !zend_compile_ignore_class(parent_ce, ce->info.user.filename)) {
|
||||
if (zend_try_early_bind(ce, parent_ce, lcname, NULL)) {
|
||||
zend_string_release(lcname);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user