php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52963 var_export -1 array index outputs incorrectly
Submitted: 2010-10-01 04:35 UTC Modified: 2010-10-01 04:40 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kym at ausphotography dot net dot au Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.14 OS: Linux Centos 5.5
Private report: No CVE-ID: None
 [2010-10-01 04:35 UTC] kym at ausphotography dot net dot au
Description:
------------
Function var_export appears to not handle -ve array indexes and outputs the unsigned value.

Sample below.

This is on a standard Linux hosted service.


Test script:
---------------
<?php
$stylecache = array ( 
-1 => array 
( 1 => array 
( 0 => array ( 'styleid' => '19', 'title' => 'vB4 efault Style', 'parentid' => '-1', 'displayorder' => '1', 'userselect' => '1',  ),  ), ),
 19 => array (
 2 =>  array (  0 =>   array (  'styleid' => '20',  'title' => 'APintermGreen1',  'parentid' => '19',  'displayorder' => '2',  'userselect' => '1',  ),  ),  
 ),
);

var_export($stylecache);
?>

Expected result:
----------------
$stylecache = array (
  -1 => 
  array (
    1 => 
    array (
      0 => 
      array (
        'styleid' => '19',
        'title' => 'vB4 Default Style',
        'parentid' => '-1',
        'displayorder' => '1',
        'userselect' => '1',
      ),
    ),
  ),
  19 => 
  array (
    2 => 
    array (
      0 => 
      array (
        'styleid' => '20',
        'title' => 'APintermGreen1',
        'parentid' => '19',
        'displayorder' => '2',
        'userselect' => '1',
      ),
    ),
  ),
);


Actual result:
--------------
$stylecache = array (
  4294967295 => 
  array (
    1 => 
    array (
      0 => 
      array (
        'styleid' => '19',
        'title' => 'vB4 Default Style',
        'parentid' => '-1',
        'displayorder' => '1',
        'userselect' => '1',
      ),
    ),
  ),
  19 => 
  array (
    2 => 
    array (
      0 => 
      array (
        'styleid' => '20',
        'title' => 'APintermGreen1',
        'parentid' => '19',
        'displayorder' => '2',
        'userselect' => '1',
      ),
    ),
  ),
);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-01 04:40 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2010-10-01 04:40 UTC] felipe@php.net
Duplicated of Bug #52534, which has been already fixed. Thanks.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Apr 04 09:01:23 2020 UTC