Bug #61527 [Opn->Csd]: ArrayIterator gives misleading notice on next() when moved to the end
| From: | stas@php.net | Date: | Sun, 15 Jul 2012 05:41:16 +0000 |
| Subject: | Bug #61527 [Opn->Csd]: ArrayIterator gives misleading notice on next() when moved to the end | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-171967@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61527&edit=1
ID: 61527
Updated by: stas@php.net
Reported by: gtisza at gmail dot com
Summary: ArrayIterator gives misleading notice on next() when
moved to the end
-Status: Open
+Status: Closed
Type: Bug
Package: SPL related
Operating System: Debian
PHP Version: 5.3.10
-Assigned To:
+Assigned To: stas
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
merged to 5.4
Previous Comments:
------------------------------------------------------------------------
[2012-07-15 05:35:49] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a5d45bae85bd75f0d57dfaf1d1c1b2b014e7949f
Log: Fixed bug #61527 (Recursive/ArrayIterator gives misleading notice when array empty or moved to
the end)
------------------------------------------------------------------------
[2012-04-05 18:12:52] reeze dot xia at gmail dot com
BTW:
I think "ArrayIterator gives misleading notice on manipulate empty or moved to
end array" will be a better title for the bug description, what do you think?
------------------------------------------------------------------------
[2012-04-05 17:46:42] reeze dot xia at gmail dot com
Hi, gtisza:
I have analyzed this misleading notice and found that it show misleading
notice when manipulate empty or move the end of array.
I made a pull request to show more meaningful notice instead of misleading
one.
here it is: https://github.com/php/php-src/pull/38
will someone review it for me?
Thanks.
------------------------------------------------------------------------
[2012-03-27 12:16:11] gtisza at gmail dot com
Description:
------------
When trying to iterate the ArrayIterator of an empty ArrayObject, it throws a very misleading notice
complaining about how the array was modified. In a complicated system, this will likely lead to a
long wild goose chase of trying to find all the possible places where the object could have been
accessed through some other iterator, when in reality the error is of a completely different nature.
Test script:
---------------
error_reporting(E_ALL);
$ao = new ArrayObject(array());
$ai = $ao->getIterator();
$ai->next();
Expected result:
----------------
$ai->next() returns null; no errors. (Or maybe a notice saying you reached the end of the array.)
Actual result:
--------------
$ai->next() returns null and throws a notice saying "ArrayIterator::next(): Array was
modified outside object and internal position is no longer valid".
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61527&edit=1