#27646 [NEW]: Cannot serialize/unserialize non-finite numeric values

From: Date: Fri, 19 Mar 2004 02:29:14 +0000
Subject: #27646 [NEW]: Cannot serialize/unserialize non-finite numeric values
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-56657@lists.php.net to get a copy of this message
From:             matthew_kay at ml1 dot net
Operating system: Linux 2.4.22 (Mandrake 9.2)
PHP version:      5.0.0RC1
PHP Bug Type:     Zend Engine 2 problem
Bug description:  Cannot serialize/unserialize non-finite numeric values

Description:
------------
It appears that unserialize() does not unserialize 
numerics that are "non-finite", such as NAN and INF. 
Instead, it simply fails and returns (bool)false. 
 
If a NAN value is encountered anywhere during an 
unserialize() (for example, in an array or an object), the 
entire operation fails and unserialize will return false. 

Reproduce code:
---------------
$testNan = (float)NAN;
var_dump($testNan); //outputs float(NAN)
$testNan2 = unserialize(serialize($testNan));
var_dump($testNan2); //outputs bool(false)

$testInf = (float)INF;
var_dump($testInf); //outputs float(INF)
$testInf2 = unserialize(serialize($testInf));
var_dump($testInf2); //outputs bool(false)

Expected result:
----------------
float(NAN) 
float(NAN) 
float(INF) 
float(INF) 

Actual result:
--------------
float(NAN) 
bool(false) 
float(INF) 
bool(false) 

-- 
Edit bug report at http://bugs.php.net/?id=27646&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27646&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27646&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27646&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27646&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27646&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27646&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27646&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27646&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27646&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27646&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27646&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27646&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27646&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27646&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27646&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27646&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27646&r=float


Thread (3 messages)

« previous php.bugs (#56657) next »