php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58361 Types lost during get/set
Submitted: 2008-10-02 12:27 UTC Modified: 2009-01-13 11:27 UTC
From: ian at digg dot com Assigned:
Status: Closed Package: memcache (PECL)
PHP Version: 5.2.0 OS: Debian Linux, Etch
Private report: No CVE-ID: None
 [2008-10-02 12:27 UTC] ian at digg dot com
Description:
------------
If you set an int in memcache, then get that key, the value has been cast to a string.

Reproduce code:
---------------
$val = (int) 200;
var_dump($val);
$cache->set('test', $val);
$newVal = $cache->get('test');
var_dump($newVal);

Expected result:
----------------
int(200)
int(200)

Actual result:
--------------
int(200)
string(3) "200"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-02 13:23 UTC] mikael at synd dot info
The clean way to do this would be to use some of the bits from the flag bitarray to indicate type info and store the int as a 4 byte binary string, taking endianness into consideration. 

Problem is that some people might well be using the flags array for their own purposes already, currently we only use the two least significant bits to indicate serialization and compression. 

I'll look into reserving the whole least significant byte for internal usage and outputting a warning if someone tries to set flags there. What other types might be interesting, floats, booleans?
 [2009-01-13 11:27 UTC] mikael at synd dot info
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

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

Implemented using flags compatible with net.spy.memcached as indicated at

 http://www.hjp.at/zettel/m/memcached_flags.rxml
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 05:01:30 2024 UTC