php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34068 Numeric string as array key not cast to integer in wddx_deserialize()
Submitted: 2005-08-10 13:58 UTC Modified: 2005-08-11 00:43 UTC
From: clemens at gutweiler dot net Assigned:
Status: Closed Package: WDDX related
PHP Version: 5CVS-2005-08-10 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: clemens at gutweiler dot net
New email:
PHP Version: OS:

 

 [2005-08-10 13:58 UTC] clemens at gutweiler dot net
Description:
------------
The vartype of the 123 key changed after serialization, it should be consistent.


Reproduce code:
---------------
<?php
    
    $data = array(
        '123' => 'zahl',
        'Foo' => 'bar',
    );
    
    var_dump( $data );
    var_dump( wddx_deserialize( wddx_serialize_value( $data ) ) );
    
    highlight_file( __FILE__ );
?>



Expected result:
----------------
array(2) {
  ["123"]=>
  string(4) "zahl"
  ["Foo"]=>
  string(3) "bar"
}
array(2) {
  ["123"]=>
  string(4) "zahl"
  ["Foo"]=>
  string(3) "bar"
}


Actual result:
--------------
array(2) {
  [123]=>
  string(4) "zahl"
  ["Foo"]=>
  string(3) "bar"
}
array(2) {
  ["123"]=>
  string(4) "zahl"
  ["Foo"]=>
  string(3) "bar"
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-10 15:39 UTC] sniper@php.net
Actually it's not WDDX issue, but general issue with numeric array index not staying as string but getting silently changed to integer:

<?php

        $a = array ('123' => 'abc', 'abc' => '123');

        var_dump($a);
?>

Outputs:

array(2) {
  [123]=>
  string(3) "abc"
  ["abc"]=>
  string(3) "123"
}

Although this is pretty old issue, Dmitry, can you check?

 [2005-08-10 15:46 UTC] sniper@php.net
Nevermind that, we have it documented as expected behaviour. 
WDDX should really be consistent with how PHP handles this..

 [2005-08-11 00:43 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC