Skip to content

Commit b1300bf

Browse files
committed
Merge in upstream changes from master branch of php-memcached GitHub project (3.0.1 release)
2 parents 4a3a80b + 71f20e1 commit b1300bf

12 files changed

+171
-74
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
- LIBMEMCACHED_VERSION=1.0.18 # Debian Jessie / Ubuntu Xenial
1414
- LIBMEMCACHED_VERSION=1.0.16 # RHEL / CentOS 7
1515
- LIBMEMCACHED_VERSION=1.0.8 # Debian Wheezy / Ubuntu Trusty
16+
- LIBMEMCACHED_VERSION=1.0.2 # Ancient
1617

1718
addons:
1819
apt:
@@ -22,11 +23,12 @@ addons:
2223
- libevent-dev
2324

2425
before_script:
26+
- sudo apt-get purge -qq '^memcached*' '^libmemcached*'
2527
- ./.travis/travis.sh before_script $LIBMEMCACHED_VERSION
2628

2729
script:
2830
- ./.travis/travis.sh script $LIBMEMCACHED_VERSION
2931

3032
cache:
3133
directories:
32-
- $HOME/cache
34+
- $HOME/cache

ChangeLog

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
memcached extension changelog
22

3+
Version 3.0.1 (2017-02-07)
4+
-------------
5+
6+
* Add API entries for flushBuffers() and getAllKeys() (#316)
7+
* Ignore specific errors from memcached_dump for getAllKeys() with newer memcached servers (#315)
8+
* Fix compiling with memcached binary protocol enabled (#312)
9+
* Restore php_libmemcached_compat with workaround for missing memcached_exists (#314)
10+
* Travis CI purge old versions of memcached and libmemcached (#309)
11+
312
Version 3.0.0 (2017-01-27)
413
--------------------------
514
* Support for PHP 7.0 and PHP 7.1

config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ if test "$PHP_MEMCACHED" != "no"; then
318318
AC_DEFINE(HAVE_MEMCACHED_EXIST, [1], [Whether memcached_exist is defined])
319319
fi
320320

321-
PHP_MEMCACHED_FILES="php_memcached.c g_fmt.c"
321+
PHP_MEMCACHED_FILES="php_memcached.c php_libmemcached_compat.c g_fmt.c"
322322

323323
if test "$PHP_SYSTEM_FASTLZ" != "no"; then
324324
AC_CHECK_HEADERS([fastlz.h], [ac_cv_have_fastlz="yes"], [ac_cv_have_fastlz="no"])

memcached-api.php

+4
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,11 @@ public function getLastDisconnectedServer( ) {}
286286

287287
public function flush( $delay = 0 ) {}
288288

289+
public function flushBuffers( ) {}
290+
289291
public function getStats( $type = null ) {}
292+
293+
public function getAllKeys( ) {}
290294

291295
public function getVersion( ) {}
292296

package.xml

+47-22
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
2121
<email>[email protected]</email>
2222
<active>yes</active>
2323
</lead>
24-
<date>2017-01-27</date>
24+
<date>2017-02-07</date>
2525
<version>
26-
<release>3.0.0</release>
26+
<release>3.0.1</release>
2727
<api>3.0.0</api>
2828
</version>
2929
<stability>
@@ -36,26 +36,12 @@ PHP7 release of memcached extension. Note that support for libmemcached 0.x seri
3636
and the oldest actively tested version is 1.0.2. It is highly recommended to use version 1.0.18 of
3737
libmemcached.
3838

39-
API
40-
* The method signature of get, getByKey, getMulti, and getMultiByKey changed.
41-
* get* and getMulti* commands no longer take cas or user flags parameters.
42-
* get* and getMulti* commands now take the Memcached::GET_EXTENDED flag to retrieve user flags and cas tokens.
43-
* Fixes getStats command to return all stats from all servers
44-
* Fixes allKeys command behaviour
45-
* Fixes error where cache callback for get command was not setting expiration time properly
46-
* Added server type to server list
47-
* Remove use_sasl ini-variable and initialise sasl as needed
48-
* CAS tokens are returned as integers and they overflow to strings as needed
49-
50-
Session handler
51-
* The session memcached protocol config name was changed, and the default protocol was changed from text to binary protocol. If your memcached setup does not support the binary protocol(e.g. if using twemproxy), then set memcached.sess_binary_protocol = Off. (Previously called memcached.sess_binary)
52-
* Session lock algorithm updated (new ini-values memcached.sess_lock_wait_min, memcached.sess_lock_wait_max and memcached.sess_lock_retries)
53-
* Session extension uses PHP allocators (still some work to do on the rest of the extension)
54-
* Ini-values take effect during session_start or session_regenerate_id
55-
* Fixes crash with session_regenerate_id (work-around for PHP bug)
56-
57-
Tests
58-
* Fix several problematic tests
39+
Fixes
40+
* Add API entries for flushBuffers() and getAllKeys() (#316)
41+
* Ignore specific errors from memcached_dump for getAllKeys() with newer memcached servers (#315)
42+
* Fix compiling with memcached binary protocol enabled (#312)
43+
* Restore php_libmemcached_compat with workaround for missing memcached_exists (#314)
44+
* Travis CI purge old versions of memcached and libmemcached (#309)
5945
</notes>
6046
<contents>
6147
<dir name="/">
@@ -73,6 +59,8 @@ Tests
7359
<file role='src' name='php_memcached_private.h'/>
7460
<file role='src' name='php_memcached_session.c'/>
7561
<file role='src' name='php_memcached_session.h'/>
62+
<file role='src' name='php_libmemcached_compat.h'/>
63+
<file role='src' name='php_libmemcached_compat.c'/>
7664
<file role='src' name='php_memcached_server.h'/>
7765
<file role='src' name='php_memcached_server.c'/>
7866
<file role='src' name='g_fmt.c'/>
@@ -194,6 +182,43 @@ Tests
194182
<configureoption name="with-libmemcached-dir" default="no" prompt="libmemcached directory"/>
195183
</extsrcrelease>
196184
<changelog>
185+
<release>
186+
<stability>
187+
<release>stable</release>
188+
<api>stable</api>
189+
</stability>
190+
<version>
191+
<release>3.0.0</release>
192+
<api>3.0.0</api>
193+
</version>
194+
<date>2016-01-27</date>
195+
<notes>
196+
PHP7 release of memcached extension. Note that support for libmemcached 0.x series has been discontinued
197+
and the oldest actively tested version is 1.0.2. It is highly recommended to use version 1.0.18 of
198+
libmemcached.
199+
200+
API
201+
* The method signature of get, getByKey, getMulti, and getMultiByKey changed.
202+
* get* and getMulti* commands no longer take cas or user flags parameters.
203+
* get* and getMulti* commands now take the Memcached::GET_EXTENDED flag to retrieve user flags and cas tokens.
204+
* Fixes getStats command to return all stats from all servers
205+
* Fixes allKeys command behaviour
206+
* Fixes error where cache callback for get command was not setting expiration time properly
207+
* Added server type to server list
208+
* Remove use_sasl ini-variable and initialise sasl as needed
209+
* CAS tokens are returned as integers and they overflow to strings as needed
210+
211+
Session handler
212+
* The session memcached protocol config name was changed, and the default protocol was changed from text to binary protocol. If your memcached setup does not support the binary protocol(e.g. if using tw
213+
* Session lock algorithm updated (new ini-values memcached.sess_lock_wait_min, memcached.sess_lock_wait_max and memcached.sess_lock_retries)
214+
* Session extension uses PHP allocators (still some work to do on the rest of the extension)
215+
* Ini-values take effect during session_start or session_regenerate_id
216+
* Fixes crash with session_regenerate_id (work-around for PHP bug)
217+
218+
Tests
219+
* Fix several problematic tests
220+
</notes>
221+
</release>
197222
<release>
198223
<stability>
199224
<release>alpha</release>

php_libmemcached_compat.c

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| Copyright (c) 2009 The PHP Group |
4+
+----------------------------------------------------------------------+
5+
| This source file is subject to version 3.0 of the PHP license, |
6+
| that is bundled with this package in the file LICENSE, and is |
7+
| available through the world-wide-web at the following url: |
8+
| http://www.php.net/license/3_0.txt. |
9+
| If you did not receive a copy of the PHP license and are unable to |
10+
| obtain it through the world-wide-web, please send a note to |
11+
| [email protected] so we can mail you a copy immediately. |
12+
+----------------------------------------------------------------------+
13+
| Authors: Andrei Zmievski <[email protected]> |
14+
+----------------------------------------------------------------------+
15+
*/
16+
17+
#include "php_memcached.h"
18+
#include "php_memcached_private.h"
19+
#include "php_libmemcached_compat.h"
20+
21+
memcached_return php_memcached_exist (memcached_st *memc, zend_string *key)
22+
{
23+
#ifdef HAVE_MEMCACHED_EXIST
24+
return memcached_exist (memc, key->val, key->len);
25+
#else
26+
memcached_return rc = MEMCACHED_SUCCESS;
27+
uint32_t flags = 0;
28+
size_t value_length = 0;
29+
char *value = NULL;
30+
31+
value = memcached_get (memc, key->val, key->len, &value_length, &flags, &rc);
32+
if (value) {
33+
free (value);
34+
}
35+
return rc;
36+
#endif
37+
}

php_libmemcached_compat.h

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| Copyright (c) 2009 The PHP Group |
4+
+----------------------------------------------------------------------+
5+
| This source file is subject to version 3.0 of the PHP license, |
6+
| that is bundled with this package in the file LICENSE, and is |
7+
| available through the world-wide-web at the following url: |
8+
| http://www.php.net/license/3_0.txt. |
9+
| If you did not receive a copy of the PHP license and are unable to |
10+
| obtain it through the world-wide-web, please send a note to |
11+
| [email protected] so we can mail you a copy immediately. |
12+
+----------------------------------------------------------------------+
13+
| Authors: Andrei Zmievski <[email protected]> |
14+
+----------------------------------------------------------------------+
15+
*/
16+
17+
#ifndef PHP_LIBMEMCACHED_COMPAT
18+
#define PHP_LIBMEMCACHED_COMPAT
19+
20+
/* this is the version(s) we support */
21+
#include <libmemcached/memcached.h>
22+
23+
memcached_return php_memcached_exist (memcached_st *memc, zend_string *key);
24+
25+
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000017
26+
typedef const memcached_instance_st * php_memcached_instance_st;
27+
#else
28+
typedef memcached_server_instance_st php_memcached_instance_st;
29+
#endif
30+
31+
#endif

php_memcached.c

+12-22
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@
5151
# include "ext/msgpack/php_msgpack.h"
5252
#endif
5353

54-
#ifdef ZTS
55-
#define MEMC_G(v) TSRMG(php_memcached_globals_id, zend_php_memcached_globals *, memc.v)
56-
#else
57-
#define MEMC_G(v) (php_memcached_globals.memc.v)
58-
#endif
59-
6054
static int le_memc;
6155

6256
static int php_memc_list_entry(void) {
@@ -238,24 +232,14 @@ static inline php_memc_server_t *php_memc_server_fetch_object(zend_object *obj)
238232
}
239233
#define Z_MEMC_SERVER_P(zv) php_memc_server_fetch_object(Z_OBJ_P(zv))
240234

241-
#ifdef ZTS
242-
#define MEMC_SERVER_G(v) TSRMG(php_memcached_globals_id, zend_php_memcached_globals *, server.v)
243-
#else
244-
#define MEMC_SERVER_G(v) (php_memcached_globals.server.v)
245-
#endif
235+
static zend_object_handlers memcached_server_object_handlers;
236+
static zend_class_entry *memcached_server_ce = NULL;
246237
#endif
247238

248239
static zend_class_entry *memcached_ce = NULL;
249-
250240
static zend_class_entry *memcached_exception_ce = NULL;
251-
252241
static zend_object_handlers memcached_object_handlers;
253242

254-
#ifdef HAVE_MEMCACHED_PROTOCOL
255-
static zend_object_handlers memcached_server_object_handlers;
256-
static zend_class_entry *memcached_server_ce = NULL;
257-
#endif
258-
259243
#ifdef HAVE_SPL
260244
static zend_class_entry *spl_ce_RuntimeException = NULL;
261245
#endif
@@ -2741,7 +2725,15 @@ PHP_METHOD(Memcached, getAllKeys)
27412725
array_init(return_value);
27422726

27432727
rc = memcached_dump(intern->memc, callback, return_value, 1);
2744-
if (s_memc_status_handle_result_code(intern, rc) == FAILURE) {
2728+
2729+
/* Ignore two errors. libmemcached has a hardcoded loop of 200 slab
2730+
* classes that matches memcached < 1.4.24, at which version the server
2731+
* has only 63 slabs and throws an error when requesting the 64th slab.
2732+
*
2733+
* In multi-server some non-deterministic number of elements will be dropped.
2734+
*/
2735+
if (rc != MEMCACHED_CLIENT_ERROR && rc != MEMCACHED_SERVER_ERROR
2736+
&& s_memc_status_handle_result_code(intern, rc) == FAILURE) {
27452737
zval_dtor(return_value);
27462738
RETURN_FALSE;
27472739
}
@@ -3644,7 +3636,7 @@ PHP_METHOD(MemcachedServer, run)
36443636
static
36453637
PHP_METHOD(MemcachedServer, on)
36463638
{
3647-
long event;
3639+
zend_long event;
36483640
zend_fcall_info fci;
36493641
zend_fcall_info_cache fci_cache;
36503642
zend_bool rc = 0;
@@ -4022,7 +4014,6 @@ static zend_function_entry memcached_class_methods[] = {
40224014
MEMC_ME(getLastErrorMessage, arginfo_getLastErrorMessage)
40234015
MEMC_ME(getLastErrorCode, arginfo_getLastErrorCode)
40244016
MEMC_ME(getLastErrorErrno, arginfo_getLastErrorErrno)
4025-
40264017
MEMC_ME(getLastDisconnectedServer, arginfo_getLastDisconnectedServer)
40274018

40284019
MEMC_ME(getStats, arginfo_getStats)
@@ -4218,7 +4209,6 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
42184209
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_MODULA, MEMCACHED_DISTRIBUTION_MODULA);
42194210
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_CONSISTENT, MEMCACHED_DISTRIBUTION_CONSISTENT);
42204211
REGISTER_MEMC_CLASS_CONST_LONG(DISTRIBUTION_VIRTUAL_BUCKET, MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET);
4221-
42224212
REGISTER_MEMC_CLASS_CONST_LONG(OPT_LIBKETAMA_COMPATIBLE, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
42234213
REGISTER_MEMC_CLASS_CONST_LONG(OPT_LIBKETAMA_HASH, MEMCACHED_BEHAVIOR_KETAMA_HASH);
42244214
REGISTER_MEMC_CLASS_CONST_LONG(OPT_TCP_KEEPALIVE, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE);

php_memcached.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# include "config.h"
2828
#endif
2929

30-
#define PHP_MEMCACHED_VERSION "3.0.0"
30+
#define PHP_MEMCACHED_VERSION "3.0.1"
3131

3232
#if defined(PHP_WIN32) && defined(MEMCACHED_EXPORTS)
3333
#define PHP_MEMCACHED_API __declspec(dllexport)
@@ -42,6 +42,14 @@ PHP_MEMCACHED_API zend_class_entry *php_memc_get_exception_base(int root);
4242
extern zend_module_entry memcached_module_entry;
4343
#define phpext_memcached_ptr &memcached_module_entry
4444

45+
#ifdef ZTS
46+
#define MEMC_G(v) TSRMG(php_memcached_globals_id, zend_php_memcached_globals *, memc.v)
47+
#define MEMC_SERVER_G(v) TSRMG(php_memcached_globals_id, zend_php_memcached_globals *, server.v)
48+
#else
49+
#define MEMC_G(v) (php_memcached_globals.memc.v)
50+
#define MEMC_SERVER_G(v) (php_memcached_globals.server.v)
51+
#endif
52+
4553
#endif /* PHP_MEMCACHED_H */
4654

4755
/*

php_memcached_private.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@
2525
# include "config.h"
2626
#endif
2727

28-
#include <libmemcached/memcached.h>
29-
30-
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000017
31-
typedef const memcached_instance_st * php_memcached_instance_st;
32-
#else
33-
typedef memcached_server_instance_st php_memcached_instance_st;
34-
#endif
28+
#include "php_libmemcached_compat.h"
3529

3630
#include <stdlib.h>
3731
#include <string.h>
@@ -214,6 +208,8 @@ PHP_MINFO_FUNCTION(memcached);
214208

215209
char *php_memc_printable_func (zend_fcall_info *fci, zend_fcall_info_cache *fci_cache);
216210

211+
memcached_return php_memcached_exist (memcached_st *memc, zend_string *key);
212+
217213
zend_bool php_memc_init_sasl_if_needed();
218214

219215
#endif /* PHP_MEMCACHED_PRIVATE_H */

0 commit comments

Comments
 (0)