From 7a8f4193836a81b31c51eb69cc4eaa22a62c2836 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 19 Mar 2019 12:37:08 +0100 Subject: update to 4.0.2 from https://github.com/websupport-sk/pecl-memcache add patch for PHP < 7.2 from https://github.com/websupport-sk/pecl-memcache/pull/40 add patch to allow session.save_path from https://github.com/websupport-sk/pecl-memcache/pull/45 --- 26.patch | 22 ------ 30.patch | 211 ------------------------------------------------- 40.patch | 24 ++++++ 45.patch | 114 ++++++++++++++++++++++++++ PHPINFO | 11 ++- REFLECTION | 29 ++++++- php-pecl-memcache.spec | 54 ++++++++----- 7 files changed, 211 insertions(+), 254 deletions(-) delete mode 100644 26.patch delete mode 100644 30.patch create mode 100644 40.patch create mode 100644 45.patch diff --git a/26.patch b/26.patch deleted file mode 100644 index 5081b6c..0000000 --- a/26.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 4a9e4ab0d12150805feca3012854de9fd4e5a721 Mon Sep 17 00:00:00 2001 -From: Remi Collet -Date: Fri, 6 Oct 2017 12:08:28 +0200 -Subject: [PATCH] Fix #23 Failed to read session data with 7.1/7.2 - ---- - php7/memcache_session.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/php7/memcache_session.c b/php7/memcache_session.c -index dd2434a..45ba97d 100644 ---- a/php7/memcache_session.c -+++ b/php7/memcache_session.c -@@ -289,7 +289,7 @@ PS_READ_FUNC(memcache) - ZVAL_NULL(&addresult); - - /* third request fetches the data, data is only valid if either of the lock requests succeeded */ -- ZVAL_NULL(&dataresult); -+ ZVAL_EMPTY_STRING(&dataresult); - - /* create requests */ - if (php_mmc_session_read_request(pool, &zkey, lockparam, &addresult, dataparam, &lockrequest, &addrequest, &datarequest) != MMC_OK) { diff --git a/30.patch b/30.patch deleted file mode 100644 index 75a59ca..0000000 --- a/30.patch +++ /dev/null @@ -1,211 +0,0 @@ -From 82f7fa12daef81f4a9b3c923c848a53dcc1b3b23 Mon Sep 17 00:00:00 2001 -From: Remi Collet -Date: Fri, 22 Jun 2018 13:57:47 +0200 -Subject: [PATCH 1/2] fix for PHP 7.3 + fix build warnings - ---- - php7/memcache.c | 14 +++++++++++++- - php7/memcache_binary_protocol.c | 9 ++------- - php7/memcache_pool.c | 2 -- - php7/memcache_session.c | 19 ++++++++++++++++++- - 4 files changed, 33 insertions(+), 11 deletions(-) - -diff --git a/php7/memcache.c b/php7/memcache.c -index f5b5c34..3a6c000 100644 ---- a/php7/memcache.c -+++ b/php7/memcache.c -@@ -621,7 +621,6 @@ static void php_mmc_numeric(INTERNAL_FUNCTION_PARAMETERS, int deleted, int inver - - if (Z_TYPE_P(keys) == IS_ARRAY) { - zval *key; -- zend_ulong key_index; - - if (deleted) { - /* changed to true/false by mmc_numeric_response_handler */ -@@ -728,7 +727,12 @@ mmc_t *mmc_find_persistent(const char *host, int host_len, unsigned short port, - mmc = mmc_server_new(host, host_len, port, udp_port, 1, timeout, retry_interval); - le->type = le_memcache_server; - le->ptr = mmc; -+#if PHP_VERSION_ID < 70300 - GC_REFCOUNT(le) = 1; -+#else -+ GC_SET_REFCOUNT(le, 1); -+#endif -+ - - /* register new persistent connection */ - if (zend_hash_str_update_mem(&EG(persistent_list), key, key_len, le, sizeof(*le)) == NULL) { -@@ -786,7 +790,11 @@ static mmc_t *php_mmc_pool_addserver( - pool->failure_callback = &php_mmc_failure_callback; - list_res = zend_register_resource(pool, le_memcache_pool); - add_property_resource(mmc_object, "connection", list_res); -+#if PHP_VERSION_ID < 70300 - GC_REFCOUNT(list_res)++; -+#else -+ GC_ADDREF(list_res); -+#endif - } - else { - pool = zend_fetch_resource_ex(connection, "connection", le_memcache_pool); -@@ -870,7 +878,11 @@ static void php_mmc_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool persistent) - mmc_object = return_value; - object_init_ex(mmc_object, memcache_ce); - add_property_resource(mmc_object, "connection", list_res); -+#if PHP_VERSION_ID < 70300 - GC_REFCOUNT(list_res)++; -+#else -+ GC_ADDREF(list_res); -+#endif - } else { - RETVAL_TRUE; - } -diff --git a/php7/memcache_binary_protocol.c b/php7/memcache_binary_protocol.c -index d1926cc..dfd8060 100644 ---- a/php7/memcache_binary_protocol.c -+++ b/php7/memcache_binary_protocol.c -@@ -239,7 +239,6 @@ static int mmc_request_parse_response(mmc_t *mmc, mmc_request_t *request) /* - { - mmc_response_header_t *header; - mmc_binary_request_t *req = (mmc_binary_request_t *)request; -- size_t size_header = sizeof(mmc_response_header_t); - - header = (mmc_response_header_t *)mmc_stream_get(request->io, sizeof(mmc_response_header_t)); - -@@ -564,7 +563,7 @@ static int mmc_binary_store( - return status; - } - -- header = (mmc_store_request_header_t *)(request->sendbuf.value.c + prevlen); -+ header = (mmc_store_append_header_t *)(request->sendbuf.value.c + prevlen); - - mmc_pack_header(&(header->base), op, 0, key_len, sizeof(mmc_store_append_header_t) - sizeof(mmc_request_header_t), request->sendbuf.value.len - valuelen); - header->base.cas = htonll(cas); -@@ -631,7 +630,6 @@ static void mmc_binary_mutate(mmc_request_t *request, zval *zkey, const char *ke - { - mmc_mutate_request_header_t header; - mmc_binary_request_t *req = (mmc_binary_request_t *)request; -- const size_t request_header_size = sizeof(mmc_request_header_t); - uint8_t op; - - request->parse = mmc_request_parse_response; -@@ -720,12 +718,10 @@ static void mmc_binary_stats(mmc_request_t *request, const char *type, long slab - - static void mmc_set_sasl_auth_data(mmc_pool_t *pool, mmc_request_t *request, const char *user, const char *password) /* {{{ */ - { -- const char *key = "PLAIN"; - const unsigned int key_len = 5; -- int prevlen, valuelen; -+ int prevlen; - mmc_sasl_request_header *header; - mmc_binary_request_t *req = (mmc_binary_request_t *)request; -- unsigned int flags = 0; - - request->parse = mmc_request_parse_response; - req->next_parse_handler = mmc_request_read_response; -@@ -740,7 +736,6 @@ static void mmc_set_sasl_auth_data(mmc_pool_t *pool, mmc_request_t *request, con - - /* append key and data */ - smart_string_appendl(&(request->sendbuf.value), "PLAIN", 5); -- valuelen = request->sendbuf.value.len; - - /* initialize header */ - header = (mmc_sasl_request_header *)(request->sendbuf.value.c + prevlen); -diff --git a/php7/memcache_pool.c b/php7/memcache_pool.c -index 3aea80c..f6e016b 100644 ---- a/php7/memcache_pool.c -+++ b/php7/memcache_pool.c -@@ -44,7 +44,6 @@ ZEND_DECLARE_MODULE_GLOBALS(memcache) - MMC_POOL_INLINE void mmc_buffer_alloc(mmc_buffer_t *buffer, unsigned int size) /* - ensures space for an additional size bytes {{{ */ - { -- register size_t newlen; - smart_string_alloc((&(buffer->value)), size, 0); - } - /* }}} */ -@@ -432,7 +431,6 @@ int mmc_unpack_value( - { - char *data = NULL; - unsigned long data_len; -- int rv; - - zval object; - -diff --git a/php7/memcache_session.c b/php7/memcache_session.c -index dd2434a..98cfde1 100644 ---- a/php7/memcache_session.c -+++ b/php7/memcache_session.c -@@ -102,7 +102,11 @@ PS_OPEN_FUNC(memcache) - if (url->query != NULL) { - array_init(¶ms); - -+#if PHP_VERSION_ID < 70300 - sapi_module.treat_data(PARSE_STRING, estrdup(url->query), ¶ms); -+#else -+ sapi_module.treat_data(PARSE_STRING, estrdup(ZSTR_VAL(url->query)), ¶ms); -+#endif - - if ((param = zend_hash_str_find(Z_ARRVAL(params), "persistent", sizeof("persistent")-1)) != NULL) { - convert_to_boolean_ex(param); -@@ -132,9 +136,15 @@ PS_OPEN_FUNC(memcache) - zval_ptr_dtor(¶ms); - } - -+#if PHP_VERSION_ID < 70300 - if (url->scheme && url->path && !strcmp(url->scheme, "file")) { - char *host; - int host_len = spprintf(&host, 0, "unix://%s", url->path); -+#else -+ if (url->scheme && url->path && !strcmp(ZSTR_VAL(url->scheme), "file")) { -+ char *host; -+ int host_len = spprintf(&host, 0, "unix://%s", ZSTR_VAL(url->path)); -+#endif - - /* chop off trailing :0 port specifier */ - if (!strcmp(host + host_len - 2, ":0")) { -@@ -158,14 +168,21 @@ PS_OPEN_FUNC(memcache) - return FAILURE; - } - -+#if PHP_VERSION_ID < 70300 - if (persistent) { - mmc = mmc_find_persistent(url->host, strlen(url->host), url->port, udp_port, timeout, retry_interval); - } - else { - mmc = mmc_server_new(url->host, strlen(url->host), url->port, udp_port, 0, timeout, retry_interval); - } -+#else -+ if (persistent) { -+ mmc = mmc_find_persistent(ZSTR_VAL(url->host), ZSTR_LEN(url->host), url->port, udp_port, timeout, retry_interval); -+ } else { -+ mmc = mmc_server_new(ZSTR_VAL(url->host), ZSTR_LEN(url->host), url->port, udp_port, 0, timeout, retry_interval); -+ } -+#endif - } -- - mmc_pool_add(pool, mmc, weight); - php_url_free(url); - } - -From 09e21a63410cbfd8827c7a876d8160a6b80b076c Mon Sep 17 00:00:00 2001 -From: Remi Collet -Date: Fri, 22 Jun 2018 15:11:07 +0200 -Subject: [PATCH 2/2] readd this for php < 7.2 - ---- - php7/memcache_pool.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/php7/memcache_pool.c b/php7/memcache_pool.c -index f6e016b..86e8983 100644 ---- a/php7/memcache_pool.c -+++ b/php7/memcache_pool.c -@@ -44,6 +44,9 @@ ZEND_DECLARE_MODULE_GLOBALS(memcache) - MMC_POOL_INLINE void mmc_buffer_alloc(mmc_buffer_t *buffer, unsigned int size) /* - ensures space for an additional size bytes {{{ */ - { -+#if PHP_VERSION_ID < 70200 -+ register size_t newlen; -+#endif - smart_string_alloc((&(buffer->value)), size, 0); - } - /* }}} */ diff --git a/40.patch b/40.patch new file mode 100644 index 0000000..678ad3e --- /dev/null +++ b/40.patch @@ -0,0 +1,24 @@ +From 315cf20acea252da86b1e3524dd2a018cb6e5dae Mon Sep 17 00:00:00 2001 +From: Jan Ehrhardt +Date: Tue, 12 Mar 2019 09:06:52 +0100 +Subject: [PATCH] readd this for php < 7.2 + +Remaining part of https://github.com/websupport-sk/pecl-memcache/pull/30 +--- + php7/memcache_pool.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/php7/memcache_pool.c b/php7/memcache_pool.c +index 5bea3e1..ffeb744 100644 +--- a/php7/memcache_pool.c ++++ b/php7/memcache_pool.c +@@ -44,6 +44,9 @@ ZEND_DECLARE_MODULE_GLOBALS(memcache) + MMC_POOL_INLINE void mmc_buffer_alloc(mmc_buffer_t *buffer, unsigned int size) /* + ensures space for an additional size bytes {{{ */ + { ++#if PHP_VERSION_ID < 70200 ++ register size_t newlen; ++#endif + smart_string_alloc((&(buffer->value)), size, 0); + } + /* }}} */ diff --git a/45.patch b/45.patch new file mode 100644 index 0000000..3e7e196 --- /dev/null +++ b/45.patch @@ -0,0 +1,114 @@ +From fd0cc8c9b0171a36116917332acc9f479e45ec81 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Tue, 19 Mar 2019 11:12:37 +0100 +Subject: [PATCH] allow to work with standard session.save_path option and + session_save_path function + +--- + php7/memcache_session.c | 8 +++-- + tests/036b.phpt | 70 +++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 76 insertions(+), 2 deletions(-) + create mode 100644 tests/036b.phpt + +diff --git a/php7/memcache_session.c b/php7/memcache_session.c +index 7807942..4cc356d 100644 +--- a/php7/memcache_session.c ++++ b/php7/memcache_session.c +@@ -56,7 +56,12 @@ PS_OPEN_FUNC(memcache) + zval params, *param; + int i, j, path_len; + +- char *path = MEMCACHE_G(session_save_path); ++ const char *path = MEMCACHE_G(session_save_path); ++ if (!path) { ++ /* allow to work with standard session.save_path option ++ and session_save_path function */ ++ path = save_path; ++ } + if (!path) { + PS_SET_MOD_DATA(NULL); + return FAILURE; +@@ -98,7 +103,6 @@ PS_OPEN_FUNC(memcache) + if (!url) { + php_error_docref(NULL, E_WARNING, + "Failed to parse memcache.save_path (error at offset %d, url was '%s')", i, path); +- efree(path); + + mmc_pool_free(pool); + PS_SET_MOD_DATA(NULL); +diff --git a/tests/036b.phpt b/tests/036b.phpt +new file mode 100644 +index 0000000..858807a +--- /dev/null ++++ b/tests/036b.phpt +@@ -0,0 +1,70 @@ ++--TEST-- ++ini_set('session.save_path') ++--SKIPIF-- ++ ++--FILE-- ++get($id); ++session_write_close(); ++$result3 = $memcache->get($id); ++ ++// Test destroy ++$result4 = session_start(); ++$result5 = session_destroy(); ++$result6 = $memcache->get($id); ++ ++// Test large session ++$session_save_path = "tcp://$host:$port"; ++session_save_path($session_save_path); ++ ++session_start(); ++$largeval = str_repeat('a', 1024*2048); ++$_SESSION['_test_key']= $largeval; ++session_write_close(); ++ ++// test large cookie lifetime ++ini_set('session.gc_maxlifetime', 1209600); ++$result7 = session_start(); ++$id = session_id(); ++$_SESSION['_test_key'] = 'Test'; ++$result8 = $memcache->get($id); ++session_write_close(); ++$result9 = $memcache->get($id); ++ ++ ++var_dump($result1); ++var_dump($id); ++var_dump($result2); ++var_dump($result3); ++var_dump($result4); ++var_dump($result5); ++var_dump($result6); ++var_dump($result7); ++var_dump($result8); ++var_dump($result9); ++ ++?> ++--EXPECTF-- ++bool(true) ++string(%d) "%s" ++bool(false) ++string(%d) "%s" ++bool(true) ++bool(true) ++bool(false) ++bool(true) ++string(%d) "%s" ++string(%d) "%s" diff --git a/PHPINFO b/PHPINFO index 8b0f580..1e53c44 100644 --- a/PHPINFO +++ b/PHPINFO @@ -2,7 +2,7 @@ memcache memcache support => enabled -Version => 3.0.9-dev +Version => 4.0.2 Revision => $Revision$ Directive => Local Value => Master Value @@ -17,3 +17,12 @@ memcache.redundancy => 1 => 1 memcache.session_redundancy => 2 => 2 memcache.compress_threshold => 20000 => 20000 memcache.lock_timeout => 15 => 15 +memcache.session_prefix_host_key => 0 => 0 +memcache.session_prefix_host_key_remove_www => 1 => 1 +memcache.session_prefix_host_key_remove_subdomain => 0 => 0 +memcache.session_prefix_static_key => no value => no value +memcache.session_save_path => no value => no value +memcache.prefix_host_key => 0 => 0 +memcache.prefix_host_key_remove_www => 1 => 1 +memcache.prefix_host_key_remove_subdomain => 0 => 0 +memcache.prefix_static_key => no value => no value diff --git a/REFLECTION b/REFLECTION index a7c17af..d71f371 100644 --- a/REFLECTION +++ b/REFLECTION @@ -1,4 +1,4 @@ -Extension [ extension #105 memcache version 3.0.9-dev ] { +Extension [ extension #118 memcache version 4.0.2 ] { - INI { Entry [ memcache.allow_failover ] @@ -34,6 +34,33 @@ Extension [ extension #105 memcache version 3.0.9-dev ] { Entry [ memcache.lock_timeout ] Current = '15' } + Entry [ memcache.session_prefix_host_key ] + Current = '0' + } + Entry [ memcache.session_prefix_host_key_remove_www ] + Current = '1' + } + Entry [ memcache.session_prefix_host_key_remove_subdomain ] + Current = '0' + } + Entry [ memcache.session_prefix_static_key ] + Current = '' + } + Entry [ memcache.session_save_path ] + Current = '' + } + Entry [ memcache.prefix_host_key ] + Current = '0' + } + Entry [ memcache.prefix_host_key_remove_www ] + Current = '1' + } + Entry [ memcache.prefix_host_key_remove_subdomain ] + Current = '0' + } + Entry [ memcache.prefix_static_key ] + Current = '' + } } - Constants [6] { diff --git a/php-pecl-memcache.spec b/php-pecl-memcache.spec index 21959cc..7a76e47 100644 --- a/php-pecl-memcache.spec +++ b/php-pecl-memcache.spec @@ -12,11 +12,12 @@ %endif # https://github.com/websupport-sk/pecl-memcache/commits/NON_BLOCKING_IO_php7 -%global gh_commit e702b5f91ec222e20d1d5cea0ffc6be012992d70 +%global gh_commit ddda96f7bfa0f0bba9ffb6974215ced8a1b80010 %global gh_short %(c=%{gh_commit}; echo ${c:0:7}) %global gh_owner websupport-sk %global gh_project pecl-memcache -%global gh_date 20170802 +%global gh_date 20190319 +#global prever dev %global pecl_name memcache # Not ready, some failed UDP tests. Neded investigation. %global with_tests 0%{?_with_tests:1} @@ -29,19 +30,18 @@ Summary: Extension to work with the Memcached caching daemon Name: %{?scl_prefix}php-pecl-memcache -Version: 3.0.9 -%if 0%{?gh_date:1} +Version: 4.0.2 +%if 0%{?prever:1} Release: 0.13.%{gh_date}.%{gh_short}%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} -Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{pecl_name}-%{version}-%{gh_short}.tar.gz %else -Release: 5%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} -Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz +Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} %endif +Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{pecl_name}-%{version}-%{gh_short}.tar.gz License: PHP URL: http://pecl.php.net/package/%{pecl_name} -Patch0: https://patch-diff.githubusercontent.com/raw/websupport-sk/pecl-memcache/pull/26.patch -Patch1: https://patch-diff.githubusercontent.com/raw/websupport-sk/pecl-memcache/pull/30.patch +Patch0: https://patch-diff.githubusercontent.com/raw/websupport-sk/pecl-memcache/pull/40.patch +Patch1: https://patch-diff.githubusercontent.com/raw/websupport-sk/pecl-memcache/pull/45.patch BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?scl_prefix}php-devel @@ -118,13 +118,13 @@ Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSIO %prep %setup -c -q -%if 0%{?gh_date:1} +%if 1 mv %{gh_project}-%{gh_commit} NTS %{__php} -r ' $pkg = simplexml_load_file("NTS/package.xml"); $pkg->date = substr("%{gh_date}",0,4)."-".substr("%{gh_date}",4,2)."-".substr("%{gh_date}",6,2); - $pkg->version->release = "%{version}dev"; - $pkg->stability->release = "devel"; + $pkg->version->release = "%{version}%{?prever}"; + $pkg->stability->release = "%{?prever}%{!?prever:stable}"; $pkg->asXML("package.xml"); ' %else @@ -137,16 +137,14 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml pushd NTS -%if "%{php_version}" > "7.1" -%patch0 -p1 -b .gh26 -%endif -%patch1 -p1 -b .gh30 +%patch0 -p1 -b .gh40 +%patch1 -p1 -b .gh45 # Chech version as upstream often forget to update this dir=php$(%{__php} -r 'echo PHP_MAJOR_VERSION;') extver=$(sed -n '/#define PHP_MEMCACHE_VERSION/{s/.* "//;s/".*$//;p}' $dir/php_memcache.h) -if test "x${extver}" != "x%{version}%{?gh_date:-dev}"; then - : Error: Upstream version is now ${extver}, expecting %{version}%{?gh_date:-dev}. +if test "x${extver}" != "x%{version}%{?prever:-%{prever}}"; then + : Error: Upstream version is now ${extver}, expecting %{version}%{?prever:-%{prever}} : Update the pdover macro and rebuild. exit 1 fi @@ -182,6 +180,11 @@ extension=%{pecl_name}.so ; Lock Timeout ;memcache.lock_timeout = 15 +;memcache.prefix_host_key = 0 +;memcache.prefix_host_key_remove_www = 1 +;memcache.prefix_host_key_remove_subdomain = 0 +;memcache.prefix_static_key = '' + ; ----- Options to use the memcache session handler ; RPM note : save_handler and save_path are defined @@ -191,7 +194,13 @@ extension=%{pecl_name}.so ; Use memcache as a session handler ;session.save_handler=memcache ; Defines a comma separated of server urls to use for session storage +; Only used when memcache.session_save_path is not set ;session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15" +;memcache.session_prefix_host_key = 0 +;memcache.session_prefix_host_key_remove_www = 1 +;memcache.session_prefix_host_key_remove_subdomain = 0 +;memcache.session_prefix_static_key = '' +;memcache.session_save_path = '' EOF %if %{with_zts} @@ -256,7 +265,7 @@ sed -e "s:/var/run/memcached/memcached.sock:$PWD/memcached.sock:" \ -i tests/connect.inc : Udp tests -rm tests/0{36,38,39,55,57}.phpt +rm tests/0{35,40,44,53}.phpt tests/bug73539.phpt : Launch the daemons memcached -p 11211 -U 11211 -d -P $PWD/memcached1.pid @@ -315,6 +324,13 @@ fi %changelog +* Tue Mar 19 2019 Remi Collet - 4.0.2-2 +- update to 4.0.2 from https://github.com/websupport-sk/pecl-memcache +- add patch for PHP < 7.2 from + https://github.com/websupport-sk/pecl-memcache/pull/40 +- add patch to allow session.save_path from + https://github.com/websupport-sk/pecl-memcache/pull/45 + * Mon Jan 21 2019 Remi Collet - 3.0.9-0.13.20170802.e702b5f - refresh patch (for php < 7.2) -- cgit