diff --git a/config.m4 b/config.m4
index e6a2dfd0..ab6142a1 100644
--- a/config.m4
+++ b/config.m4
@@ -318,7 +318,7 @@ if test "$PHP_MEMCACHED" != "no"; then
AC_DEFINE(HAVE_MEMCACHED_EXIST, [1], [Whether memcached_exist is defined])
fi
- PHP_MEMCACHED_FILES="php_memcached.c php_libmemcached_compat.c g_fmt.c"
+ PHP_MEMCACHED_FILES="php_memcached.c g_fmt.c"
if test "$PHP_SYSTEM_FASTLZ" != "no"; then
AC_CHECK_HEADERS([fastlz.h], [ac_cv_have_fastlz="yes"], [ac_cv_have_fastlz="no"])
diff --git a/package.xml b/package.xml
index 244acfab..1dd5305f 100644
--- a/package.xml
+++ b/package.xml
@@ -72,8 +72,6 @@ Tests
-
-
diff --git a/php_libmemcached_compat.c b/php_libmemcached_compat.c
deleted file mode 100644
index bd35d8fe..00000000
--- a/php_libmemcached_compat.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | Copyright (c) 2009 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andrei Zmievski |
- +----------------------------------------------------------------------+
-*/
-
-#include "php_memcached.h"
-#include "php_memcached_private.h"
-#include "php_libmemcached_compat.h"
-
-memcached_return php_memcached_exist (memcached_st *memc, zend_string *key)
-{
-#ifdef HAVE_MEMCACHED_EXIST
- return memcached_exist (memc, key->val, key->len);
-#else
- memcached_return rc = MEMCACHED_SUCCESS;
- uint32_t flags = 0;
- size_t value_length = 0;
- char *value = NULL;
-
- value = memcached_get (memc, key->val, key->len, &value_length, &flags, &rc);
- if (value) {
- free (value);
- }
- return rc;
-#endif
-}
diff --git a/php_libmemcached_compat.h b/php_libmemcached_compat.h
deleted file mode 100644
index e740d310..00000000
--- a/php_libmemcached_compat.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | Copyright (c) 2009 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andrei Zmievski |
- +----------------------------------------------------------------------+
-*/
-
-#ifndef PHP_LIBMEMCACHED_COMPAT
-#define PHP_LIBMEMCACHED_COMPAT
-
-/* this is the version(s) we support */
-#include
-
-memcached_return php_memcached_exist (memcached_st *memc, zend_string *key);
-
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX < 0x00052000
-# define MEMCACHED_SERVER_TEMPORARILY_DISABLED (1024 << 2)
-#endif
-
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000002
-# define HAVE_MEMCACHED_TOUCH 1
-#endif
-
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000017
-# define HAVE_MEMCACHED_INSTANCE_ST 1
-#endif
-
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00049000
-# define HAVE_LIBMEMCACHED_CHECK_CONFIGURATION 1
-#endif
-
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000002
-# define HAVE_MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS 1
-#endif
-
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00049000
-# define HAVE_LIBMEMCACHED_MEMCACHED 1
-#endif
-
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000018
-# define HAVE_MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT 1
-#endif
-
-#ifdef HAVE_MEMCACHED_INSTANCE_ST
-typedef const memcached_instance_st * php_memcached_instance_st;
-#else
-typedef memcached_server_instance_st php_memcached_instance_st;
-#endif
-
-#endif
diff --git a/php_memcached.c b/php_memcached.c
index e6b741ef..35c0a6c1 100644
--- a/php_memcached.c
+++ b/php_memcached.c
@@ -1753,7 +1753,6 @@ PHP_METHOD(Memcached, setByKey)
}
/* }}} */
-#ifdef HAVE_MEMCACHED_TOUCH
/* {{{ Memcached::touch(string key, [, int expiration ])
Sets a new expiration for the given key */
PHP_METHOD(Memcached, touch)
@@ -1769,8 +1768,6 @@ PHP_METHOD(Memcached, touchByKey)
php_memc_store_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, MEMC_OP_TOUCH, 1);
}
/* }}} */
-#endif
-
/* {{{ Memcached::setMulti(array items [, int expiration ])
Sets the keys/values specified in the items array */
@@ -2305,17 +2302,7 @@ PHP_METHOD(Memcached, addServer)
MEMC_METHOD_FETCH_OBJECT;
s_memc_set_status(intern, MEMCACHED_SUCCESS, 0);
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX < 0x01000002
- if (ZSTR_VAL(host)[0] == '/') { /* unix domain socket */
- status = memcached_server_add_unix_socket_with_weight(intern->memc, ZSTR_VAL(host), weight);
- } else if (memcached_behavior_get(intern->memc, MEMCACHED_BEHAVIOR_USE_UDP)) {
- status = memcached_server_add_udp_with_weight(intern->memc, ZSTR_VAL(host), port, weight);
- } else {
- status = memcached_server_add_with_weight(intern->memc, ZSTR_VAL(host), port, weight);
- }
-#else
status = memcached_server_add_with_weight(intern->memc, ZSTR_VAL(host), port, weight);
-#endif
if (s_memc_status_handle_result_code(intern, status) == FAILURE) {
RETURN_FALSE;
@@ -2511,7 +2498,6 @@ PHP_METHOD(Memcached, flushBuffers)
}
/* }}} */
-#ifdef HAVE_LIBMEMCACHED_CHECK_CONFIGURATION
/* {{{ Memcached::getLastErrorMessage()
Returns the last error message that occurred */
PHP_METHOD(Memcached, getLastErrorMessage)
@@ -2559,7 +2545,6 @@ PHP_METHOD(Memcached, getLastErrorErrno)
RETURN_LONG(memcached_last_error_errno(intern->memc));
}
/* }}} */
-#endif
/* {{{ Memcached::getLastDisconnectedServer()
Returns the last disconnected server
@@ -2794,11 +2779,7 @@ static PHP_METHOD(Memcached, getOption)
result = memcached_callback_get(intern->memc, MEMCACHED_CALLBACK_PREFIX_KEY, &retval);
if (retval == MEMCACHED_SUCCESS && result) {
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX == 0x00049000
- RETURN_STRINGL(result, strlen(result));
-#else
RETURN_STRING(result);
-#endif
} else {
RETURN_EMPTY_STRING();
}
@@ -2863,23 +2844,11 @@ int php_memc_set_option(php_memc_object_t *intern, long option, zval *value)
{
zend_string *str;
char *key;
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX == 0x00049000
- char tmp[MEMCACHED_PREFIX_KEY_MAX_SIZE - 1];
-#endif
str = zval_get_string(value);
if (ZSTR_VAL(str) == 0) {
key = NULL;
} else {
- /*
- work-around a bug in libmemcached in 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 == 0x00049000
- snprintf(tmp, sizeof(tmp), "%s0", ZSTR_VAL(str));
- key = tmp;
-#else
key = ZSTR_VAL(str);
-#endif
}
if (memcached_callback_set(intern->memc, MEMCACHED_CALLBACK_PREFIX_KEY, key) == MEMCACHED_BAD_KEY_PROVIDED) {
zend_string_release(str);
@@ -2908,14 +2877,9 @@ int php_memc_set_option(php_memc_object_t *intern, long option, zval *value)
* (non-weighted) case. We have to clean up ourselves.
*/
if (!lval) {
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX > 0x00037000
- (void)memcached_behavior_set_key_hash(intern->memc, MEMCACHED_HASH_DEFAULT);
- (void)memcached_behavior_set_distribution_hash(intern->memc, MEMCACHED_HASH_DEFAULT);
- (void)memcached_behavior_set_distribution(intern->memc, MEMCACHED_DISTRIBUTION_MODULA);
-#else
- intern->memc->hash = 0;
- intern->memc->distribution = 0;
-#endif
+ (void)memcached_behavior_set_key_hash(intern->memc, MEMCACHED_HASH_DEFAULT);
+ (void)memcached_behavior_set_distribution_hash(intern->memc, MEMCACHED_HASH_DEFAULT);
+ (void)memcached_behavior_set_distribution(intern->memc, MEMCACHED_DISTRIBUTION_MODULA);
}
break;
@@ -3997,10 +3961,10 @@ static zend_function_entry memcached_class_methods[] = {
MEMC_ME(set, arginfo_set)
MEMC_ME(setByKey, arginfo_setByKey)
-#ifdef HAVE_MEMCACHED_TOUCH
+
MEMC_ME(touch, arginfo_touch)
MEMC_ME(touchByKey, arginfo_touchByKey)
-#endif
+
MEMC_ME(setMulti, arginfo_setMulti)
MEMC_ME(setMultiByKey, arginfo_setMultiByKey)
@@ -4032,11 +3996,10 @@ static zend_function_entry memcached_class_methods[] = {
MEMC_ME(quit, arginfo_quit)
MEMC_ME(flushBuffers, arginfo_flushBuffers)
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00049000
MEMC_ME(getLastErrorMessage, arginfo_getLastErrorMessage)
MEMC_ME(getLastErrorCode, arginfo_getLastErrorCode)
MEMC_ME(getLastErrorErrno, arginfo_getLastErrorErrno)
-#endif
+
MEMC_ME(getLastDisconnectedServer, arginfo_getLastDisconnectedServer)
MEMC_ME(getStats, arginfo_getStats)
@@ -4229,9 +4192,8 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
REGISTER_MEMC_CLASS_CONST_LONG(OPT_DISTRIBUTION, MEMCACHED_BEHAVIOR_DISTRIBUTION);
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_MODULA, MEMCACHED_DISTRIBUTION_MODULA);
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_CONSISTENT, MEMCACHED_DISTRIBUTION_CONSISTENT);
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00049000
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_VIRTUAL_BUCKET, MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET);
-#endif
+
REGISTER_MEMC_CLASS_CONST_LONG(OPT_LIBKETAMA_COMPATIBLE, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
REGISTER_MEMC_CLASS_CONST_LONG(OPT_LIBKETAMA_HASH, MEMCACHED_BEHAVIOR_KETAMA_HASH);
REGISTER_MEMC_CLASS_CONST_LONG(OPT_TCP_KEEPALIVE, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE);
@@ -4257,14 +4219,10 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
REGISTER_MEMC_CLASS_CONST_LONG(OPT_SORT_HOSTS, MEMCACHED_BEHAVIOR_SORT_HOSTS);
REGISTER_MEMC_CLASS_CONST_LONG(OPT_VERIFY_KEY, MEMCACHED_BEHAVIOR_VERIFY_KEY);
REGISTER_MEMC_CLASS_CONST_LONG(OPT_USE_UDP, MEMCACHED_BEHAVIOR_USE_UDP);
-#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00037000
REGISTER_MEMC_CLASS_CONST_LONG(OPT_NUMBER_OF_REPLICAS, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS);
REGISTER_MEMC_CLASS_CONST_LONG(OPT_RANDOMIZE_REPLICA_READ, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ);
-#endif
-#ifdef HAVE_MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS
REGISTER_MEMC_CLASS_CONST_LONG(OPT_REMOVE_FAILED_SERVERS, MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS);
-#endif
-#ifdef HAVE_MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT
+#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000018
REGISTER_MEMC_CLASS_CONST_LONG(OPT_SERVER_TIMEOUT_LIMIT, MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT);
#endif
diff --git a/php_memcached_private.h b/php_memcached_private.h
index a04e19be..fe6ccc2c 100644
--- a/php_memcached_private.h
+++ b/php_memcached_private.h
@@ -25,7 +25,13 @@
# include "config.h"
#endif
-#include "php_libmemcached_compat.h"
+#include
+
+#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000017
+typedef const memcached_instance_st * php_memcached_instance_st;
+#else
+typedef memcached_server_instance_st php_memcached_instance_st;
+#endif
#include
#include
@@ -208,8 +214,6 @@ PHP_MINFO_FUNCTION(memcached);
char *php_memc_printable_func (zend_fcall_info *fci, zend_fcall_info_cache *fci_cache);
-memcached_return php_memcached_exist (memcached_st *memc, zend_string *key);
-
zend_bool php_memc_init_sasl_if_needed();
#endif /* PHP_MEMCACHED_PRIVATE_H */
diff --git a/php_memcached_session.c b/php_memcached_session.c
index 42659fe5..c7e6d1cd 100644
--- a/php_memcached_session.c
+++ b/php_memcached_session.c
@@ -527,7 +527,7 @@ PS_VALIDATE_SID_FUNC(memcached)
{
memcached_st *memc = PS_GET_MOD_DATA();
- if (php_memcached_exist(memc, key) == MEMCACHED_SUCCESS) {
+ if (memcached_exist(memc, key->val, key->len) == MEMCACHED_SUCCESS) {
return SUCCESS;
} else {
return FAILURE;