php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69335 SplArray BC break
Submitted: 2015-03-31 03:52 UTC Modified: 2017-09-12 14:29 UTC
From: laruence@php.net Assigned: laruence (profile)
Status: Suspended Package: SPL related
PHP Version: master-Git-2015-03-31 (snap) OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-03-31 03:52 UTC] laruence@php.net
Description:
------------
with the new Hashtable implementation..

follows script doesn't works as before:


anyway, I don't see a good way to fix it (using HashTableIterator is expensive here, and may introduce performance issue for later foreach calls)

I'd like add a test script, and mark it as XFAIL, linked to this entry.

Test script:
---------------
<?php
$a = array(1=>1, 3=>3, 5=>5, 7=>7);
$a = new ArrayObject($a);

foreach ($a as $k => $v) {
    var_dump("$k => $v");
    if ($k == 3) {
        $a['a'] = "?";
    }
}
?>

Expected result:
----------------
string(6) "1 => 1"
string(6) "3 => 3"
string(6) "5 => 5"
string(6) "7 => 7"
string(6) "a => ?"

Actual result:
--------------
string(6) "1 => 1"
string(6) "3 => 3"
PHP Notice:  main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in /tmp/1.php on line 5

Notice: main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in /tmp/1.php on line 5
string(6) "1 => 1"
string(6) "3 => 3"
string(6) "5 => 5"
string(6) "7 => 7"
string(6) "a => ?"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-31 04:32 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2015-04-01 03:23 UTC] laruence@php.net
-Status: Assigned +Status: Suspended
 [2015-04-01 03:23 UTC] laruence@php.net
marked as suspend for now
 [2017-09-12 14:29 UTC] cmb@php.net
This issue appears to have been fixed, see
<https://3v4l.org/vP95o>.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC