|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80945 "Notice: Undefined index" on unset() ArrayObject non-existing key
Submitted: 2021-04-09 14:04 UTC Modified: 2021-05-05 15:13 UTC
From: php at yopmail dot com Assigned:
Status: Closed Package: SPL related
PHP Version: 7.4.16 OS:
Private report: No CVE-ID: None
 [2021-04-09 14:04 UTC] php at yopmail dot com
Unsetting a non-existing key on an ArrayObject triggers a notice (even a warning in PHP 8),
while it doesn't on an array.

More complete example:

Test script:

$arr = array();

$obj = new ArrayObject();

Expected result:

Actual result:
Notice: Undefined index: nonexisting_2 in [...] on line 7


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-05 14:35 UTC]
-Type: Bug +Type: Documentation Problem
 [2021-05-05 14:35 UTC]
These notices/warnings look intentional[1].  Changing to doc

[1] <>
 [2021-05-05 15:13 UTC]
-Type: Documentation Problem +Type: Bug
 [2021-05-05 15:13 UTC]
I think we do try to match behavior between array and ArrayObject, so I'd personally drop the warning in the implementation.
 [2021-06-14 08:15 UTC]
Automatic comment on behalf of nikic
Log: Fix bug #80945: Don't throw undefined array key warning in ArrayObject unset()
 [2021-06-14 08:15 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 22 22:01:32 2024 UTC