php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17948 serialize() and setlocale() problem (was: unserialize() failure)
Submitted: 2002-06-24 11:57 UTC Modified: 2002-10-10 11:55 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: cox at idecnet dot com Assigned: hholzgra (profile)
Status: Closed Package: Strings related
PHP Version: 4.2.1 OS: RH
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cox at idecnet dot com
New email:
PHP Version: OS:

 

 [2002-06-24 11:57 UTC] cox at idecnet dot com
file: bug_serialize
<?php
error_reporting(E_ALL);
$ser = 'a:5:{s:6:"lineas";a:1:{i:0;a:7:{s:7:"ldivisa";s:3:"eur";s:9:"letcambio";s:1:"1";s:9:"leimporte";s:3:"200";s:7:"letotal";s:3:"200";s:9:"ldtcambio";s:1:"1";s:9:"ldimporte";s:2:"50";s:7:"ldtotal";s:2:"50";}}s:3:"lte";i:200;s:3:"ltd";i:50;s:10:"ltgtosefec";d:93,66;s:3:"lrl";d:56,34;}';
var_dump(unserialize($ser));
?>

With PHP 4.1.1

array(5) {
  ["lineas"]=>
  array(1) {
    [0]=>
    array(7) {
      ["ldivisa"]=>
      string(3) "eur"
      ["letcambio"]=>
      string(1) "1"
      ["leimporte"]=>
      string(3) "200"
      ["letotal"]=>
      string(3) "200"
      ["ldtcambio"]=>
      string(1) "1"
      ["ldimporte"]=>
      string(2) "50"
      ["ldtotal"]=>
      string(2) "50"
    }
  }
  ["lte"]=>
  int(200)
  ["ltd"]=>
  int(50)
  ["ltgtosefec"]=>
  float(93)
  ["lrl"]=>
  float(56)
}

With PHP 4.2.1

Notice: unserialize() failed at offset 253 of 280 bytes in bug_serialize on line 4
bool(false)


Tomas V.V.Cox

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-24 12:12 UTC] cox at idecnet dot com
I guess that there is some problem with perhaps the locale, storing "99,33" (spanish decimal) as a float, the same with "56,34", so the problem is perhaps serialize instead. I'll try to give more info.
 [2002-06-24 13:16 UTC] cox at idecnet dot com
Ok, I found the problem. See that script:

<?php
error_reporting(E_ALL);
//setlocale(LC_ALL, "es_ES");
$a = 2.3;
$b = serialize($a);
var_dump(serialize($b));
var_dump(unserialize($b));
?>

The output is:
string(13) "s:6:"d:2.3;";"
float(2.3)

No problem. Now uncomment line 2. You'll get:
string(13) "s:6:"d:2,3;";"
 
Notice: unserialize() failed at offset 0 of 6 bytes in borrar.php on line 9
bool(false)


Tomas V.V.Cox
 [2002-06-25 07:01 UTC] sander@php.net
Let's assign this to Hartmut, he's busy with all those locale problems.
 [2002-10-10 11:55 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 17:01:29 2024 UTC