Bug #77115 [Csd->ReO]: The array contains 2 identical keys

From: Date: Tue, 06 Nov 2018 13:37:54 +0000
Subject: Bug #77115 [Csd->ReO]: The array contains 2 identical keys
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217844@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77115&edit=1

 ID:                 77115
 Updated by:         bwoebi@php.net
 Reported by:        boris at korobkov dot su
 Summary:            The array contains 2 identical keys
-Status:             Closed
+Status:             Re-Opened
 Type:               Bug
 Package:            Arrays related
 Operating System:   Ubuntu
 PHP Version:        7.0.32
-Assigned To:        bwoebi
+Assigned To:        
 Block user comment: N
 Private report:     N

 New Comment:

Eih, yeah, backporting is possibly a good idea.


Previous Comments:
------------------------------------------------------------------------
[2018-11-06 13:37:25] bwoebi@php.net

This is already fixed on master:
http://git.php.net/?p=php-src.git;a=commitdiff;h=149e6aaa99cf9b94987fe23b999443ca56db1caf

------------------------------------------------------------------------
[2018-11-06 13:04:01] nikic@php.net

I've fixed this issue for PHP 7.4 some time ago via https://github.com/php/php-src/commit/4d5d77904e9e4dc52236ec5416d1ddfef9b3911c#diff-5d1661cc2ad170dc8bbe40c80ae75b85.
I guess we'll have to backport it now :)

------------------------------------------------------------------------
[2018-11-06 12:56:25] boris at korobkov dot su

Description:
------------
The array contains 2 identical keys.
Reproduced in all PHP 7.*.
Not reproduced in PHP 5.6.

Test script:
---------------
<?php

class A {
    private $foo = 'fooA';
    public function dump() { return get_object_vars($this); }
}

class B extends A {
    public $foo = 'fooB';
}

$b = new B();
$object_vars = $b->dump();
var_dump($object_vars);

unset($object_vars['foo']);
var_dump($object_vars);

unset($object_vars['foo']);
var_dump($object_vars);

Expected result:
----------------
The array contains unique keys only.

Actual result:
--------------
array(2) {
  ["foo"]=>
  string(4) "fooB"
  ["foo"]=>
  string(4) "fooA"
}

array(1) {
  ["foo"]=>
  string(4) "fooB"
}

array(0) {
}


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



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


Thread (6 messages)

« previous php.bugs (#217844) next »