php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77115 The array contains 2 identical keys
Submitted: 2018-11-06 12:56 UTC Modified: 2021-07-23 10:10 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: boris at korobkov dot su Assigned: nikic (profile)
Status: Closed Package: Arrays related
PHP Version: 7.0.32 OS: Ubuntu
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: boris at korobkov dot su
New email:
PHP Version: OS:

 

 [2018-11-06 12:56 UTC] 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) {
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-06 13:04 UTC] 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 13:37 UTC] bwoebi@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: bwoebi
 [2018-11-06 13:37 UTC] bwoebi@php.net
-Status: Closed +Status: Re-Opened -Assigned To: bwoebi +Assigned To:
 [2018-11-06 13:37 UTC] bwoebi@php.net
Eih, yeah, backporting is possibly a good idea.
 [2018-11-06 13:50 UTC] nikic@php.net
@bwoebi: I don't think we'll want to backport the fix for dynamic properties as it's more intrusive, but the one for declared properties should be relatively self-contained.
 [2021-07-23 10:10 UTC] nikic@php.net
-Status: Re-Opened +Status: Closed -Assigned To: +Assigned To: nikic
 [2021-07-23 10:10 UTC] nikic@php.net
Looks like the backport here never happened, and the affected versions are no longer supported.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 16:01:29 2024 UTC