diff --git a/config.m4 b/config.m4
index 50e2d3bd..b34c30bf 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 g_fmt.c"
+ PHP_MEMCACHED_FILES="php_memcached.c php_libmemcached_compat.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 357086f8..2f01cf46 100644
--- a/package.xml
+++ b/package.xml
@@ -73,6 +73,8 @@ Tests
+
+
diff --git a/php_libmemcached_compat.c b/php_libmemcached_compat.c
new file mode 100644
index 00000000..bd35d8fe
--- /dev/null
+++ b/php_libmemcached_compat.c
@@ -0,0 +1,37 @@
+/*
+ +----------------------------------------------------------------------+
+ | 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
new file mode 100644
index 00000000..9bcbc20f
--- /dev/null
+++ b/php_libmemcached_compat.h
@@ -0,0 +1,31 @@
+/*
+ +----------------------------------------------------------------------+
+ | 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 >= 0x01000017
+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 ba3473de..514f4c33 100644
--- a/php_memcached.c
+++ b/php_memcached.c
@@ -4022,7 +4022,6 @@ static zend_function_entry memcached_class_methods[] = {
MEMC_ME(getLastErrorMessage, arginfo_getLastErrorMessage)
MEMC_ME(getLastErrorCode, arginfo_getLastErrorCode)
MEMC_ME(getLastErrorErrno, arginfo_getLastErrorErrno)
-
MEMC_ME(getLastDisconnectedServer, arginfo_getLastDisconnectedServer)
MEMC_ME(getStats, arginfo_getStats)
@@ -4216,7 +4215,6 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_MODULA, MEMCACHED_DISTRIBUTION_MODULA);
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_CONSISTENT, MEMCACHED_DISTRIBUTION_CONSISTENT);
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_VIRTUAL_BUCKET, MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET);
-
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);
diff --git a/php_memcached_private.h b/php_memcached_private.h
index fe6ccc2c..a04e19be 100644
--- a/php_memcached_private.h
+++ b/php_memcached_private.h
@@ -25,13 +25,7 @@
# include "config.h"
#endif
-#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 "php_libmemcached_compat.h"
#include
#include
@@ -214,6 +208,8 @@ 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 25ca0ae2..1695b330 100644
--- a/php_memcached_session.c
+++ b/php_memcached_session.c
@@ -530,7 +530,7 @@ PS_VALIDATE_SID_FUNC(memcached)
{
memcached_st *memc = PS_GET_MOD_DATA();
- if (memcached_exist(memc, key->val, key->len) == MEMCACHED_SUCCESS) {
+ if (php_memcached_exist(memc, key) == MEMCACHED_SUCCESS) {
return SUCCESS;
} else {
return FAILURE;