From a40ccd758cb856bb4a175e0e025113ea7e9de50a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 24 Aug 2021 15:05:53 +0200 Subject: [PATCH] Fixed bug #81377 BP_VAR_UNSET should not result in undefined warnings. --- NEWS | 3 +++ Zend/tests/bug81377.phpt | 11 +++++++++++ Zend/zend_vm_def.h | 4 ++-- Zend/zend_vm_execute.h | 12 ++++++------ 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 Zend/tests/bug81377.phpt diff --git a/NEWS b/NEWS index 15724d2035a..bbb61e29e88 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/Zend/tests/bug81377.phpt b/Zend/tests/bug81377.phpt new file mode 100644 index 00000000000..e8f36a2fb54 --- /dev/null +++ b/Zend/tests/bug81377.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #81377: unset() of $GLOBALS sub-key yields warning +--FILE-- + +===DONE== +--EXPECT-- +===DONE== diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index eb27187be08..38619d94d80 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -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", @@ -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", diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 3c705c1fff1..55e86737d5a 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -9690,7 +9690,7 @@ 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", @@ -9710,7 +9710,7 @@ 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", @@ -17522,7 +17522,7 @@ 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", @@ -17542,7 +17542,7 @@ 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", @@ -45966,7 +45966,7 @@ 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", @@ -45986,7 +45986,7 @@ 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",