|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59016 Memcached::setMulti can't support pure digit key
Submitted: 2009-12-30 10:03 UTC Modified: 2010-01-05 04:11 UTC
Avg. Score:4.3 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: gnujava at gmail dot com Assigned:
Status: Open Package: memcached (PECL)
PHP Version: 5.3.0 OS: Linux 64bit
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-12-30 10:03 UTC] gnujava at gmail dot com
Memcached::setMulti can't support pure digit key

file: php_memcached.c
fun:  php_memc_setMulti_impl
line: 1009

if (zend_hash_get_current_key_ex(Z_ARRVAL_P(entries), 
&str_key_len, &num_key, 0, NULL) != HASH_KEY_IS_STRING) {
HASH_KEY_IS_STRING is not good idea.

Reproduce code:
$m = new Memcached();
$m->addServer('localhost', 11211);

$items = array(
    '123' => 'value1'            // key is pure number but       that type is string, and php engine will turn string(123) to    int(123) key.
var_dump($m->get('123'));         // '123'=>'value1' not in memcached 

Expected result:
string(6) "value1"

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-04 22:40 UTC] tuyanozipek at gmail dot com
This should be fixed in my devel branch. Can you please test
and provide feedback?

 [2010-01-05 03:32 UTC] tricky dot pecl at luuseri dot com
Also, a fix to allow pure digit keys in deleteMulti and getMulti is in the works.
 [2010-01-05 04:11 UTC] gnujava at gmail dot com
Could you add the automatic type conversion in get/set method 
for pure digit key(integer type).

value = $mc->get((string)123);

value = $mc->get(123);
 [2013-04-25 18:56 UTC] kneeoh at yahoo dot com
I've observed the same behavior on PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli) 
(built: Mar 11 2013 14:31:48)
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 03:01:25 2019 UTC