Skip to content

Commit 69efeb1

Browse files
committed
Fix constant expr coaleasce with protected mode opcache
1 parent 5053fc0 commit 69efeb1

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

Zend/zend_ast.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -338,21 +338,13 @@ ZEND_API int zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *sc
338338
}
339339
break;
340340
case ZEND_AST_COALESCE:
341-
if (ast->child[0]->kind == ZEND_AST_DIM) {
342-
ast->child[0]->attr = ZEND_DIM_IS;
343-
}
344-
345341
if (UNEXPECTED(zend_ast_evaluate(&op1, ast->child[0], scope) != SUCCESS)) {
346342
ret = FAILURE;
347343
break;
348344
}
349345
if (Z_TYPE(op1) > IS_NULL) {
350346
*result = op1;
351347
} else {
352-
if (ast->child[1]->kind == ZEND_AST_DIM) {
353-
ast->child[1]->attr = ZEND_DIM_IS;
354-
}
355-
356348
if (UNEXPECTED(zend_ast_evaluate(result, ast->child[1], scope) != SUCCESS)) {
357349
zval_dtor(&op1);
358350
ret = FAILURE;
@@ -413,10 +405,6 @@ ZEND_API int zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *sc
413405
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use [] for reading");
414406
}
415407

416-
if (ast->attr == ZEND_DIM_IS && ast->child[0]->kind == ZEND_AST_DIM) {
417-
ast->child[0]->attr = ZEND_DIM_IS;
418-
}
419-
420408
if (UNEXPECTED(zend_ast_evaluate(&op1, ast->child[0], scope) != SUCCESS)) {
421409
ret = FAILURE;
422410
} else if (UNEXPECTED(zend_ast_evaluate(&op2, ast->child[1], scope) != SUCCESS)) {

Zend/zend_compile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7388,6 +7388,10 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
73887388
zend_ct_eval_unary_pm(&result, ast->kind, zend_ast_get_zval(ast->child[0]));
73897389
break;
73907390
case ZEND_AST_COALESCE:
7391+
/* Set isset fetch indicator here, opcache disallows runtime altering of the AST */
7392+
if (ast->child[0]->kind == ZEND_AST_DIM) {
7393+
ast->child[0]->attr = ZEND_DIM_IS;
7394+
}
73917395
zend_eval_const_expr(&ast->child[0]);
73927396

73937397
if (ast->child[0]->kind != ZEND_AST_ZVAL) {
@@ -7440,6 +7444,11 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
74407444
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use [] for reading");
74417445
}
74427446

7447+
/* Set isset fetch indicator here, opcache disallows runtime altering of the AST */
7448+
if (ast->attr == ZEND_DIM_IS && ast->child[0]->kind == ZEND_AST_DIM) {
7449+
ast->child[0]->attr = ZEND_DIM_IS;
7450+
}
7451+
74437452
zend_eval_const_expr(&ast->child[0]);
74447453
zend_eval_const_expr(&ast->child[1]);
74457454
if (ast->child[0]->kind != ZEND_AST_ZVAL || ast->child[1]->kind != ZEND_AST_ZVAL) {

0 commit comments

Comments
 (0)