Bug #52963 [NEW]: var_export -1 array index outputs incorrectly

From: Date: Fri, 01 Oct 2010 02:35:13 +0000
Subject: Bug #52963 [NEW]: var_export -1 array index outputs incorrectly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-154797@lists.php.net to get a copy of this message
From:             
Operating system: Linux Centos 5.5
PHP version:      5.2.14
Package:          Strings related
Bug Type:         Bug
Bug description:var_export -1 array index outputs incorrectly

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',
      ),
    ),
  ),
);


-- 
Edit bug report at http://bugs.php.net/bug.php?id=52963&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=52963&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=52963&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=52963&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=52963&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52963&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=52963&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=52963&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=52963&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=52963&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=52963&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=52963&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=52963&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=52963&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=52963&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52963&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52963&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=52963&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=52963&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=52963&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=52963&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=52963&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#154797) next »