Skip to content

Cannot reset OPT_PREFIX_KEY #293 #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Tests
<file role='test' name='session_regenerate.phpt'/>
<file role='test' name='stats.phpt'/>
<file role='test' name='default_behavior.phpt'/>
<file role='test' name='reset_keyprefix.phpt'/>
</dir>
</dir>
</contents>
Expand Down
2 changes: 1 addition & 1 deletion php_memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -2867,7 +2867,7 @@ int php_memc_set_option(php_memc_object_t *intern, long option, zval *value)
char tmp[MEMCACHED_PREFIX_KEY_MAX_SIZE - 1];
#endif
str = zval_get_string(value);
if (ZSTR_VAL(str) == 0) {
if (ZSTR_LEN(str) == 0) {
key = NULL;
} else {
/*
Expand Down
38 changes: 38 additions & 0 deletions tests/reset_keyprefix.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--TEST--
Cannot reset OPT_PREFIX_KEY #293
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';

$m = memc_get_instance ();

$m->set('key1', 'abc');
var_dump($m->get('key1'));

$m->setOption(Memcached::OPT_PREFIX_KEY, 'prefix');
var_dump($m->get('key1'));

$m->setOption(Memcached::OPT_PREFIX_KEY, false);
var_dump($m->get('key1'));

$m->setOption(Memcached::OPT_PREFIX_KEY, 'prefix');
var_dump($m->get('key1'));

$m->setOption(Memcached::OPT_PREFIX_KEY, '');
var_dump($m->get('key1'));

$m->setOption(Memcached::OPT_PREFIX_KEY, 'prefix');
var_dump($m->get('key1'));

$m->setOption(Memcached::OPT_PREFIX_KEY, null);
var_dump($m->get('key1'));
--EXPECTF--
string(3) "abc"
bool(false)
string(3) "abc"
bool(false)
string(3) "abc"
bool(false)
string(3) "abc"