php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58975 getMulti + BINARY_PROTOCOL problem
Submitted: 2009-12-03 20:28 UTC Modified: 2010-05-03 16:16 UTC
From: skorodumov at vingrad dot ru Assigned:
Status: Closed Package: memcached (PECL)
PHP Version: 5.3.0 OS: Debian 5.0
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: skorodumov at vingrad dot ru
New email:
PHP Version: OS:

 

 [2009-12-03 20:28 UTC] skorodumov at vingrad dot ru
Description:
------------
When switch on BINARY_PROTOCOL we see strange things while using values got from getMulti method.
Look at the end of the output - we get NULL instead off the "value0".
If the BINARY_PROTOCOL is turned off everything works fine.

Values:
array(2) { ["key_0"]=> string(6) "value0" ["key_0_additional"]=> string(17) "value0_additional" }
key_0:
string(6) "value0"
Values:
array(2) { ["key_0_additional"]=> string(17) "value0_additional" ["key_0"]=> string(6) "value0" }
key_0:
NULL 

Reproduce code:
---------------
$cache = new Memcached();
$cache->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$cache->addServers( array( array('localhost', 11211) ) );
$cache->set( 'key_0', 'value0' );
$cache->set( 'key_0_additional', 'value0_additional' );
// -------------- NORMAL
$keys = array( 'key_0', 'key_0_additional' );
$values = $cache->getMulti( $keys );
echo "Values:<br>\n"; var_dump( $values ); 
echo "<br>\n";
echo "key_0:<br>\n"; var_dump( $values['key_0'] );
echo "<br>\n";
// --------------- REVERSED KEY ORDER
$keys = array( 'key_0_additional', 'key_0' );
$values = $cache->getMulti( $keys );
echo "Values:<br>\n"; var_dump( $values );
echo "<br>\n";
echo "key_0:<br>\n"; var_dump( $values['key_0'] );
echo "<br>\n";

Expected result:
----------------
key_0:
string(6) "value0"


Actual result:
--------------
key_0:
NULL 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-08 16:52 UTC] wedgedkc at hotmail dot com
I'm having strange issues with multiget and binary protocol as 
well. I'm trying to make a small testcase. The issue for me is 
that I get keys returned with other values than the ones asked 
for. If I ask for key "xmlprod677" I can get "xmlprod6772" 
returned instead.

I'm running PHP 5.3.0 on snow leopard with the latest version 
of the extension from github (5d01619) and libmemcached 0.3.5.
 [2009-12-10 06:20 UTC] wedgedkc at hotmail dot com
It looks like I get different result from array_diff() and 
array_diff_key(). Could this be a PHP problem or am I missing 
something?

Example code:
http://paste2.org/p/555378
 [2009-12-10 06:22 UTC] wedgedkc at hotmail dot com
Forgot my result from my example code:
xmlprod677 and an empty array.
 [2009-12-13 11:55 UTC] tricky dot pecl at luuseri dot com
The returned value is null, which means there might be an error. Could you post what getResultMessage() and getResultCode() return?
 [2009-12-13 14:36 UTC] tricky dot pecl at luuseri dot com
The problem was that keys are not 0-terminated by libmemcached when using the binary protocol. Fixed that, and you may pull my fix from github (6abbe4b9f, devel branch)
 [2009-12-13 18:55 UTC] jmy at morgontech dot com
This seems to be a duplicate of Bug #16829, sounds like you're having the same trouble I am.
 [2009-12-14 17:50 UTC] wedgedkc at hotmail dot com
The null termination patch seems to have taken care of my 
problems. Thanks!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Mar 10 21:01:30 2025 UTC