ID:               42316
 User updated by:  titerm at lfdj dot com
 Reported By:      titerm at lfdj dot com
 Status:           Bogus
 Bug Type:         SPL related
 Operating System: Windows
-PHP Version:      5.2.3
+PHP Version:      5.2.4RC3-dev
 New Comment:

I finally download snap.
This snapshot was automatically generated on
Fri, 17 Aug 2007 00:08:51 -0400

Version: 5.2.4RC3-dev
Branch: HEAD
Build: Release_TS

The bug is still there. Take a look to the added dump of $data. $data
is altered to. This can't be the expected result. $data is never used as
reference.

Reproduce code
$data[] = 'ORG';
$arr1 = array ('branch1' => $data, 'branch2' => $data);

$iterator = new ArrayIterator($arr1['branch1']);;
$iterator->offSetSet($iterator->key(), 'ALTER' );

var_dump($arr1);
var_dump($data);

Actual result.
array(2) {
  ["branch1"]=>
  array(1) {
    [0]=>
    string(5) "ALTER"
  }
  ["branch2"]=>
  array(1) {
    [0]=>
    string(5) "ALTER"
  }
}
array(1) {
  [0]=>
  string(5) "ALTER"
}


Previous Comments:
------------------------------------------------------------------------

[2007-08-17 05:26:41] titerm at lfdj dot com

I can't access to cvs or svn through my company's firewall.
I see  there is a zip with snaps for windows but the download server is
currently offline for maintenance.

Anyway, with the result you gave me, 'ORG' on both branch, the problem
is not solve for me. ArrayIterator should be able to modify the array.
And at least, it has always been able too until now.

------------------------------------------------------------------------

[2007-08-17 00:58:18] [EMAIL PROTECTED]

But I'm using latest CVS. Perhaps you should have tried it too before
reporting already fixed bug.

------------------------------------------------------------------------

[2007-08-16 14:07:40] titerm at lfdj dot com

I did my test on 5.2.3 release on window and solaris.
I don't understand why you say original array is not modified since i'm
using offsetSet function, it should modified $arr and it does.

If i init $arr with $data1 and $data2 like this, only branch one is
altered.

$data1['one'] = 'ORG';
$data2['one'] = 'ORG';
$arr = array (
        'branch1' => $data1,
        'branch2' => $data2,
);

------------------------------------------------------------------------

[2007-08-16 13:47:51] [EMAIL PROTECTED]

Since the iterator does not modify original array, this is the expected
result of your script (and what I get using latest CVS build):

array(2) {
  ["branch1"]=>
  array(1) {
    ["one"]=>
    string(3) "ORG"
  }
  ["branch2"]=>
  array(1) {
    ["one"]=>
    string(3) "ORG"
  }
}


------------------------------------------------------------------------

[2007-08-16 12:11:48] titerm at lfdj dot com

Create a ArrayIterator on branch1. Alter the leaf by using iterator.
Leave on branch2 are affected too.

Simplified reproduce code.

$data['one'] = 'ORG';
$arr = array (
        'branch1' => $data,
        'branch2' => $data,
);
$iterator = new ArrayIterator($arr['branch1']);;
$iterator->offSetSet($iterator->key(), 'ALTER' );
var_dump($arr);

Expected result
array
  'branch1' => 
    array
      'one' => string 'ALTER' (length=5)
  'branch2' => 
    array
      'one' => string 'ORG' (length=3)


Actual result
array
  'branch1' => 
    array
      'one' => string 'ALTER' (length=5)
  'branch2' => 
    array
      'one' => string 'ALTER' (length=5)

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/42316

-- 
Edit this bug report at http://bugs.php.net/?id=42316&edit=1

Reply via email to