forked from php-memcached-dev/php-memcached
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PECL bug 16959, binary protocol and bad multiget.
libmemcached doesn't null terminate keys when in binary mode. This fix always sets the null. It is safe because the max key length is 250 and libmemcached reserves extra byte for the terminating null.
- Loading branch information
Teddy Grenman
committed
Dec 13, 2009
1 parent
640927e
commit 6abbe4b
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--TEST-- | ||
Memcached: Bug #16959 (getMulti + BINARY_PROTOCOL problem) | ||
--SKIPIF-- | ||
<?php if (!extension_loaded("memcached")) print "skip"; ?> | ||
--FILE-- | ||
<? | ||
$cache = new Memcached(); | ||
$cache->setOption(Memcached::OPT_BINARY_PROTOCOL, true); | ||
$cache->addServer('localhost', 11211); | ||
|
||
$cache->set('key_0', 'value0'); | ||
$cache->set('key_0_additional', 'value0_additional'); | ||
|
||
// -------------- NORMAL | ||
echo "NORMAL\n"; | ||
$keys = array( 'key_0', 'key_0_additional' ); | ||
$values = $cache->getMulti($keys); | ||
echo $cache->getResultMessage(), "\n"; | ||
echo "Values:\n"; | ||
foreach ($values as $k => $v) { | ||
var_dump($k); | ||
var_dump($v); | ||
var_dump($values[$k]); | ||
} | ||
// --------------- REVERSED KEY ORDER | ||
echo "REVERSED KEY ORDER\n"; | ||
$keys = array( 'key_0_additional', 'key_0' ); | ||
$values = $cache->getMulti($keys); | ||
echo $cache->getResultMessage(), "\n"; | ||
echo "Values:\n"; | ||
foreach ($values as $k => $v) { | ||
var_dump($k); | ||
var_dump($v); | ||
var_dump($values[$k]); | ||
} | ||
|
||
--EXPECT-- | ||
NORMAL | ||
SUCCESS | ||
Values: | ||
string(5) "key_0" | ||
string(6) "value0" | ||
string(6) "value0" | ||
string(16) "key_0_additional" | ||
string(17) "value0_additional" | ||
string(17) "value0_additional" | ||
REVERSED KEY ORDER | ||
SUCCESS | ||
Values: | ||
string(16) "key_0_additional" | ||
string(17) "value0_additional" | ||
string(17) "value0_additional" | ||
string(5) "key_0" | ||
string(6) "value0" | ||
string(6) "value0" |