[php-src] PHP-8.3: Merge branch 'PHP-8.2' into PHP-8.3
| From: | Ilija Tovilo | Date: | Wed, 17 Apr 2024 20:41:10 +0000 |
| Subject: | [php-src] PHP-8.3: Merge branch 'PHP-8.2' into PHP-8.3 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-128149@lists.php.net to get a copy of this message | ||
Author: Ilija Tovilo (iluuu1994)
Date: 2024-04-17T22:39:48+02:00
Commit: https://github.com/php/php-src/commit/3d86d9acc1cd9e7ab499453a6aacbe1563d0dafc
Raw diff: https://github.com/php/php-src/commit/3d86d9acc1cd9e7ab499453a6aacbe1563d0dafc.diff
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
Add missing COMPILE_IGNORE_OTHER_FILES check for static calls
Changed paths:
M NEWS
M Zend/zend_compile.c
Diff:
diff --git a/NEWS b/NEWS
index 83ce8c08a96f4..be3b6cfbe9ed0 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,8 @@ PHP NEWS
- Opcache:
. Fixed bug GH-13433 (Segmentation Fault in zend_class_init_statics when
using opcache.preload). (nielsdos)
+ . Fixed incorrect assumptions across compilation units for static calls.
+ (ilutov)
- OpenSSL:
. Fixed bug GH-10495 (feof on OpenSSL stream hangs indefinitely).
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 1078dd1d20a2a..33c15f00b339c 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4118,6 +4118,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;
@@ -4132,11 +4153,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;
}
@@ -4646,11 +4665,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;
@@ -4817,7 +4834,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);
}
@@ -8162,9 +8183,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;