php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73998 array_key_exists fails on arrays created by get_object_vars
Submitted: 2017-01-25 19:05 UTC Modified: 2017-03-17 16:52 UTC
From: Hauke dot Jensen at volz-software dot de Assigned: nikic
Status: Closed Package: Arrays related
PHP Version: 7.0.0 OS: Linux
Private report: No CVE-ID:
 [2017-01-25 19:05 UTC] Hauke dot Jensen at volz-software dot de
Description:
------------
array_key_exists fails on arrays created by get_object_vars on Objects with numeric Propertie Names.
It works fine in the old PHP 5.3 enviroment.

Test script:
---------------
$json = '{"100308":1}';
$temp = json_decode($json);
$sub = get_object_vars($temp); // Error Array
var_dump($sub, array_key_exists('100308', $sub));

Expected result:
----------------
array(1) {
  [100308]=>
  int(1)
}
bool(true)

Actual result:
--------------
array(1) {
  ["100308"]=>
  int(1)
}
bool(false)

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-27 18:48 UTC] cmb@php.net
-Status: Open +Status: Verified -PHP Version: 7.1.1 +PHP Version: 7.0.0
 [2017-01-27 18:48 UTC] cmb@php.net
Confirmed: <https://3v4l.org/vZbPc>.
 [2017-02-02 17:43 UTC] nikic@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: nikic
 [2017-03-17 16:35 UTC] ajf@php.net
Uhm: https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts

Did we just backport an RFC-agreed change from 7.2 to a 7.1 patch release?
 [2017-03-17 16:52 UTC] nikic@php.net
No, we fixed a PHP 7 regression.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC