php.net |  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: 2021-06-09 11:22 UTC
Votes:3
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: cmb (profile)
Status: Closed Package: memcached (PECL)
PHP Version: 5.3.0 OS: Linux 64bit
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gnujava at gmail dot com
New email:
PHP Version: OS:

 

 [2009-12-30 10:03 UTC] gnujava at gmail dot com
Description:
------------
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, 
&str_key_len, &num_key, 0, NULL) != HASH_KEY_IS_STRING) {
                        continue;
                }
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.
);
$m->setMulti($items);
var_dump($m->get('123'));         // '123'=>'value1' not in memcached 


Expected result:
----------------
string(6) "value1"

Actual result:
--------------
bool(false)

Patches

Pull Requests

History

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?

git://github.com/tuyan/php-memcached.git
 [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).

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

desire:
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)
 [2021-06-09 11:22 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-06-09 11:22 UTC] cmb@php.net
The memcached bug tracker is now on Github[1].  If this is still
an issue with the current memcached version, please report there.

[1] <https://github.com/php-memcached-dev/php-memcached/issues>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 23:01:32 2024 UTC