Skip to content

Commit

Permalink
Fixed bug #81377
Browse files Browse the repository at this point in the history
BP_VAR_UNSET should not result in undefined warnings.
  • Loading branch information
nikic committed Aug 24, 2021
1 parent be50786 commit a40ccd7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.1.0RC1

- Core:
. Fixed bug #81377 (unset() of $GLOBALS sub-key yields warning). (Nikita)

- COM:
. Dispatch using LANG_NEUTRAL instead of LOCALE_SYSTEM_DEFAULT. (Dmitry
Maksimov)
Expand Down
11 changes: 11 additions & 0 deletions Zend/tests/bug81377.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Bug #81377: unset() of $GLOBALS sub-key yields warning
--FILE--
<?php

unset($GLOBALS['foo']['bar']);

?>
===DONE==
--EXPECT--
===DONE==
4 changes: 2 additions & 2 deletions Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ ZEND_VM_C_LABEL(fetch_this):
}
if (type == BP_VAR_W) {
retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval));
} else if (type == BP_VAR_IS) {
} else if (type == BP_VAR_IS || type == BP_VAR_UNSET) {
retval = &EG(uninitialized_zval);
} else {
zend_error(E_WARNING, "Undefined %svariable $%s",
Expand All @@ -1750,7 +1750,7 @@ ZEND_VM_C_LABEL(fetch_this):
}
if (type == BP_VAR_W) {
ZVAL_NULL(retval);
} else if (type == BP_VAR_IS) {
} else if (type == BP_VAR_IS || type == BP_VAR_UNSET) {
retval = &EG(uninitialized_zval);
} else {
zend_error(E_WARNING, "Undefined %svariable $%s",
Expand Down
12 changes: 6 additions & 6 deletions Zend/zend_vm_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -9690,7 +9690,7 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_ad
}
if (type == BP_VAR_W) {
retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval));
} else if (type == BP_VAR_IS) {
} else if (type == BP_VAR_IS || type == BP_VAR_UNSET) {
retval = &EG(uninitialized_zval);
} else {
zend_error(E_WARNING, "Undefined %svariable $%s",
Expand All @@ -9710,7 +9710,7 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_ad
}
if (type == BP_VAR_W) {
ZVAL_NULL(retval);
} else if (type == BP_VAR_IS) {
} else if (type == BP_VAR_IS || type == BP_VAR_UNSET) {
retval = &EG(uninitialized_zval);
} else {
zend_error(E_WARNING, "Undefined %svariable $%s",
Expand Down Expand Up @@ -17522,7 +17522,7 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_ad
}
if (type == BP_VAR_W) {
retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval));
} else if (type == BP_VAR_IS) {
} else if (type == BP_VAR_IS || type == BP_VAR_UNSET) {
retval = &EG(uninitialized_zval);
} else {
zend_error(E_WARNING, "Undefined %svariable $%s",
Expand All @@ -17542,7 +17542,7 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_ad
}
if (type == BP_VAR_W) {
ZVAL_NULL(retval);
} else if (type == BP_VAR_IS) {
} else if (type == BP_VAR_IS || type == BP_VAR_UNSET) {
retval = &EG(uninitialized_zval);
} else {
zend_error(E_WARNING, "Undefined %svariable $%s",
Expand Down Expand Up @@ -45966,7 +45966,7 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_ad
}
if (type == BP_VAR_W) {
retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval));
} else if (type == BP_VAR_IS) {
} else if (type == BP_VAR_IS || type == BP_VAR_UNSET) {
retval = &EG(uninitialized_zval);
} else {
zend_error(E_WARNING, "Undefined %svariable $%s",
Expand All @@ -45986,7 +45986,7 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_ad
}
if (type == BP_VAR_W) {
ZVAL_NULL(retval);
} else if (type == BP_VAR_IS) {
} else if (type == BP_VAR_IS || type == BP_VAR_UNSET) {
retval = &EG(uninitialized_zval);
} else {
zend_error(E_WARNING, "Undefined %svariable $%s",
Expand Down

0 comments on commit a40ccd7

Please sign in to comment.