Skip to content

Commit 9dbaaed

Browse files
committed
Restore compatibility cuts, leaving php_memcached_exist workaround
1 parent 9258efd commit 9dbaaed

File tree

2 files changed

+6
-78
lines changed

2 files changed

+6
-78
lines changed

php_libmemcached_compat.h

-28
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,7 @@
2222

2323
memcached_return php_memcached_exist (memcached_st *memc, zend_string *key);
2424

25-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX < 0x00052000
26-
# define MEMCACHED_SERVER_TEMPORARILY_DISABLED (1024 << 2)
27-
#endif
28-
29-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000002
30-
# define HAVE_MEMCACHED_TOUCH 1
31-
#endif
32-
3325
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000017
34-
# define HAVE_MEMCACHED_INSTANCE_ST 1
35-
#endif
36-
37-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00049000
38-
# define HAVE_LIBMEMCACHED_CHECK_CONFIGURATION 1
39-
#endif
40-
41-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000002
42-
# define HAVE_MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS 1
43-
#endif
44-
45-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00049000
46-
# define HAVE_LIBMEMCACHED_MEMCACHED 1
47-
#endif
48-
49-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000018
50-
# define HAVE_MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT 1
51-
#endif
52-
53-
#ifdef HAVE_MEMCACHED_INSTANCE_ST
5426
typedef const memcached_instance_st * php_memcached_instance_st;
5527
#else
5628
typedef memcached_server_instance_st php_memcached_instance_st;

php_memcached.c

+6-50
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,6 @@ PHP_METHOD(Memcached, setByKey)
17651765
}
17661766
/* }}} */
17671767

1768-
#ifdef HAVE_MEMCACHED_TOUCH
17691768
/* {{{ Memcached::touch(string key, [, int expiration ])
17701769
Sets a new expiration for the given key */
17711770
PHP_METHOD(Memcached, touch)
@@ -1781,8 +1780,6 @@ PHP_METHOD(Memcached, touchByKey)
17811780
php_memc_store_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, MEMC_OP_TOUCH, 1);
17821781
}
17831782
/* }}} */
1784-
#endif
1785-
17861783

17871784
/* {{{ Memcached::setMulti(array items [, int expiration ])
17881785
Sets the keys/values specified in the items array */
@@ -2322,17 +2319,7 @@ PHP_METHOD(Memcached, addServer)
23222319
MEMC_METHOD_FETCH_OBJECT;
23232320
s_memc_set_status(intern, MEMCACHED_SUCCESS, 0);
23242321

2325-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX < 0x01000002
2326-
if (ZSTR_VAL(host)[0] == '/') { /* unix domain socket */
2327-
status = memcached_server_add_unix_socket_with_weight(intern->memc, ZSTR_VAL(host), weight);
2328-
} else if (memcached_behavior_get(intern->memc, MEMCACHED_BEHAVIOR_USE_UDP)) {
2329-
status = memcached_server_add_udp_with_weight(intern->memc, ZSTR_VAL(host), port, weight);
2330-
} else {
2331-
status = memcached_server_add_with_weight(intern->memc, ZSTR_VAL(host), port, weight);
2332-
}
2333-
#else
23342322
status = memcached_server_add_with_weight(intern->memc, ZSTR_VAL(host), port, weight);
2335-
#endif
23362323

23372324
if (s_memc_status_handle_result_code(intern, status) == FAILURE) {
23382325
RETURN_FALSE;
@@ -2528,7 +2515,6 @@ PHP_METHOD(Memcached, flushBuffers)
25282515
}
25292516
/* }}} */
25302517

2531-
#ifdef HAVE_LIBMEMCACHED_CHECK_CONFIGURATION
25322518
/* {{{ Memcached::getLastErrorMessage()
25332519
Returns the last error message that occurred */
25342520
PHP_METHOD(Memcached, getLastErrorMessage)
@@ -2576,7 +2562,6 @@ PHP_METHOD(Memcached, getLastErrorErrno)
25762562
RETURN_LONG(memcached_last_error_errno(intern->memc));
25772563
}
25782564
/* }}} */
2579-
#endif
25802565

