Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package php-memcache for openSUSE:Factory checked in at 2026-12-01 16:59:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/php-memcache (Old) and /work/SRC/openSUSE:Factory/.php-memcache.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "php-memcache" Tue Dec 1 16:59:45 2026 rev:11 rq:1401834 version:8.6 Changes: -------- --- /work/SRC/openSUSE:Factory/php-memcache/php-memcache.changes 2025-11-12 21:14:32.794534220 +0100 +++ /work/SRC/openSUSE:Factory/.php-memcache.new.1340718/php-memcache.changes 2026-12-01 17:02:58.995216266 +0100 @@ -1,0 +2,21 @@ +Mon Nov 30 19:56:07 UTC 2026 - Arjen de Korte <[email protected]> + +- Update to version 8.6 + * Fix build with PHP 8.5 and 8.6: use Zend/zend_smart_string.h, adapt + to the new PS_OPEN_ARGS signature, replace removed zval_dtor() and + wrong-parameter-count macros, and drop deprecated ini usage (#118, #120) + * Implement the session handlers PHP 8.6 requires (PS_CREATE_SID_FUNC, + PS_VALIDATE_SID_FUNC), with a new session_strict_mode test and updated + session tests (#122) + * Add a POSIX poll() I/O implementation alongside select(), fixing the + *** buffer overflow detected ***: terminated abort (#101) + * Handle file descriptors equal to or higher than FD_SETSIZE, which + cannot be used with select() (#100) + * Add composer.json to enable installation with PIE (#116) + * Update package.xml (removed cloudfile) and raise the GitHub Actions + workflow timeout +- Remove upstreamed patches + - memcache-fix-build-PHP-8.5.patch + - memcache-clean-deprecated-ini.patch + +------------------------------------------------------------------- Old: ---- memcache-8.2.tar.gz memcache-clean-deprecated-ini.patch memcache-fix-build-PHP-8.5.patch New: ---- memcache-8.6.tar.gz ----------(Old B)---------- Old: - memcache-fix-build-PHP-8.5.patch - memcache-clean-deprecated-ini.patch Old:- Remove upstreamed patches - memcache-fix-build-PHP-8.5.patch - memcache-clean-deprecated-ini.patch ----------(Old E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ php-memcache.spec ++++++ --- /var/tmp/diff_new_pack.XKqjlF/_old 2026-12-01 17:02:59.771248785 +0100 +++ /var/tmp/diff_new_pack.XKqjlF/_new 2026-12-01 17:02:59.772248827 +0100 @@ -1,7 +1,7 @@ # # spec file for package php-memcache # -# Copyright (c) 2025 SUSE LLC +# Copyright (c) 2026 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -31,7 +31,7 @@ %endif Name: %{php_name}-%{pkg_name} -Version: 8.2 +Version: 8.6 Release: 0 Summary: PHP Memcache client Extension License: PHP-3.0 @@ -41,10 +41,6 @@ Source10: php-memcache-rpmlintrc # PATCH-FIX-OPENSUSE: fix unit tests that don't work on OBS Patch1: fixup-unit-tests.patch -# PATCH-FIX-UPSTREAM https://github.com/websupport-sk/pecl-memcache/pull/118 -Patch2: memcache-fix-build-PHP-8.5.patch -# PATCH-FIX-UPSTREAM https://github.com/websupport-sk/pecl-memcache/pull/120 -Patch3: memcache-clean-deprecated-ini.patch %if 0%{?suse_version} > 1500 BuildRequires: %{php_name}-cli %endif ++++++ memcache-8.2.tar.gz -> memcache-8.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/.github/workflows/config.yml new/pecl-memcache-8.6/.github/workflows/config.yml --- old/pecl-memcache-8.2/.github/workflows/config.yml 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/.github/workflows/config.yml 2026-11-23 20:02:39.000000000 +0100 @@ -4,8 +4,9 @@ ubuntu: strategy: matrix: - version: ["8.0", "8.1", "8.2"] + version: ["8.0", "8.1", "8.2", "8.3", "8.4", "8.5", "8.6"] runs-on: ubuntu-latest + timeout-minutes: 5 steps: - name: Checkout pecl-memcache extension uses: actions/checkout@v2 @@ -33,5 +34,5 @@ run: make - name: test run: | - MEMCACHE_PROTOCOL=ascii make test TESTS="--show-diff" - MEMCACHE_PROTOCOL=binary make test TESTS="--show-diff" \ No newline at end of file + MEMCACHE_PROTOCOL=ascii make test TESTS="-j1 --show-diff" + MEMCACHE_PROTOCOL=binary make test TESTS="-j1 --show-diff" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/README new/pecl-memcache-8.6/README --- old/pecl-memcache-8.2/README 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/README 2026-11-23 20:02:39.000000000 +0100 @@ -3,12 +3,12 @@ This repository contains modified pecl-memcache plugin ported to PHP8, which was originally developed for the need of hosting company in Slovakia (Websupport.sk). -The latest release is 8.2 (released: 2023-04-30) with support for PHP 8.0+ (incl. PHP 8.2). +The latest release is 8.6 (released: 2026-11-23) with support for PHP 8.0+ (incl. PHP 8.6). Please use version 4.0.5.1 (released: 2020-12-19) for PHP 7.x from branch NON_BLOCKING_IO_php7. See: https://github.com/websupport-sk/pecl-memcache/releases -See also release on PECL: https://pecl.php.net/package/memcache +See also release on PECL: https://pecl.php.net/package/memcache (deprecated) Feel free to use it and post patches. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/composer.json new/pecl-memcache-8.6/composer.json --- old/pecl-memcache-8.2/composer.json 1970-01-01 01:00:00.000000000 +0100 +++ new/pecl-memcache-8.6/composer.json 2026-11-23 20:02:39.000000000 +0100 @@ -0,0 +1,31 @@ +{ + "name": "websupport-sk/pecl-memcache", + "type": "php-ext", + "license": "PHP-3.0", + "description": "PHP Extension - Memcache module with support of newer PHP 7.x and PHP 8.x", + "require": { + "php": ">= 8.0.0" + }, + "php-ext": { + "extension-name": "memcache", + "configure-options": [ + { + "name": "enable-memcache", + "description": "Enable memcache support" + }, + { + "name": "disable-memcache-session", + "description": "Disable memcache session handler support" + }, + { + "name": "with-zlib-dir", + "description": "Set the path to ZLIB install prefix.", + "needs-value": true + }, + { + "name": "enable-debug", + "description": "compile with debugging symbols" + } + ] + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/package.xml new/pecl-memcache-8.6/package.xml --- old/pecl-memcache-8.2/package.xml 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/package.xml 2026-11-23 20:02:39.000000000 +0100 @@ -89,7 +89,6 @@ <file name="README" role="doc" /> <file name="memcache.php" role="doc" /> <file name="Dockerfile" role="src" /> - <file name="cloudbuild.yaml" role="src" /> <file name ="tests/connect.inc" role="test" /> <file name ="tests/memcache.sh" role="test" /> <file name ="tests/001.phpt" role="test" /> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/src/memcache.c new/pecl-memcache-8.6/src/memcache.c --- old/pecl-memcache-8.2/src/memcache.c 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/src/memcache.c 2026-11-23 20:02:39.000000000 +0100 @@ -523,6 +523,33 @@ } /* }}} */ +static PHP_INI_MH(OnUpdateSelectApi) /* {{{ */ +{ + #ifdef PHP_WIN32 + if (!strcasecmp(ZSTR_VAL(new_value), "select")) { + MEMCACHE_G(select_api) = MMC_API_SELECT; + } + else { + php_error_docref(NULL, E_WARNING, "memcache.select_api supports only 'select' on Windows ('%s' given)", ZSTR_VAL(new_value)); + return FAILURE; + } + #else + if (!strcasecmp(ZSTR_VAL(new_value), "select")) { + MEMCACHE_G(select_api) = MMC_API_SELECT; + } + else if (!strcasecmp(ZSTR_VAL(new_value), "poll")) { + MEMCACHE_G(select_api) = MMC_API_POLL; + } + else { + php_error_docref(NULL, E_WARNING, "memcache.select_api must be in set {select, poll} ('%s' given)", ZSTR_VAL(new_value)); + return FAILURE; + } + #endif + + return SUCCESS; +} +/* }}} */ + static PHP_INI_MH(OnUpdatePrefixStaticKey) /* {{{ */ { int i; @@ -553,6 +580,7 @@ STD_PHP_INI_ENTRY("memcache.session_redundancy", "2", PHP_INI_ALL, OnUpdateRedundancy, session_redundancy, zend_memcache_globals, memcache_globals) STD_PHP_INI_ENTRY("memcache.compress_threshold", "20000", PHP_INI_ALL, OnUpdateCompressThreshold, compress_threshold, zend_memcache_globals, memcache_globals) STD_PHP_INI_ENTRY("memcache.lock_timeout", "15", PHP_INI_ALL, OnUpdateLockTimeout, lock_timeout, zend_memcache_globals, memcache_globals) + STD_PHP_INI_ENTRY("memcache.select_api", "select", PHP_INI_ALL, OnUpdateSelectApi, select_api, zend_memcache_globals, memcache_globals) STD_PHP_INI_BOOLEAN("memcache.session_prefix_host_key", "0", PHP_INI_ALL, OnUpdateBool, session_prefix_host_key, zend_memcache_globals, memcache_globals) STD_PHP_INI_BOOLEAN("memcache.session_prefix_host_key_remove_www", "1", PHP_INI_ALL, OnUpdateBool, session_prefix_host_key_remove_www, zend_memcache_globals, memcache_globals) STD_PHP_INI_BOOLEAN("memcache.session_prefix_host_key_remove_subdomain", "0", PHP_INI_ALL, OnUpdateBool, session_prefix_host_key_remove_subdomain, zend_memcache_globals, memcache_globals) @@ -578,6 +606,7 @@ { MEMCACHE_G(hash_strategy) = MMC_STANDARD_HASH; MEMCACHE_G(hash_function) = MMC_HASH_CRC32; + MEMCACHE_G(select_api) = MMC_API_SELECT; } /* }}} */ @@ -956,7 +985,12 @@ } } else { +#if PHP_VERSION_ID < 80600 WRONG_PARAM_COUNT; +#else + zend_wrong_param_count(); + RETURN_THROWS(); +#endif } /* execute all requests */ @@ -2216,7 +2250,7 @@ return MMC_REQUEST_AGAIN; } - zval_dtor((zval *)param); + zval_ptr_dtor_nogc((zval *)param); ZVAL_FALSE((zval *)param); return MMC_REQUEST_FAILURE; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/src/memcache_ascii_protocol.c new/pecl-memcache-8.6/src/memcache_ascii_protocol.c --- old/pecl-memcache-8.2/src/memcache_ascii_protocol.c 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/src/memcache_ascii_protocol.c 2026-11-23 20:02:39.000000000 +0100 @@ -24,7 +24,7 @@ #endif #include "memcache_pool.h" -#include "ext/standard/php_smart_string.h" +#include "Zend/zend_smart_string.h" typedef struct mmc_ascii_request { mmc_request_t base; /* enable cast to mmc_request_t */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/src/memcache_binary_protocol.c new/pecl-memcache-8.6/src/memcache_binary_protocol.c --- old/pecl-memcache-8.2/src/memcache_binary_protocol.c 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/src/memcache_binary_protocol.c 2026-11-23 20:02:39.000000000 +0100 @@ -26,15 +26,19 @@ #define MMC_DEBUG 0 #ifdef PHP_WIN32 -#include <win32/php_stdint.h> -#include <winsock2.h> +# if defined(_MSC_VER) && _MSC_VER < 1920 +# include "win32/php_stdint.h" +# else +# include <stdint.h> +# endif +# include <winsock2.h> #else -#include <stdint.h> -#include <arpa/inet.h> -#include <netinet/in.h> +# include <stdint.h> +# include <arpa/inet.h> +# include <netinet/in.h> #endif #include "memcache_pool.h" -#include "ext/standard/php_smart_string.h" +#include "Zend/zend_smart_string.h" #ifdef htonll #undef htonll @@ -379,7 +383,7 @@ Z_STRVAL(keytmp), Z_STRLEN(keytmp), &value, req->value.flags, req->value.cas, request->value_handler_param); - zval_dtor(&keytmp); + zval_ptr_dtor_nogc(&keytmp); } else { result = request->value_handler( @@ -450,7 +454,7 @@ mmc, request, &(request->readbuf), Z_STRVAL(keytmp), Z_STRLEN(keytmp), req->value.flags, req->value.cas, req->value.length); - zval_dtor(&keytmp); + zval_ptr_dtor_nogc(&keytmp); } else { result = mmc_unpack_value( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/src/memcache_pool.c new/pecl-memcache-8.6/src/memcache_pool.c --- old/pecl-memcache-8.2/src/memcache_pool.c 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/src/memcache_pool.c 2026-11-23 20:02:39.000000000 +0100 @@ -28,6 +28,7 @@ #include <winsock2.h> #else #include <arpa/inet.h> +#include <sys/poll.h> #endif #include "php.h" @@ -35,7 +36,7 @@ #include "ext/standard/crc32.h" #include "ext/standard/php_var.h" #include "ext/standard/php_string.h" -#include "ext/standard/php_smart_string.h" +#include "Zend/zend_smart_string.h" #include "zend_smart_str.h" #include "memcache_pool.h" @@ -425,7 +426,7 @@ PHP_VAR_SERIALIZE_DESTROY(value_hash); if (!buf.s) { - zval_dtor(&value_copy); + zval_ptr_dtor_nogc(&value_copy); php_error_docref(NULL, E_WARNING, "Failed to serialize value"); return MMC_REQUEST_FAILURE; } @@ -435,13 +436,13 @@ /* trying to save null or something went really wrong */ if (buffer->value.c == NULL || buffer->value.len == prev_len) { - zval_dtor(&value_copy); + zval_ptr_dtor_nogc(&value_copy); php_error_docref(NULL, E_WARNING, "Failed to serialize value"); return MMC_REQUEST_FAILURE; } *flags |= MMC_SERIALIZED; - zval_dtor(&value_copy); + zval_ptr_dtor_nogc(&value_copy); mmc_compress(pool, buffer, buffer->value.c + prev_len, buffer->value.len - prev_len, flags, 1); } @@ -770,6 +771,9 @@ return MMC_REQUEST_FAILURE; } + if (fd >= FD_SETSIZE) { + php_error_docref(NULL, E_ERROR, "Too many open file descriptors: %d", fd); + } php_stream_auto_cleanup(io->stream); php_stream_set_chunk_size(io->stream, io->chunk_size); php_stream_set_option(io->stream, PHP_STREAM_OPTION_BLOCKING, 0, NULL); @@ -899,6 +903,7 @@ mmc_pool_init_hash(pool); pool->compress_threshold = MEMCACHE_G(compress_threshold); pool->min_compress_savings = MMC_DEFAULT_SAVINGS; + pool->select_api = MEMCACHE_G(select_api); pool->sending = &(pool->_sending1); pool->reading = &(pool->_reading1); @@ -1399,7 +1404,7 @@ } /* }}} */ -void mmc_pool_select(mmc_pool_t *pool) /* +static void mmc_pool_select_impl(mmc_pool_t *pool) /* runs one select() round on all scheduled requests {{{ */ { int i, fd, result; @@ -1679,6 +1684,346 @@ } /* }}} */ +#ifndef PHP_WIN32 +static void mmc_pool_add_poll_event(mmc_pool_t *pool, int fd, short event) /* + add fd with event to array for poll {{{ */ +{ + // remove duplicates as poll() doesn't guarantee to work properly with them + // as the list expected to be small linear search should work well + for (int i=0; i < pool->nfds; i++) { + if (pool->pollfds[i].fd == fd) { + pool->pollfds[i].events |= event; + + return; + } + } + + pool->pollfds[pool->nfds].fd = fd; + pool->pollfds[pool->nfds].events = event; + pool->nfds++; +} +/* }}} */ +#endif + +#ifndef PHP_WIN32 +static int mmc_pool_poll_event_idx(mmc_pool_t *pool, int fd, short event) /* + check if fd with event is present in revents array for poll {{{ */ +{ + // remove duplicates as poll() doesn't guarantee to work properly with them + // as the list expected to be small linear search should work well + for (int i=0; i < pool->nfds; i++) { + if (pool->pollfds[i].fd == fd && pool->pollfds[i].revents & event) { + return i; + } + } + + return -1; +} +/* }}} */ +#endif + +#ifndef PHP_WIN32 +static void mmc_pool_poll(mmc_pool_t *pool) /* + runs one poll() round on all scheduled requests {{{ */ +{ + int i, result; + mmc_t *mmc; + mmc_queue_t *sending, *reading; + + int should_free_fds; + + /* help complete previous run */ + if (pool->in_select) { + if (pool->sending == &(pool->_sending1)) { + sending = &(pool->_sending2); + reading = &(pool->_reading2); + } + else { + sending = &(pool->_sending1); + reading = &(pool->_reading1); + } + } + else { + // poll takes timout as int in milliseconds + int timeout = ((int)pool->timeout.tv_sec) * 1000 + ((int)pool->timeout.tv_usec) / 1000; + pool->nfds = 0; + + sending = pool->sending; + reading = pool->reading; + mmc_pool_switch(pool); + + int max_nfds = sending->len + reading->len; + int memsize = max_nfds * sizeof(struct pollfd); + + should_free_fds = 1; + pool->pollfds = emalloc(memsize); + memset(pool->pollfds, 0, memsize); + + for (i=0; i < sending->len; i++) { + mmc = mmc_queue_item(sending, i); + mmc_pool_add_poll_event(pool, mmc->sendreq->io->fd, POLLOUT); + } + + for (i=0; i < reading->len; i++) { + mmc = mmc_queue_item(reading, i); + mmc_pool_add_poll_event(pool, mmc->readreq->io->fd, POLLIN); + } + + result = poll(pool->pollfds, pool->nfds, timeout); + + /* if poll timed out or error */ + if (result <= 0) { + for (i=0; i < sending->len; i++) { + mmc = (mmc_t *)mmc_queue_item(sending, i); + + mmc_queue_remove(sending, mmc); + mmc_queue_remove(reading, mmc); + i--; + + if (mmc_select_failure(pool, mmc, mmc->sendreq, result) == MMC_REQUEST_RETRY) { + /* allow request to try and send again */ + mmc_select_retry(pool, mmc, mmc->sendreq); + } + } + + for (i=0; i < reading->len; i++) { + mmc = (mmc_t *)mmc_queue_item(reading, i); + + mmc_queue_remove(sending, mmc); + mmc_queue_remove(reading, mmc); + i--; + + if (mmc_select_failure(pool, mmc, mmc->readreq, result) == MMC_REQUEST_RETRY) { + /* allow request to try and read again */ + mmc_select_retry(pool, mmc, mmc->readreq); + } + } + } + + pool->in_select = 1; + } + + for (i=0; i < sending->len; i++) { + mmc = mmc_queue_item(sending, i); + + /* skip servers which have failed */ + if (!mmc->sendreq) { + continue; + } + + int fd_idx = mmc_pool_poll_event_idx(pool, mmc->sendreq->io->fd, POLLOUT); + + if (fd_idx != -1) { + /* clear bit for reentrancy reasons */ + pool->pollfds[fd_idx].revents &= ~POLLOUT; + + /* until stream buffer is empty */ + do { + /* delegate to request send handler */ + result = mmc_request_send(mmc, mmc->sendreq); + + /* check if someone has helped complete our run */ + if (!pool->in_select) { + if (should_free_fds) { + efree(pool->pollfds); + } + return; + } + + switch (result) { + case MMC_REQUEST_FAILURE: + /* take server offline and failover requests */ + mmc_server_deactivate(pool, mmc); + + /* server is failed, remove from read queue */ + mmc_queue_remove(reading, mmc); + break; + + case MMC_REQUEST_RETRY: + /* allow request to reschedule itself */ + mmc_select_retry(pool, mmc, mmc->sendreq); + break; + + case MMC_REQUEST_DONE: + /* shift next request into send slot */ + mmc_pool_slot_send(pool, mmc, mmc_queue_pop(&(mmc->sendqueue)), 1); + break; + + case MMC_REQUEST_MORE: + /* send more data to socket */ + break; + + default: + php_error_docref(NULL, E_ERROR, "Invalid return value, bailing out"); + } + } while (mmc->sendreq != NULL && (result == MMC_REQUEST_DONE || result == MMC_REQUEST_AGAIN)); + + if (result == MMC_REQUEST_MORE) { + /* add server to read queue once more */ + mmc_queue_push(pool->sending, mmc); + } + } + else { + /* add server to send queue once more */ + mmc_queue_push(pool->sending, mmc); + } + + if ( ! pool->sending->len && ( mmc->sendreq != NULL || mmc->sendqueue.len ) ) { + php_error_docref( NULL, E_WARNING, "mmc_pool_select() failed to cleanup when sending! Sendqueue: %d", mmc->sendqueue.len ); + } + } + + for (i=0; i < reading->len; i++) { + mmc = mmc_queue_item(reading, i); + + /* skip servers which have failed */ + if (!mmc->readreq) { + continue; + } + + int fd_idx = mmc_pool_poll_event_idx(pool, mmc->readreq->io->fd, POLLIN); + + if (fd_idx != -1) { + /* clear bit for reentrancy reasons */ + pool->pollfds[fd_idx].revents &= ~POLLIN; + + /* fill read buffer if needed */ + if (mmc->readreq->read != NULL) { + result = mmc->readreq->read(mmc, mmc->readreq); + + if (result != MMC_OK) { + switch (result) { + case MMC_REQUEST_FAILURE: + /* take server offline and failover requests */ + mmc_server_deactivate(pool, mmc); + break; + + case MMC_REQUEST_RETRY: + /* allow request to reschedule itself */ + mmc_select_retry(pool, mmc, mmc->readreq); + break; + + case MMC_REQUEST_MORE: + /* add server to read queue once more */ + mmc_queue_push(pool->reading, mmc); + break; + + default: + php_error_docref(NULL, E_ERROR, "Invalid return value, bailing out"); + } + + /* skip to next request */ + continue; + } + } + + /* until stream buffer is empty */ + do { + /* delegate to request response handler */ + result = mmc->readreq->parse(mmc, mmc->readreq); + + /* check if someone has helped complete our run */ + if (!pool->in_select) { + if (should_free_fds) { + efree(pool->pollfds); + } + return; + } + + switch (result) { + case MMC_REQUEST_FAILURE: + /* take server offline and failover requests */ + mmc_server_deactivate(pool, mmc); + break; + + case MMC_REQUEST_RETRY: + /* allow request to reschedule itself */ + mmc_select_retry(pool, mmc, mmc->readreq); + break; + + case MMC_REQUEST_DONE: + /* might have completed without having sent all data (e.g. object too large errors) */ + if (mmc->sendreq == mmc->readreq) { + /* disconnect stream since data may have been sent before we received the SERVER_ERROR */ + mmc_server_disconnect(mmc, mmc->readreq->io); + + /* shift next request into send slot */ + mmc_pool_slot_send(pool, mmc, mmc_queue_pop(&(mmc->sendqueue)), 1); + + /* clear out connection from send queue if no new request was slotted */ + if (!mmc->sendreq) { + mmc_queue_remove(pool->sending, mmc); + } + } + + /* release completed request */ + mmc_pool_release(pool, mmc->readreq); + + /* shift next request into read slot */ + mmc->readreq = mmc_queue_pop(&(mmc->readqueue)); + break; + + case MMC_REQUEST_MORE: + /* read more data from socket */ + if (php_stream_eof(mmc->readreq->io->stream)) { + result = mmc_server_failure(mmc, mmc->readreq->io, "Read failed (socket was unexpectedly closed)", 0); + if (result == MMC_REQUEST_FAILURE) { + /* take server offline and failover requests */ + mmc_server_deactivate(pool, mmc); + } else { + mmc_select_retry(pool, mmc, mmc->readreq); + } + } + break; + + case MMC_REQUEST_AGAIN: + /* request wants another loop */ + break; + + default: + php_error_docref(NULL, E_ERROR, "Invalid return value, bailing out"); + } + } while (mmc->readreq != NULL && (result == MMC_REQUEST_DONE || result == MMC_REQUEST_AGAIN)); + + if (result == MMC_REQUEST_MORE) { + /* add server to read queue once more */ + mmc_queue_push(pool->reading, mmc); + } + } + else { + /* add server to read queue once more */ + mmc_queue_push(pool->reading, mmc); + } + + if ( ! pool->reading->len && ( mmc->readreq != NULL || mmc->readqueue.len ) ) { + php_error_docref( NULL, E_WARNING, "mmc_pool_select() failed to cleanup when reading! Readqueue: %d", mmc->readqueue.len ); + } + } + + pool->in_select = 0; + + if (should_free_fds) { + efree(pool->pollfds); + } +} +/* }}} */ +#endif + +void mmc_pool_select(mmc_pool_t *pool) /* + runs one select() or poll() round on all scheduled requests {{{ */ +{ + #ifdef PHP_WIN32 + mmc_pool_select_impl(pool); + #else + if (pool->select_api == MMC_API_POLL) { + mmc_pool_poll(pool); + } else { + mmc_pool_select_impl(pool); + } + #endif +} +/* }}} */ + void mmc_pool_schedule_pending(mmc_pool_t *pool) { mmc_t *mmc; while ((mmc = mmc_queue_pop(&(pool->pending))) != NULL) { @@ -1750,7 +2095,7 @@ res = mmc_prepare_key_ex(Z_STRVAL(keytmp), Z_STRLEN(keytmp), result, result_len, MEMCACHE_G(key_prefix)); - zval_dtor(&keytmp); + zval_ptr_dtor_nogc(&keytmp); return res; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/src/memcache_pool.h new/pecl-memcache-8.6/src/memcache_pool.h --- old/pecl-memcache-8.2/src/memcache_pool.h 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/src/memcache_pool.h 2026-11-23 20:02:39.000000000 +0100 @@ -35,14 +35,18 @@ #endif #ifdef PHP_WIN32 -#include <win32/php_stdint.h> +# if defined(_MSC_VER) && _MSC_VER < 1920 +# include "win32/php_stdint.h" +# else +# include <stdint.h> +# endif #else -#include <stdint.h> +# include <stdint.h> #endif #include <string.h> #include "php.h" -#include "ext/standard/php_smart_string_public.h" +#include "Zend/zend_smart_string.h" #include "memcache_queue.h" /* @@ -115,6 +119,9 @@ #define MMC_HASH_CRC32 1 /* CRC32 hash function */ #define MMC_HASH_FNV1A 2 /* FNV-1a hash function */ +#define MMC_API_SELECT 1 +#define MMC_API_POLL 2 + #define MMC_CONSISTENT_POINTS 160 /* points per server */ #define MMC_CONSISTENT_BUCKETS 1024 /* number of precomputed buckets, should be power of 2 */ @@ -339,6 +346,11 @@ void *hash_state; /* strategy specific state */ fd_set wfds; fd_set rfds; + #ifndef PHP_WIN32 + struct pollfd *pollfds; + int nfds; + #endif + long select_api; struct timeval timeout; /* smallest timeout for any of the servers */ int in_select; mmc_queue_t *sending; /* mmc_queue_t<mmc_t *>, connections that want to send */ @@ -414,6 +426,7 @@ long session_redundancy; long compress_threshold; long lock_timeout; + long select_api; char *session_key_prefix; zend_bool session_prefix_host_key; zend_bool session_prefix_host_key_remove_www; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/src/memcache_session.c new/pecl-memcache-8.6/src/memcache_session.c --- old/pecl-memcache-8.2/src/memcache_session.c 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/src/memcache_session.c 2026-11-23 20:02:39.000000000 +0100 @@ -29,7 +29,7 @@ #include "php_variables.h" #include "SAPI.h" -#include "ext/standard/php_smart_string.h" +#include "Zend/zend_smart_string.h" #include "ext/standard/url.h" #include "ext/session/php_session.h" #ifdef PHP_WIN32 @@ -60,7 +60,11 @@ if (!path) { /* allow to work with standard session.save_path option and session_save_path function */ +#if PHP_VERSION_ID < 80600 path = save_path; +#else + path = ZSTR_VAL(save_path); +#endif } if (!path) { PS_SET_MOD_DATA(NULL); @@ -355,7 +359,7 @@ } /* if missing value, skip this server and try next */ - zval_dtor(&dataresult); + zval_ptr_dtor_nogc(&dataresult); mmc_queue_push(&skip_servers, mmc); /* if it is the last server in pool and connection was ok return success and empty string due to php70 changes */ @@ -366,7 +370,7 @@ } } else { - zval_dtor(&dataresult); + zval_ptr_dtor_nogc(&dataresult); /* if missing lock, back off and retry same server */ last_index = prev_index; @@ -382,7 +386,7 @@ } while (skip_servers.len < MEMCACHE_G(session_redundancy) && skip_servers.len < pool->num_servers && remainingtime > 0); mmc_queue_free(&skip_servers); - zval_dtor(&dataresult); + zval_ptr_dtor_nogc(&dataresult); return SUCCESS; } @@ -405,7 +409,7 @@ mmc_t *mmc; mmc_request_t *lockrequest, *datarequest; mmc_queue_t skip_servers = {0}; - size_t lifetime = (size_t)time(NULL) + INI_INT("session.gc_maxlifetime"); + size_t lifetime = (size_t)time(NULL) + zend_ini_long("session.gc_maxlifetime", strlen("session.gc_maxlifetime"), 0); unsigned int last_index = 0; ZVAL_NULL(&lockresult); @@ -573,6 +577,116 @@ } /* }}} */ +#if PHP_VERSION_ID >= 80600 +static zend_result php_mmc_session_key_exists(mmc_pool_t *pool, zend_string *key) +{ + zval result, zkey; + zval *resultparam[3]; + mmc_t *mmc; + mmc_request_t *request; + mmc_queue_t skip_servers = {0}; + unsigned int last_index = 0; + + ZVAL_STR(&zkey, key); + + resultparam[0] = &result; + resultparam[1] = NULL; + resultparam[2] = NULL; + + do { + ZVAL_NULL(&result); + + request = mmc_pool_request_get( + pool, MMC_PROTO_TCP, mmc_value_handler_single, resultparam, + mmc_pool_failover_handler_null, NULL); + + if (mmc_prepare_key_ex( + ZSTR_VAL(key), ZSTR_LEN(key), + request->key, &(request->key_len), + MEMCACHE_G(session_key_prefix)) != MMC_OK) { + mmc_pool_release(pool, request); + mmc_queue_free(&skip_servers); + return FAILURE; + } + + pool->protocol->get( + request, MMC_OP_GET, &zkey, + request->key, request->key_len); + + mmc = mmc_pool_find_next( + pool, + request->key, request->key_len, + &skip_servers, &last_index); + + if (!mmc_server_valid(mmc) || + mmc_pool_schedule(pool, mmc, request) != MMC_OK) { + mmc_pool_release(pool, request); + mmc_queue_push(&skip_servers, mmc); + continue; + } + + mmc_pool_run(pool); + + if (Z_TYPE(result) == IS_STRING) { + zval_ptr_dtor(&result); + mmc_queue_free(&skip_servers); + return SUCCESS; + } + + zval_ptr_dtor(&result); + mmc_queue_push(&skip_servers, mmc); + + } while (skip_servers.len < MEMCACHE_G(session_redundancy) && + skip_servers.len < pool->num_servers); + + mmc_queue_free(&skip_servers); + + return FAILURE; +} + +PS_VALIDATE_SID_FUNC(memcache) +{ + mmc_pool_t *pool = PS_GET_MOD_DATA(); + + if (pool == NULL) { + return FAILURE; + } + + return php_mmc_session_key_exists(pool, key); +} + +PS_CREATE_SID_FUNC(memcache) +{ + mmc_pool_t *pool = PS_GET_MOD_DATA(); + zend_string *sid; + int maxfail = 3; + + do { + sid = php_session_create_id(mod_data); + + if (sid == NULL) { + if (--maxfail < 0) { + return NULL; + } + continue; + } + + if (pool != NULL && + php_mmc_session_key_exists(pool, sid) == SUCCESS) { + zend_string_release_ex(sid, false); + sid = NULL; + + if (--maxfail < 0) { + return NULL; + } + } + } while (sid == NULL); + + return sid; +} + +#endif /* PHP_VERSION_ID >= 80600 */ + /* * Local variables: * tab-width: 4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/src/php_memcache.h new/pecl-memcache-8.6/src/php_memcache.h --- old/pecl-memcache-8.2/src/php_memcache.h 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/src/php_memcache.h 2026-11-23 20:02:39.000000000 +0100 @@ -67,7 +67,7 @@ PHP_FUNCTION(memcache_flush); PHP_FUNCTION(memcache_set_sasl_auth_data); -#define PHP_MEMCACHE_VERSION "8.2" +#define PHP_MEMCACHE_VERSION "8.6" #define MMC_DEFAULT_TIMEOUT 1 /* seconds */ #define MMC_DEFAULT_RETRY 15 /* retry failed server after x seconds */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/tests/034.phpt new/pecl-memcache-8.6/tests/034.phpt --- old/pecl-memcache-8.2/tests/034.phpt 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/tests/034.phpt 2026-11-23 20:02:39.000000000 +0100 @@ -33,7 +33,15 @@ var_dump($result[key($result)]['free_chunks_end']); $slab = key($result); -$result = $memcache->getStats('cachedump', $slab, 10); +// memcached >= 1.5 only dumps the COLD LRU queue; a fresh item sits in HOT +// until the LRU maintainer thread moves it, so wait for it (max ~3s) +for ($i = 0; $i < 60; $i++) { + $result = $memcache->getStats('cachedump', $slab, 10); + if (is_array($result)) { + break; + } + usleep(50000); +} var_dump($result[key($result)][0]); var_dump($result[key($result)][1]); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/tests/044b.phpt new/pecl-memcache-8.6/tests/044b.phpt --- old/pecl-memcache-8.2/tests/044b.phpt 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/tests/044b.phpt 2026-11-23 20:02:39.000000000 +0100 @@ -1,5 +1,7 @@ --TEST-- ini_set('memcache.session_redundancy') +--INI-- +session.use_strict_mode=0 --SKIPIF-- <?php include 'connect.inc'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/tests/057.phpt new/pecl-memcache-8.6/tests/057.phpt --- old/pecl-memcache-8.2/tests/057.phpt 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/tests/057.phpt 2026-11-23 20:02:39.000000000 +0100 @@ -1,5 +1,7 @@ --TEST-- session locking +--INI-- +session.use_strict_mode=0 --SKIPIF-- <?php include 'connect.inc'; if (!MEMCACHE_HAVE_SESSION) print 'skip not compiled with session support'; else if (!function_exists('pcntl_fork')) print 'skip not compiled with pcntl_fork() support'; ?> --FILE-- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/tests/bug73539.phpt new/pecl-memcache-8.6/tests/bug73539.phpt --- old/pecl-memcache-8.2/tests/bug73539.phpt 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/tests/bug73539.phpt 2026-11-23 20:02:39.000000000 +0100 @@ -1,5 +1,7 @@ --TEST-- memcache multi host save path function +--INI-- +session.use_strict_mode=0 --SKIPIF-- <?php include 'connect.inc'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/tests/pecl63142.phpt new/pecl-memcache-8.6/tests/pecl63142.phpt --- old/pecl-memcache-8.2/tests/pecl63142.phpt 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/tests/pecl63142.phpt 2026-11-23 20:02:39.000000000 +0100 @@ -2,9 +2,6 @@ PECL bug #63142 (memcache 3.0.7 segfaults with object (un)serialization) --SKIPIF-- <?php include 'connect.inc'; ?> ---INI-- -;fix me later -report_memleaks=0 --FILE-- <?php diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/tests/redundancy_test.phpt new/pecl-memcache-8.6/tests/redundancy_test.phpt --- old/pecl-memcache-8.2/tests/redundancy_test.phpt 2023-04-30 13:17:46.000000000 +0200 +++ new/pecl-memcache-8.6/tests/redundancy_test.phpt 2026-11-23 20:02:39.000000000 +0100 @@ -1,5 +1,7 @@ --TEST-- redundancy test +--INI-- +session.use_strict_mode=0 --SKIPIF-- <?php include 'connect.inc'; if (!MEMCACHE_HAVE_SESSION) print 'skip not compiled with session support'; else if (!function_exists('pcntl_fork')) print 'skip not compiled with pcntl_fork() support'; ?> --FILE-- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pecl-memcache-8.2/tests/session_strict_mode.phpt new/pecl-memcache-8.6/tests/session_strict_mode.phpt --- old/pecl-memcache-8.2/tests/session_strict_mode.phpt 1970-01-01 01:00:00.000000000 +0100 +++ new/pecl-memcache-8.6/tests/session_strict_mode.phpt 2026-11-23 20:02:39.000000000 +0100 @@ -0,0 +1,58 @@ +--TEST-- +Memcache session handler supports strict mode +--SKIPIF-- +<?php +if (!extension_loaded('memcache')) { + die('skip memcache extension not loaded'); +} +if (PHP_VERSION_ID < 80600) { + die('skip PHP 8.6+ only'); +} +?> +--INI-- +session.save_handler=memcache +session.save_path=tcp://127.0.0.1:11211 +session.use_strict_mode=1 +session.use_cookies=0 +session.cache_limiter= +--FILE-- +<?php + +/* Create a session and write some data. */ +session_start(); +$sid = session_id(); + +$_SESSION['foo'] = 'bar'; +$_SESSION['answer'] = 42; + +session_write_close(); + +/* An existing SID must be accepted in strict mode. */ +session_id($sid); +var_dump(session_start()); +var_dump(session_id() === $sid); +var_dump($_SESSION); + +session_write_close(); + +/* A nonexistent SID must be rejected in strict mode. */ +$invalid = 'this-session-does-not-exist'; + +session_id($invalid); +var_dump(session_start()); +var_dump(session_id() !== $invalid); + +session_abort(); + +?> +--EXPECT-- +bool(true) +bool(true) +array(2) { + ["foo"]=> + string(3) "bar" + ["answer"]=> + int(42) +} +bool(true) +bool(true)
