#48171 [Bgs]: Unserialize converts string to integer in case of numeric properties

2009-05-06 Thread csnyder at fcny dot org
 ID:   48171
 User updated by:  csnyder at fcny dot org
 Reported By:  csnyder at fcny dot org
 Status:   Bogus
 Bug Type: Scripting Engine problem
 Operating System: Linux
 PHP Version:  5.2.9
 New Comment:

Bogus really? If serialize handles numeric property names correctly,
why shouldn't unserialize?

Also, would be interested in actual citation in the manual as to why
this bug is bogus. Thanks.


Previous Comments:


[2009-05-06 18:39:06] j...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php





[2009-05-06 18:36:32] csnyder at fcny dot org

Description:

When unserializing a string like
O:8:"stdClass":3:{s:5:"22387";s:1:"a";s:5:"22386";s:1:"a";s:5:"22368";s:1:"a";},
the resulting object will have integers as property names instead of
strings.

This may be regression of #43614, marked fixed in CVS but that was a
year ago.

Reproduce code:
---
{$key} = 'a';
}

var_dump( $obj );
$s = serialize( $obj );
$u = unserialize( $s );
var_dump( $u );

?>

Expected result:

object(stdClass)#1 (3) {
  ["1"]=>
  string(1) "a"
  ["2"]=>
  string(1) "a"
  ["3"]=>
  string(1) "a"
}
object(stdClass)#2 (3) {
  ["1"]=>
  string(1) "a"
  ["2"]=>
  string(1) "a"
  ["3"]=>
  string(1) "a"
}


Actual result:
--
object(stdClass)#1 (3) {
  ["1"]=>
  string(1) "a"
  ["2"]=>
  string(1) "a"
  ["3"]=>
  string(1) "a"
}
object(stdClass)#2 (3) {
  [1]=>
  string(1) "a"
  [2]=>
  string(1) "a"
  [3]=>
  string(1) "a"
}






-- 
Edit this bug report at http://bugs.php.net/?id=48171&edit=1



#48171 [NEW]: Unserialize converts string to integer in case of numeric properties

2009-05-06 Thread csnyder at fcny dot org
From: csnyder at fcny dot org
Operating system: Linux
PHP version:  5.2.9
PHP Bug Type: Scripting Engine problem
Bug description:  Unserialize converts string to integer in case of numeric 
properties

Description:

When unserializing a string like
O:8:"stdClass":3:{s:5:"22387";s:1:"a";s:5:"22386";s:1:"a";s:5:"22368";s:1:"a";},
the resulting object will have integers as property names instead of
strings.

This may be regression of #43614, marked fixed in CVS but that was a year
ago.

Reproduce code:
---
{$key} = 'a';
}

var_dump( $obj );
$s = serialize( $obj );
$u = unserialize( $s );
var_dump( $u );

?>

Expected result:

object(stdClass)#1 (3) {
  ["1"]=>
  string(1) "a"
  ["2"]=>
  string(1) "a"
  ["3"]=>
  string(1) "a"
}
object(stdClass)#2 (3) {
  ["1"]=>
  string(1) "a"
  ["2"]=>
  string(1) "a"
  ["3"]=>
  string(1) "a"
}


Actual result:
--
object(stdClass)#1 (3) {
  ["1"]=>
  string(1) "a"
  ["2"]=>
  string(1) "a"
  ["3"]=>
  string(1) "a"
}
object(stdClass)#2 (3) {
  [1]=>
  string(1) "a"
  [2]=>
  string(1) "a"
  [3]=>
  string(1) "a"
}


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