25812566
/* {{{ Memcached::getLastDisconnectedServer()
25822567
Returns the last disconnected server
@@ -2816,11 +2801,7 @@ static PHP_METHOD(Memcached, getOption)
28162801

28172802
result = memcached_callback_get(intern->memc, MEMCACHED_CALLBACK_PREFIX_KEY, &retval);
28182803
if (retval == MEMCACHED_SUCCESS && result) {
2819-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX == 0x00049000
2820-
RETURN_STRINGL(result, strlen(result));
2821-
#else
28222804
RETURN_STRING(result);
2823-
#endif
28242805
} else {
28252806
RETURN_EMPTY_STRING();
28262807
}
@@ -2885,23 +2866,11 @@ int php_memc_set_option(php_memc_object_t *intern, long option, zval *value)
28852866
{
28862867
zend_string *str;
28872868
char *key;
2888-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX == 0x00049000
2889-
char tmp[MEMCACHED_PREFIX_KEY_MAX_SIZE - 1];
2890-
#endif
28912869
str = zval_get_string(value);
28922870
if (ZSTR_LEN(str) == 0) {
28932871
key = NULL;
28942872
} else {
2895-
/*
2896-
work-around a bug in libmemcached in version 0.49 that truncates the trailing
2897-
character of the key prefix, to avoid the issue we pad it with a '0'
2898-
*/
2899-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX == 0x00049000
2900-
snprintf(tmp, sizeof(tmp), "%s0", ZSTR_VAL(str));
2901-
key = tmp;
2902-
#else
29032873
key = ZSTR_VAL(str);
2904-
#endif
29052874
}
29062875
if (memcached_callback_set(intern->memc, MEMCACHED_CALLBACK_PREFIX_KEY, key) == MEMCACHED_BAD_KEY_PROVIDED) {
29072876
zend_string_release(str);
@@ -2930,14 +2899,9 @@ int php_memc_set_option(php_memc_object_t *intern, long option, zval *value)
29302899
* (non-weighted) case. We have to clean up ourselves.
29312900
*/
29322901
if (!lval) {
2933-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX > 0x00037000
2934-
(void)memcached_behavior_set_key_hash(intern->memc, MEMCACHED_HASH_DEFAULT);
2935-
(void)memcached_behavior_set_distribution_hash(intern->memc, MEMCACHED_HASH_DEFAULT);
2936-
(void)memcached_behavior_set_distribution(intern->memc, MEMCACHED_DISTRIBUTION_MODULA);
2937-
#else
2938-
intern->memc->hash = 0;
2939-
intern->memc->distribution = 0;
2940-
#endif
2902+
(void)memcached_behavior_set_key_hash(intern->memc, MEMCACHED_HASH_DEFAULT);
2903+
(void)memcached_behavior_set_distribution_hash(intern->memc, MEMCACHED_HASH_DEFAULT);
2904+
(void)memcached_behavior_set_distribution(intern->memc, MEMCACHED_DISTRIBUTION_MODULA);
29412905
}
29422906
break;
29432907

@@ -4020,10 +3984,10 @@ static zend_function_entry memcached_class_methods[] = {
40203984

40213985
MEMC_ME(set, arginfo_set)
40223986
MEMC_ME(setByKey, arginfo_setByKey)
4023-
#ifdef HAVE_MEMCACHED_TOUCH
3987+
40243988
MEMC_ME(touch, arginfo_touch)
40253989
MEMC_ME(touchByKey, arginfo_touchByKey)
4026-
#endif
3990+
40273991
MEMC_ME(setMulti, arginfo_setMulti)
40283992
MEMC_ME(setMultiByKey, arginfo_setMultiByKey)
40293993

@@ -4055,11 +4019,9 @@ static zend_function_entry memcached_class_methods[] = {
40554019
MEMC_ME(quit, arginfo_quit)
40564020
MEMC_ME(flushBuffers, arginfo_flushBuffers)
40574021

4058-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00049000
40594022
MEMC_ME(getLastErrorMessage, arginfo_getLastErrorMessage)
40604023
MEMC_ME(getLastErrorCode, arginfo_getLastErrorCode)
40614024
MEMC_ME(getLastErrorErrno, arginfo_getLastErrorErrno)
4062-
#endif
40634025
MEMC_ME(getLastDisconnectedServer, arginfo_getLastDisconnectedServer)
40644026

40654027
MEMC_ME(getStats, arginfo_getStats)
@@ -4252,9 +4214,7 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
42524214
REGISTER_MEMC_CLASS_CONST_LONG(OPT_DISTRIBUTION, MEMCACHED_BEHAVIOR_DISTRIBUTION);
42534215
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_MODULA, MEMCACHED_DISTRIBUTION_MODULA);
42544216
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_CONSISTENT, MEMCACHED_DISTRIBUTION_CONSISTENT);
4255-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00049000
42564217
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_VIRTUAL_BUCKET, MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET);
4257-
#endif
42584218
REGISTER_MEMC_CLASS_CONST_LONG(OPT_LIBKETAMA_COMPATIBLE, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
42594219
REGISTER_MEMC_CLASS_CONST_LONG(OPT_LIBKETAMA_HASH, MEMCACHED_BEHAVIOR_KETAMA_HASH);
42604220
REGISTER_MEMC_CLASS_CONST_LONG(OPT_TCP_KEEPALIVE, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE);
@@ -4280,14 +4240,10 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
42804240
REGISTER_MEMC_CLASS_CONST_LONG(OPT_SORT_HOSTS, MEMCACHED_BEHAVIOR_SORT_HOSTS);
42814241
REGISTER_MEMC_CLASS_CONST_LONG(OPT_VERIFY_KEY, MEMCACHED_BEHAVIOR_VERIFY_KEY);
42824242
REGISTER_MEMC_CLASS_CONST_LONG(OPT_USE_UDP, MEMCACHED_BEHAVIOR_USE_UDP);
4283-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00037000
42844243
REGISTER_MEMC_CLASS_CONST_LONG(OPT_NUMBER_OF_REPLICAS, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS);
42854244
REGISTER_MEMC_CLASS_CONST_LONG(OPT_RANDOMIZE_REPLICA_READ, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ);
4286-
#endif
4287-
#ifdef HAVE_MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS
42884245
REGISTER_MEMC_CLASS_CONST_LONG(OPT_REMOVE_FAILED_SERVERS, MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS);
4289-
#endif
4290-
#ifdef HAVE_MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT
4246+
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000018
42914247
REGISTER_MEMC_CLASS_CONST_LONG(OPT_SERVER_TIMEOUT_LIMIT, MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT);
42924248
#endif
42934249

0 commit comments

Comments
 (0)