Skip to content

Fixes an incorrect libmemcached version check for OPT_PREFIX_KEY #6

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

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 4 additions & 4 deletions php_memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ static PHP_METHOD(Memcached, getOption)

result = memcached_callback_get(m_obj->memc, MEMCACHED_CALLBACK_PREFIX_KEY, &retval);
if (retval == MEMCACHED_SUCCESS) {
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX < 0x00050000
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX == 0x00049000
RETURN_STRINGL(result, strlen(result) - 1, 1);
#else
RETURN_STRING(result, 1);
Expand Down Expand Up @@ -2228,18 +2228,18 @@ static int php_memc_set_option(php_memc_t *i_obj, long option, zval *value TSRML
case MEMC_OPT_PREFIX_KEY:
{
char *key;
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX < 0x00050000
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX == 0x00049000
char tmp[MEMCACHED_PREFIX_KEY_MAX_SIZE - 1];
#endif
convert_to_string(value);
if (Z_STRLEN_P(value) == 0) {
key = NULL;
} else {
/*
work-around a bug in libmemcached prior to version 0.50 that truncates the trailing
work-around a bug in libmemcached version 0.49 that truncates the trailing
character of the key prefix, to avoid the issue we pad it with a '0'
*/
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX < 0x00050000
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX == 0x00049000
snprintf(tmp, sizeof(tmp), "%s0", Z_STRVAL_P(value));
key = tmp;
#else
Expand Down