From 2a5de3c5d9c0bd0acbcf7e6e0b7570f15f89f55b Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Sun, 9 Aug 2020 11:17:47 -0400 Subject: [PATCH 01/12] Use zend_bool for ini bool settings I think that these might have uninitialized bytes when a data type larger than zend_bool is used for the ini setting, if the module globals are set from malloc? (Not 100% sure if the entire structure isn't set to 0 before being used) Related to #56 --- php7/memcache.c | 16 ++++++++-------- php7/memcache_pool.h | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/php7/memcache.c b/php7/memcache.c index 89ca4e0..4625182 100644 --- a/php7/memcache.c +++ b/php7/memcache.c @@ -103,7 +103,7 @@ static zend_function_entry php_memcache_pool_class_functions[] = { PHP_FALIAS(close, memcache_close, NULL) PHP_FALIAS(flush, memcache_flush, NULL) PHP_FALIAS(setSaslAuthData, memcache_set_sasl_auth_data, NULL) - + {NULL, NULL, NULL} }; @@ -292,14 +292,14 @@ PHP_INI_BEGIN() 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.session_prefix_host_key", "0", PHP_INI_ALL, OnUpdateBool, session_prefix_host_key, zend_memcache_globals, memcache_globals) - STD_PHP_INI_ENTRY("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_ENTRY("memcache.session_prefix_host_key_remove_subdomain", "0", PHP_INI_ALL, OnUpdateBool, session_prefix_host_key_remove_subdomain, 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) STD_PHP_INI_ENTRY("memcache.session_prefix_static_key", NULL, PHP_INI_ALL, OnUpdatePrefixStaticKey, session_prefix_static_key, zend_memcache_globals, memcache_globals) STD_PHP_INI_ENTRY("memcache.session_save_path", NULL, PHP_INI_ALL, OnUpdateString, session_save_path, zend_memcache_globals, memcache_globals) - STD_PHP_INI_ENTRY("memcache.prefix_host_key", "0", PHP_INI_ALL, OnUpdateBool, prefix_host_key, zend_memcache_globals, memcache_globals) - STD_PHP_INI_ENTRY("memcache.prefix_host_key_remove_www", "1", PHP_INI_ALL, OnUpdateBool, prefix_host_key_remove_www, zend_memcache_globals, memcache_globals) - STD_PHP_INI_ENTRY("memcache.prefix_host_key_remove_subdomain", "0", PHP_INI_ALL, OnUpdateBool, prefix_host_key_remove_subdomain, zend_memcache_globals, memcache_globals) + STD_PHP_INI_BOOLEAN("memcache.prefix_host_key", "0", PHP_INI_ALL, OnUpdateBool, prefix_host_key, zend_memcache_globals, memcache_globals) + STD_PHP_INI_BOOLEAN("memcache.prefix_host_key_remove_www", "1", PHP_INI_ALL, OnUpdateBool, prefix_host_key_remove_www, zend_memcache_globals, memcache_globals) + STD_PHP_INI_BOOLEAN("memcache.prefix_host_key_remove_subdomain", "0", PHP_INI_ALL, OnUpdateBool, prefix_host_key_remove_subdomain, zend_memcache_globals, memcache_globals) STD_PHP_INI_ENTRY("memcache.prefix_static_key", NULL, PHP_INI_ALL, OnUpdatePrefixStaticKey, prefix_static_key, zend_memcache_globals, memcache_globals) PHP_INI_END() /* }}} */ @@ -878,7 +878,7 @@ static void php_mmc_numeric(INTERNAL_FUNCTION_PARAMETERS, int deleted, int inver memcpy((char *)persistent_id, key, key_len+1); if (zend_register_persistent_resource ( (char*) persistent_id, key_len, mmc, le_memcache_server) == NULL) ; - then not forget to pefree, check refcounts in _mmc_server_free / _mmc_server_list_dtor , etc. + then not forget to pefree, check refcounts in _mmc_server_free / _mmc_server_list_dtor , etc. otherwise we will leak mem with persistent connections /run into other trouble with later versions */ mmc_t *mmc_find_persistent(const char *host, int host_len, unsigned short port, unsigned short udp_port, double timeout, int retry_interval) /* {{{ */ diff --git a/php7/memcache_pool.h b/php7/memcache_pool.h index 2382aa8..cb3d086 100644 --- a/php7/memcache_pool.h +++ b/php7/memcache_pool.h @@ -47,7 +47,7 @@ /* * Mac OS X has no MSG_NOSIGNAL but >= 10.2 comes with SO_NOSIGPIPE which is a setsockopt() option - * and not a send() parameter as MSG_NOSIGNAL. OpenBSD has none of the options so we need to ignore + * and not a send() parameter as MSG_NOSIGNAL. OpenBSD has none of the options so we need to ignore * SIGPIPE events */ #ifndef MSG_NOSIGNAL @@ -285,7 +285,7 @@ typedef struct mmc_protocol { mmc_protocol_flush flush; mmc_protocol_version version; mmc_protocol_stats stats; - + mmc_protocol_set_sasl_auth_data set_sasl_auth_data; } mmc_protocol_t; @@ -415,15 +415,15 @@ ZEND_BEGIN_MODULE_GLOBALS(memcache) long compress_threshold; long lock_timeout; char *session_key_prefix; - char *session_prefix_host_key; - char *session_prefix_host_key_remove_www; - char *session_prefix_host_key_remove_subdomain; + zend_bool session_prefix_host_key; + zend_bool session_prefix_host_key_remove_www; + zend_bool session_prefix_host_key_remove_subdomain; char *session_prefix_static_key; char *session_save_path; char *key_prefix; - char *prefix_host_key; - char *prefix_host_key_remove_www; - char *prefix_host_key_remove_subdomain; + zend_bool prefix_host_key; + zend_bool prefix_host_key_remove_www; + zend_bool prefix_host_key_remove_subdomain; char *prefix_static_key; ZEND_END_MODULE_GLOBALS(memcache) From 2b25d81c55e420f02df98a43b30f4451c02f6d53 Mon Sep 17 00:00:00 2001 From: Zaffy Date: Thu, 24 Sep 2020 13:41:20 +0200 Subject: [PATCH 02/12] Initial work for php 8 --- .gitignore | 10 +- Dockerfile | 4 +- docker/start.sh | 16 +- php7/memcache.c | 340 ++++++++++++++++++++++++++------- php7/memcache_ascii_protocol.c | 2 +- php7/memcache_pool.c | 13 +- php7/memcache_session.c | 8 +- tests/001.phpt | 19 +- tests/019a.phpt | 22 ++- tests/022a.phpt | 19 +- tests/024a.phpt | 20 +- tests/027a.phpt | 21 +- tests/040.phpt | 5 + tests/044.phpt | 15 +- tests/044b.phpt | 5 - tests/100a.phpt | 20 +- tests/bug73539.phpt | 23 ++- tests/connect.inc | 4 +- 18 files changed, 410 insertions(+), 156 deletions(-) diff --git a/.gitignore b/.gitignore index c6603f2..64f87e3 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,14 @@ # Debug files *.dSYM/ +# Tests-generated stuff +tests/*.diff +tests/*.php +tests/*.out +tests/*.sh +tests/*.log +tests/*.exp + *.fragments Makefile* autom4te* @@ -55,6 +63,6 @@ mkinstalldirs run-tests.php fails.log configure.ac -tests/*.php *.code-workspace .vscode/* +.idea/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2427f11..a67b716 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG PHP_IMAGE=php:7.4-rc +ARG PHP_IMAGE=php:8.0-rc FROM $PHP_IMAGE RUN apt-get update && apt-get install -y \ @@ -8,5 +8,7 @@ RUN apt-get update && apt-get install -y \ COPY docker/host.conf /etc/host.conf +# ENV LOCAL_DEV 1 +# ADD . /usr/src/pecl-memcache COPY docker/start.sh / CMD ["/start.sh"] diff --git a/docker/start.sh b/docker/start.sh index bc9f5ec..14b3524 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,9 +1,8 @@ #!/bin/bash -CFLAGS="-fstack-protector-strong -fpic -fpie -O2" -CPPFLAGS="$PHP_CFLAGS" -LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie" - +export CFLAGS="-fstack-protector-strong -O2" +export CPPFLAGS="${CFLAGS}" +export LDFLAGS="-Wl,-O1 -Wl,--hash-style=both" # Build extension set -eux @@ -14,10 +13,11 @@ then git clone https://github.com/websupport-sk/pecl-memcache.git fi -cd pecl-memcache; -phpize +cd pecl-memcache; +[[ -n "${LOCAL_DEV}" ]] && phpize --clean +phpize ./configure -make -j$(nproc) +make -j"$(nproc)" # Spawn memcached for tests echo "Starting memcached... " @@ -29,4 +29,4 @@ chown memcache:memcache /var/run/memcached # Let's start tests cd /usr/src/pecl-memcache -TEST_PHP_ARGS="--show-diff --keep-all -w fails.log" make test +NO_INTERACTION=1 TEST_PHP_ARGS="--show-diff --keep-all -w fails.log" make test diff --git a/php7/memcache.c b/php7/memcache.c index 89ca4e0..a403848 100644 --- a/php7/memcache.c +++ b/php7/memcache.c @@ -26,7 +26,6 @@ #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" -#include "ext/standard/php_string.h" #include "php_memcache.h" /* True global resources - no need for thread safety here */ @@ -38,80 +37,276 @@ ZEND_EXTERN_MODULE_GLOBALS(memcache) /* {{{ memcache_functions[] */ -ZEND_BEGIN_ARG_INFO(arginfo_memcache_get, 1) - ZEND_ARG_PASS_INFO(0) - ZEND_ARG_PASS_INFO(0) - ZEND_ARG_PASS_INFO(1) - ZEND_ARG_PASS_INFO(1) + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_connect, 0, 0, 1) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, port) + ZEND_ARG_INFO(0, udp_port) + ZEND_ARG_INFO(0, persistent) + ZEND_ARG_INFO(0, weight) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retry_interval) +ZEND_END_ARG_INFO() + +#define arginfo_memcache_pconnect arginfo_memcache_connect + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_add_server, 0, 0, 2) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, port) + ZEND_ARG_INFO(0, persistent) + ZEND_ARG_INFO(0, weight) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retry_interval) + ZEND_ARG_INFO(0, status) + ZEND_ARG_INFO(0, failure_callback) + ZEND_ARG_INFO(0, timeoutms) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_server_params, 0, 0, 1) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, port) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retry_interval) + ZEND_ARG_INFO(0, status) + ZEND_ARG_INFO(0, failure_callback) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_failure_callback, 1, 0, 2) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_INFO(0, failure_callback) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get_server_status, 0, 0, 1) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, port) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get_version, 1, 0, 1) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_add, 0, 0, 2) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, value) + ZEND_ARG_INFO(0, flag) + ZEND_ARG_INFO(0, exptime) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_memcache_object_get, 1) - ZEND_ARG_PASS_INFO(0) - ZEND_ARG_PASS_INFO(1) - ZEND_ARG_PASS_INFO(1) +#define arginfo_memcache_set arginfo_memcache_add +#define arginfo_memcache_replace arginfo_memcache_add + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_cas, 0, 0, 2) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, value) + ZEND_ARG_INFO(0, flag) + ZEND_ARG_INFO(0, exptime) + ZEND_ARG_INFO(0, cas) +ZEND_END_ARG_INFO() + +#define arginfo_memcache_append arginfo_memcache_add +#define arginfo_memcache_prepend arginfo_memcache_add + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get, 1, 0, 2) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(1, flags) + ZEND_ARG_INFO(1, cas) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_delete, 0, 0, 2) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, exptime) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_debug, 0, 0, 1) + ZEND_ARG_INFO(0, on_off) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get_stats, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_INFO(0, type) + ZEND_ARG_INFO(0, slabid) + ZEND_ARG_INFO(0, limit) +ZEND_END_ARG_INFO() + +#define arginfo_memcache_get_extended_stats arginfo_memcache_get_stats + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_compress_threshold, 0, 0, 2) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_INFO(0, threshold) + ZEND_ARG_INFO(0, min_savings) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_increment, 0, 0, 2) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, value) + ZEND_ARG_INFO(0, defval) + ZEND_ARG_INFO(0, exptime) +ZEND_END_ARG_INFO() + +#define arginfo_memcache_decrement arginfo_memcache_increment + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_close, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_flush, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_INFO(0, delay) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_sasl_auth_data, 1, 0, 3) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_INFO(0, username) + ZEND_ARG_INFO(0, password) ZEND_END_ARG_INFO() zend_function_entry memcache_functions[] = { - PHP_FE(memcache_connect, NULL) - PHP_FE(memcache_pconnect, NULL) - PHP_FE(memcache_add_server, NULL) - PHP_FE(memcache_set_server_params, NULL) - PHP_FE(memcache_set_failure_callback, NULL) - PHP_FE(memcache_get_server_status, NULL) - PHP_FE(memcache_get_version, NULL) - PHP_FE(memcache_add, NULL) - PHP_FE(memcache_set, NULL) - PHP_FE(memcache_replace, NULL) - PHP_FE(memcache_cas, NULL) - PHP_FE(memcache_append, NULL) - PHP_FE(memcache_prepend, NULL) + PHP_FE(memcache_connect, arginfo_memcache_connect) + PHP_FE(memcache_pconnect, arginfo_memcache_pconnect) + PHP_FE(memcache_add_server, arginfo_memcache_add_server) + PHP_FE(memcache_set_server_params, arginfo_memcache_set_server_params) + PHP_FE(memcache_set_failure_callback, arginfo_memcache_set_failure_callback) + PHP_FE(memcache_get_server_status, arginfo_memcache_get_server_status) + PHP_FE(memcache_get_version, arginfo_memcache_get_version) + PHP_FE(memcache_add, arginfo_memcache_add) + PHP_FE(memcache_set, arginfo_memcache_set) + PHP_FE(memcache_replace, arginfo_memcache_replace) + PHP_FE(memcache_cas, arginfo_memcache_cas) + PHP_FE(memcache_append, arginfo_memcache_append) + PHP_FE(memcache_prepend, arginfo_memcache_prepend) PHP_FE(memcache_get, arginfo_memcache_get) - PHP_FE(memcache_delete, NULL) - PHP_FE(memcache_debug, NULL) - PHP_FE(memcache_get_stats, NULL) - PHP_FE(memcache_get_extended_stats, NULL) - PHP_FE(memcache_set_compress_threshold, NULL) - PHP_FE(memcache_increment, NULL) - PHP_FE(memcache_decrement, NULL) - PHP_FE(memcache_close, NULL) - PHP_FE(memcache_flush, NULL) - PHP_FE(memcache_set_sasl_auth_data, NULL) - {NULL, NULL, NULL} + PHP_FE(memcache_delete, arginfo_memcache_delete) + PHP_FE(memcache_debug, arginfo_memcache_debug) + PHP_FE(memcache_get_stats, arginfo_memcache_get_stats) + PHP_FE(memcache_get_extended_stats, arginfo_memcache_get_extended_stats) + PHP_FE(memcache_set_compress_threshold, arginfo_memcache_set_compress_threshold) + PHP_FE(memcache_increment, arginfo_memcache_increment) + PHP_FE(memcache_decrement, arginfo_memcache_decrement) + PHP_FE(memcache_close, arginfo_memcache_close) + PHP_FE(memcache_flush, arginfo_memcache_flush) + PHP_FE(memcache_set_sasl_auth_data, arginfo_memcache_set_sasl_auth_data) + ZEND_FE_END }; +#define arginfo_memcache_object_connect arginfo_memcache_connect + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_addserver, 0, 0, 1) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, port) + ZEND_ARG_INFO(0, persistent) + ZEND_ARG_INFO(0, weight) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retry_interval) + ZEND_ARG_INFO(0, status) + ZEND_ARG_INFO(0, failure_callback) + ZEND_ARG_INFO(0, timeoutms) +ZEND_END_ARG_INFO() + +#define arginfo_memcache_object_setserverparams arginfo_memcache_set_server_params + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_setfailurecallback, 0, 0, 1) + ZEND_ARG_INFO(0, failure_callback) +ZEND_END_ARG_INFO() + +#define arginfo_memcache_object_getserverstatus arginfo_memcache_get_server_status + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_findserver, 0, 0, 1) + ZEND_ARG_INFO(0, key) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_getversion, 0, 0, 0) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_add, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, value) + ZEND_ARG_INFO(0, flag) + ZEND_ARG_INFO(0, exptime) +ZEND_END_ARG_INFO() + +#define arginfo_memcache_object_set arginfo_memcache_object_add +#define arginfo_memcache_object_replace arginfo_memcache_object_add + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_cas, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, value) + ZEND_ARG_INFO(0, flag) + ZEND_ARG_INFO(0, exptime) + ZEND_ARG_INFO(0, cas) +ZEND_END_ARG_INFO() + +#define arginfo_memcache_object_append arginfo_memcache_object_add +#define arginfo_memcache_object_prepend arginfo_memcache_object_add + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_get, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(1, flags) + ZEND_ARG_INFO(1, cas) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_delete, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, exptime) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_getstats, 0, 0, 0) + ZEND_ARG_INFO(0, type) + ZEND_ARG_INFO(0, slabid) + ZEND_ARG_INFO(0, limit) +ZEND_END_ARG_INFO() + +#define arginfo_memcache_object_getextendedstats arginfo_memcache_object_getstats + +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_setcompressthreshold, 0, 0, 1) + ZEND_ARG_INFO(0, threshold) + ZEND_ARG_INFO(0, min_savings) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_increment, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, value) + ZEND_ARG_INFO(0, defval) + ZEND_ARG_INFO(0, exptime) +ZEND_END_ARG_INFO() + +#define arginfo_memcache_object_decrement arginfo_memcache_object_increment + +ZEND_BEGIN_ARG_INFO(arginfo_memcache_object_close, 0) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_flush, 0, 0, 0) + ZEND_ARG_INFO(0, delay) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_setSaslAuthData, 0, 0, 2) + ZEND_ARG_INFO(0, username) + ZEND_ARG_INFO(0, password) +ZEND_END_ARG_INFO() + static zend_function_entry php_memcache_pool_class_functions[] = { - PHP_NAMED_FE(connect, zif_memcache_pool_connect, NULL) - PHP_NAMED_FE(addserver, zif_memcache_pool_addserver, NULL) - PHP_FALIAS(setserverparams, memcache_set_server_params, NULL) - PHP_FALIAS(setfailurecallback, memcache_set_failure_callback, NULL) - PHP_FALIAS(getserverstatus, memcache_get_server_status, NULL) - PHP_NAMED_FE(findserver, zif_memcache_pool_findserver, NULL) - PHP_FALIAS(getversion, memcache_get_version, NULL) - PHP_FALIAS(add, memcache_add, NULL) - PHP_FALIAS(set, memcache_set, NULL) - PHP_FALIAS(replace, memcache_replace, NULL) - PHP_FALIAS(cas, memcache_cas, NULL) - PHP_FALIAS(append, memcache_append, NULL) - PHP_FALIAS(prepend, memcache_prepend, NULL) + PHP_NAMED_FE(connect, zif_memcache_pool_connect, arginfo_memcache_object_connect) + PHP_NAMED_FE(addserver, zif_memcache_pool_addserver, arginfo_memcache_object_addserver) + PHP_FALIAS(setserverparams, memcache_set_server_params, arginfo_memcache_object_setserverparams) + PHP_FALIAS(setfailurecallback, memcache_set_failure_callback, arginfo_memcache_object_setfailurecallback) + PHP_FALIAS(getserverstatus, memcache_get_server_status, arginfo_memcache_object_getserverstatus) + PHP_NAMED_FE(findserver, zif_memcache_pool_findserver, arginfo_memcache_object_findserver) + PHP_FALIAS(getversion, memcache_get_version, arginfo_memcache_object_getversion) + PHP_FALIAS(add, memcache_add, arginfo_memcache_object_add) + PHP_FALIAS(set, memcache_set, arginfo_memcache_object_set) + PHP_FALIAS(replace, memcache_replace, arginfo_memcache_object_replace) + PHP_FALIAS(cas, memcache_cas, arginfo_memcache_object_cas) + PHP_FALIAS(append, memcache_append, arginfo_memcache_object_append) + PHP_FALIAS(prepend, memcache_prepend, arginfo_memcache_object_prepend) PHP_FALIAS(get, memcache_get, arginfo_memcache_object_get) - PHP_FALIAS(delete, memcache_delete, NULL) - PHP_FALIAS(getstats, memcache_get_stats, NULL) - PHP_FALIAS(getextendedstats, memcache_get_extended_stats, NULL) - PHP_FALIAS(setcompressthreshold, memcache_set_compress_threshold, NULL) - PHP_FALIAS(increment, memcache_increment, NULL) - PHP_FALIAS(decrement, memcache_decrement, NULL) - PHP_FALIAS(close, memcache_close, NULL) - PHP_FALIAS(flush, memcache_flush, NULL) - PHP_FALIAS(setSaslAuthData, memcache_set_sasl_auth_data, NULL) - - {NULL, NULL, NULL} + PHP_FALIAS(delete, memcache_delete, arginfo_memcache_object_delete) + PHP_FALIAS(getstats, memcache_get_stats, arginfo_memcache_object_getstats) + PHP_FALIAS(getextendedstats, memcache_get_extended_stats, arginfo_memcache_object_getextendedstats) + PHP_FALIAS(setcompressthreshold, memcache_set_compress_threshold, arginfo_memcache_object_setcompressthreshold) + PHP_FALIAS(increment, memcache_increment, arginfo_memcache_object_increment) + PHP_FALIAS(decrement, memcache_decrement, arginfo_memcache_object_decrement) + PHP_FALIAS(close, memcache_close, arginfo_memcache_object_close) + PHP_FALIAS(flush, memcache_flush, arginfo_memcache_object_flush) + PHP_FALIAS(setSaslAuthData, memcache_set_sasl_auth_data, arginfo_memcache_object_setSaslAuthData) + ZEND_FE_END }; static zend_function_entry php_memcache_class_functions[] = { - PHP_FALIAS(connect, memcache_connect, NULL) - PHP_FALIAS(pconnect, memcache_pconnect, NULL) - PHP_FALIAS(addserver, memcache_add_server, NULL) - {NULL, NULL, NULL} + PHP_ME_MAPPING(connect, memcache_connect, arginfo_memcache_connect, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(pconnect, memcache_pconnect, arginfo_memcache_pconnect, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(addserver, memcache_add_server, arginfo_memcache_object_addserver, ZEND_ACC_PUBLIC) + ZEND_FE_END }; /* }}} */ @@ -269,7 +464,7 @@ static PHP_INI_MH(OnUpdatePrefixStaticKey) /* {{{ */ if (new_value) { for (i=0 ; iprotocol == &mmc_binary_protocol) { zval rv1, rv2; - zval *username = zend_read_property(memcache_ce, mmc_object, "username", strlen("username"), 1, &rv1); - zval *password = zend_read_property(memcache_ce, mmc_object, "password", strlen("password"), 1, &rv2); + zval *username = zend_read_property(memcache_ce, Z_OBJ_P(mmc_object), "username", strlen("username"), 1, &rv1); + zval *password = zend_read_property(memcache_ce, Z_OBJ_P(mmc_object), "password", strlen("password"), 1, &rv2); if (Z_TYPE_P(username) == IS_STRING && Z_TYPE_P(password) == IS_STRING) { if (Z_STRLEN_P(username) > 1 && Z_STRLEN_P(password) > 1) { mmc_request_t *request; @@ -1058,7 +1253,7 @@ static void php_mmc_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool persistent) /* initialize pool and object if need be */ if (!mmc_object) { zend_resource *list_res; - mmc_pool_t *pool = mmc_pool_new(); + pool = mmc_pool_new(); pool->failure_callback = (mmc_failure_callback) &php_mmc_failure_callback; list_res = zend_register_resource(pool, le_memcache_pool); mmc_object = return_value; @@ -1241,7 +1436,7 @@ static void php_mmc_failure_callback(mmc_pool_t *pool, mmc_t *mmc, zval *param) } ZVAL_LONG(errnum, mmc->errnum); - call_user_function_ex(EG(function_table), NULL, callback, &retval, 5, params, 0, NULL); + call_user_function(EG(function_table), NULL, callback, &retval, 5, params); zval_ptr_dtor(host); zval_ptr_dtor(tcp_port); zval_ptr_dtor(udp_port); @@ -1252,7 +1447,7 @@ static void php_mmc_failure_callback(mmc_pool_t *pool, mmc_t *mmc, zval *param) } } else { - php_mmc_set_failure_callback(pool, (zval *)param, NULL); + php_mmc_set_failure_callback(pool, param, NULL); php_error_docref(NULL, E_WARNING, "Invalid failure callback"); } } @@ -1754,6 +1949,9 @@ int mmc_value_handler_multi( if (Z_TYPE_P(result[0]) != IS_ARRAY) { array_init(result[0]); } + + ZEND_ASSERT(key_len > 0); + add_assoc_zval_ex(result[0], (char *)key, key_len, value); /* add flags to result */ @@ -2241,8 +2439,8 @@ PHP_FUNCTION(memcache_set_sasl_auth_data) if (user_length < 1 || password_length < 1) { RETURN_FALSE; } - zend_update_property_stringl(memcache_pool_ce, mmc_object, "username", strlen("username"), user, user_length); - zend_update_property_stringl(memcache_pool_ce, mmc_object, "password", strlen("password"), password, password_length); + zend_update_property_stringl(memcache_pool_ce, Z_OBJ_P(mmc_object), "username", strlen("username"), user, user_length); + zend_update_property_stringl(memcache_pool_ce, Z_OBJ_P(mmc_object), "password", strlen("password"), password, password_length); RETURN_TRUE; } /* }}} */ diff --git a/php7/memcache_ascii_protocol.c b/php7/memcache_ascii_protocol.c index dd31382..d2c9f27 100644 --- a/php7/memcache_ascii_protocol.c +++ b/php7/memcache_ascii_protocol.c @@ -129,7 +129,7 @@ static int mmc_request_parse_mutate(mmc_t *mmc, mmc_request_t *request) /* return request->response_handler(mmc, request, response, line, line_len - (sizeof("\r\n")-1), request->response_handler_param); } - if (sscanf(line, "%lu", &lval) < 1) { + if (sscanf(line, "%ld", &lval) < 1) { return mmc_server_failure(mmc, request->io, "Malformed VALUE header", 0); } diff --git a/php7/memcache_pool.c b/php7/memcache_pool.c index 0df2055..2960301 100644 --- a/php7/memcache_pool.c +++ b/php7/memcache_pool.c @@ -733,7 +733,16 @@ static int mmc_server_connect(mmc_pool_t *pool, mmc_t *mmc, mmc_stream_t *io, in /* check connection and extract socket for select() purposes */ if (!io->stream || php_stream_cast(io->stream, PHP_STREAM_AS_FD_FOR_SELECT, (void **)&fd, 1) != SUCCESS) { - mmc_server_seterror(mmc, errstr != NULL ? ZSTR_VAL(errstr) : "Connection failed", errnum); + if (errstr != NULL) { + zend_string* error = zend_string_concat2( + "Connection failed: ", sizeof("Connection failed: ") - 1, + ZSTR_VAL(errstr), ZSTR_LEN(errstr)); + + mmc_server_seterror(mmc, ZSTR_VAL(error), errnum); + zend_string_release(error); + } else { + mmc_server_seterror(mmc, "Connection failed", errnum); + } mmc_server_deactivate(pool, mmc); if (errstr != NULL) { @@ -821,6 +830,8 @@ void mmc_server_sleep(mmc_t *mmc) /* void mmc_server_free(mmc_t *mmc) /* {{{ */ { + mmc_server_sleep(mmc); + pefree(mmc->host, mmc->persistent); pefree(mmc, mmc->persistent); } diff --git a/php7/memcache_session.c b/php7/memcache_session.c index 4cc356d..0e027f5 100644 --- a/php7/memcache_session.c +++ b/php7/memcache_session.c @@ -64,12 +64,13 @@ PS_OPEN_FUNC(memcache) } if (!path) { PS_SET_MOD_DATA(NULL); + ZEND_ASSERT(0 && "open"); return FAILURE; } pool = mmc_pool_new(); - for (i=0,j=0,path_len=strlen(path); ikey, &(datarequest->key_len), MEMCACHE_G(session_key_prefix)) != MMC_OK) { mmc_pool_release(pool, datarequest); + if (lockrequest != NULL) { + mmc_pool_release(pool, lockrequest); + } break; } @@ -450,6 +455,7 @@ PS_WRITE_FUNC(memcache) mmc_pool_schedule(pool, mmc, lockrequest) != MMC_OK) { mmc_pool_release(pool, datarequest); mmc_pool_release(pool, lockrequest); + lockrequest = NULL; continue; } } while (skip_servers.len < MEMCACHE_G(session_redundancy) && skip_servers.len < pool->num_servers); diff --git a/tests/001.phpt b/tests/001.phpt index fe25dd1..582542a 100644 --- a/tests/001.phpt +++ b/tests/001.phpt @@ -19,8 +19,17 @@ memcache_set($memcache, $key, $value, false, 10); var_dump($key); var_dump($value); -memcache_set($memcache, $key); -$memcache->set($key); +try { + memcache_set($memcache, $key); +} catch (ArgumentCountError $e) { + echo "{$e->getMessage()}\n"; +} + +try { + $memcache->set($key); +} catch (ArgumentCountError $e) { + echo "{$e->getMessage()}\n"; +} echo "Done\n"; @@ -28,8 +37,6 @@ echo "Done\n"; --EXPECTF-- int(123) int(123) - -Warning: %s parameter%s - -Warning: %s parameter%s +Wrong parameter count for memcache_set() +Wrong parameter count for MemcachePool::set() Done \ No newline at end of file diff --git a/tests/019a.phpt b/tests/019a.phpt index 8602958..461cc54 100644 --- a/tests/019a.phpt +++ b/tests/019a.phpt @@ -9,8 +9,18 @@ include 'connect.inc'; var_dump(memcache_add_server($memcache, $host2, $port2)); var_dump(memcache_add_server($memcache, $nonExistingHost, $nonExistingPort)); -var_dump(memcache_add_server(new stdclass, $host2, $port2)); -var_dump(memcache_add_server($memcache, new stdclass, array())); + +try { + var_dump(memcache_add_server(new stdclass, $host2, $port2)); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} + +try { + var_dump(memcache_add_server($memcache, new stdclass, array())); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} echo "Done\n"; @@ -18,10 +28,6 @@ echo "Done\n"; --EXPECTF-- bool(true) bool(true) - -Warning: memcache_add_server() expects parameter 1 to be Memcache, object given in %s on line %d -NULL - -Warning: memcache_add_server() expects parameter 2 to be string, object given in %s on line %d -NULL +memcache_add_server(): Argument #1 ($memcache) must be of type Memcache, stdClass given +memcache_add_server(): Argument #2 ($host) must be of type string, stdClass given Done diff --git a/tests/022a.phpt b/tests/022a.phpt index f76f674..31de368 100644 --- a/tests/022a.phpt +++ b/tests/022a.phpt @@ -14,8 +14,16 @@ memcache_add_server($memcache, $host2, $port2); $result1 = @memcache_get_stats($memcache); $result2 = @memcache_get_extended_stats($memcache); -var_dump(memcache_get_extended_stats(array())); -var_dump(memcache_get_extended_stats(new stdClass)); +try { + var_dump(memcache_get_extended_stats(array())); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} +try { + var_dump(memcache_get_extended_stats(new stdClass)); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} var_dump($result1['pid']); @@ -26,11 +34,8 @@ var_dump($result2["$nonExistingHost:$nonExistingPort"]); ?> --EXPECTF-- -Warning: memcache_get_extended_stats() expects parameter 1 to be MemcachePool, array given in %s on line %d -NULL - -Warning: memcache_get_extended_stats() expects parameter 1 to be MemcachePool, object given in %s on line %d -NULL +memcache_get_extended_stats(): Argument #1 ($memcache) must be of type MemcachePool, array given +memcache_get_extended_stats(): Argument #1 ($memcache) must be of type MemcachePool, stdClass given string(%d) "%d" int(3) string(%d) "%d" diff --git a/tests/024a.phpt b/tests/024a.phpt index a739750..6a464dd 100644 --- a/tests/024a.phpt +++ b/tests/024a.phpt @@ -29,8 +29,16 @@ var_dump($result5); var_dump(memcache_close($memcache)); var_dump(memcache_close($memcache)); -var_dump(memcache_close(new stdClass)); -var_dump(memcache_close("")); +try { + var_dump(memcache_close(new stdClass)); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} +try { + var_dump(memcache_close("")); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} echo "Done\n"; @@ -43,10 +51,6 @@ bool(true) bool(false) bool(true) bool(true) - -Warning: memcache_close() expects parameter 1 to be MemcachePool, object given in %s on line %d -NULL - -Warning: memcache_close() expects parameter 1 to be MemcachePool, string given in %s on line %d -NULL +memcache_close(): Argument #1 ($memcache) must be of type MemcachePool, stdClass given +memcache_close(): Argument #1 ($memcache) must be of type MemcachePool, string given Done diff --git a/tests/027a.phpt b/tests/027a.phpt index 57eec40..50ef564 100644 --- a/tests/027a.phpt +++ b/tests/027a.phpt @@ -30,12 +30,19 @@ $result6 = memcache_get($memcache, 'non_existing_test_key'); var_dump($result5); var_dump($result6); - -var_dump(memcache_set_compress_threshold(array(), 10000, 0)); +try { + var_dump(memcache_set_compress_threshold(array(), 10000, 0)); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} var_dump(memcache_set_compress_threshold($memcache, -1, -1)); var_dump(memcache_set_compress_threshold($memcache, 1, -1)); var_dump(memcache_set_compress_threshold($memcache, -1, 1)); -var_dump(memcache_set_compress_threshold(new stdClass, 1, 1)); +try { + var_dump(memcache_set_compress_threshold(new stdClass, 1, 1)); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} echo "Done\n"; @@ -47,9 +54,7 @@ bool(true) bool(true) bool(true) string(3) "abc" - -Warning: memcache_set_compress_threshold() expects parameter 1 to be MemcachePool, array given in %s on line %d -NULL +memcache_set_compress_threshold(): Argument #1 ($memcache) must be of type MemcachePool, array given Warning: memcache_set_compress_threshold()%s threshold must be a positive integer in %s on line %d bool(false) @@ -59,7 +64,5 @@ bool(false) Warning: memcache_set_compress_threshold()%s threshold must be a positive integer in %s on line %d bool(false) - -Warning: memcache_set_compress_threshold() expects parameter 1 to be MemcachePool, object given in %s on line %d -NULL +memcache_set_compress_threshold(): Argument #1 ($memcache) must be of type MemcachePool, stdClass given Done diff --git a/tests/040.phpt b/tests/040.phpt index 12c7446..949aca1 100644 --- a/tests/040.phpt +++ b/tests/040.phpt @@ -12,6 +12,7 @@ $memcache->set($balanceKey1, 1, 0, 10); $memcache->set($balanceKey2, 2, 0, 10); $result = $memcache->increment(array($balanceKey1, $balanceKey2), 1); +asort($result); var_dump($result); $result1 = $memcache->get($balanceKey1); @@ -20,18 +21,22 @@ var_dump($result1); var_dump($result2); $result = $memcache->decrement(array($balanceKey1, $balanceKey2), 1); +asort($result); var_dump($result); $result = memcache_increment($memcache, array($balanceKey1, $balanceKey2), 1); +asort($result); var_dump($result); $result = memcache_decrement($memcache, array($balanceKey1, $balanceKey2), 1); +asort($result); var_dump($result); $result = $memcache->increment(array()); var_dump($result); $result = $memcache->increment(array('unset_test_key', 'unset_test_key1')); +asort($result); var_dump($result); ?> diff --git a/tests/044.phpt b/tests/044.phpt index a49b139..e829836 100644 --- a/tests/044.phpt +++ b/tests/044.phpt @@ -3,12 +3,7 @@ ini_set('memcache.session_redundancy') --SKIPIF-- - --FILE-- delete($balanceKey1); +$memcache1->delete($balanceKey2); $memcache2->delete($balanceKey1); +$memcache2->delete($balanceKey2); // Test set session_id($balanceKey1); @@ -38,7 +35,7 @@ var_dump($result2); // Test delete session_id($balanceKey1); -@session_start(); +session_start(); session_destroy(); $result1 = $memcache1->get($balanceKey1); @@ -48,7 +45,7 @@ var_dump($result2); // Test lost session on server1 session_id($balanceKey1); -@session_start(); +session_start(); $_SESSION['key'] = 'Test2'; session_write_close(); unset($_SESSION['key']); @@ -63,7 +60,7 @@ session_write_close(); // Test lost session on server2 session_id($balanceKey2); -@session_start(); +session_start(); $_SESSION['key'] = 'Test3'; session_write_close(); unset($_SESSION['key']); @@ -72,7 +69,7 @@ $result = $memcache2->delete($balanceKey1); var_dump($result); session_id($balanceKey2); -@session_start(); +session_start(); var_dump($_SESSION); session_write_close(); ob_flush(); diff --git a/tests/044b.phpt b/tests/044b.phpt index eec9368..dbd95a4 100644 --- a/tests/044b.phpt +++ b/tests/044b.phpt @@ -3,11 +3,6 @@ ini_set('memcache.session_redundancy') --SKIPIF-- 70200)) { - die("skip"); -} ?> --FILE-- diff --git a/tests/100a.phpt b/tests/100a.phpt index 6170b27..5cf1d3d 100644 --- a/tests/100a.phpt +++ b/tests/100a.phpt @@ -27,8 +27,16 @@ var_dump($result); memcache_close($memcache); var_dump(memcache_flush($memcache)); -var_dump(memcache_flush(new stdClass)); -var_dump(memcache_flush('')); +try { + var_dump(memcache_flush(new stdClass)); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} +try { + var_dump(memcache_flush('')); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} echo "Done\n"; @@ -38,10 +46,6 @@ bool(true) bool(false) bool(false) bool(true) - -Warning: memcache_flush() expects parameter 1 to be MemcachePool, object given in %s on line %d -NULL - -Warning: memcache_flush() expects parameter 1 to be MemcachePool, string given in %s on line %d -NULL +memcache_flush(): Argument #1 ($memcache) must be of type MemcachePool, stdClass given +memcache_flush(): Argument #1 ($memcache) must be of type MemcachePool, string given Done diff --git a/tests/bug73539.phpt b/tests/bug73539.phpt index 812ece5..07e9c3c 100644 --- a/tests/bug73539.phpt +++ b/tests/bug73539.phpt @@ -2,11 +2,7 @@ memcache multi host save path function --SKIPIF-- 70000) { - die("skip not relevant for php 7.1+ -"); -} +include 'connect.inc'; ?> --FILE-- --EXPECTF-- array(1) { - 'bof.test' => + ["bof.test"]=> int(42) } array(1) { - 'bof.test' => + ["bof.test"]=> int(42) } array(1) { - 'bof.test' => + ["bof.test"]=> int(42) } - Done diff --git a/tests/connect.inc b/tests/connect.inc index 4ccdd31..69fc3b0 100644 --- a/tests/connect.inc +++ b/tests/connect.inc @@ -1,7 +1,7 @@ From 07375853ad960c868fc7d47eb8792ffaae5d3811 Mon Sep 17 00:00:00 2001 From: Zaffy Date: Thu, 24 Sep 2020 16:05:42 +0200 Subject: [PATCH 03/12] php7 -> php8 --- README | 2 +- config.w32 | 4 ++-- config9.m4 | 4 ++-- package.xml | 2 +- {php7 => php8}/memcache.c | 0 {php7 => php8}/memcache_ascii_protocol.c | 0 {php7 => php8}/memcache_binary_protocol.c | 0 {php7 => php8}/memcache_consistent_hash.c | 0 {php7 => php8}/memcache_pool.c | 0 {php7 => php8}/memcache_pool.h | 0 {php7 => php8}/memcache_queue.c | 0 {php7 => php8}/memcache_queue.h | 0 {php7 => php8}/memcache_session.c | 0 {php7 => php8}/memcache_standard_hash.c | 0 {php7 => php8}/php_memcache.h | 0 15 files changed, 6 insertions(+), 6 deletions(-) rename {php7 => php8}/memcache.c (100%) rename {php7 => php8}/memcache_ascii_protocol.c (100%) rename {php7 => php8}/memcache_binary_protocol.c (100%) rename {php7 => php8}/memcache_consistent_hash.c (100%) rename {php7 => php8}/memcache_pool.c (100%) rename {php7 => php8}/memcache_pool.h (100%) rename {php7 => php8}/memcache_queue.c (100%) rename {php7 => php8}/memcache_queue.h (100%) rename {php7 => php8}/memcache_session.c (100%) rename {php7 => php8}/memcache_standard_hash.c (100%) rename {php7 => php8}/php_memcache.h (100%) diff --git a/README b/README index 6868734..824d5fd 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ This is an official repository for pecl-memcache plugin since 2019. -This repository contains modified pecl-memcache plugin ported to PHP7, +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 4.0.5.1 (released: 2019-12-19) with support for PHP 7.0-7.4. diff --git a/config.w32 b/config.w32 index d626820..13c987e 100644 --- a/config.w32 +++ b/config.w32 @@ -9,8 +9,8 @@ if (PHP_MEMCACHE != "no") { var dll = get_define('PHPDLL'); var old_conf_dir = configure_module_dirname; - if (dll.match(/^php7/) != null) { - configure_module_dirname = configure_module_dirname + "\\php7"; + if (dll.match(/^php8/) != null) { + configure_module_dirname = configure_module_dirname + "\\php8"; } else if (dll.match(/^php5/) != null) { ERROR("PHP 7.x required for pecl-php-memcache ver 4+. Use pecl-php-meachce ver 3.x for PHP 5.x."); } else { diff --git a/config9.m4 b/config9.m4 index aa540ee..d132937 100644 --- a/config9.m4 +++ b/config9.m4 @@ -64,7 +64,7 @@ if test "$PHP_MEMCACHE" != "no"; then fi AC_MSG_CHECKING(PHP version) - if test -d $abs_srcdir/php7 ; then + if test -d $abs_srcdir/php8 ; then dnl # only when for PECL, not for PHP export OLD_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS $INCLUDES" @@ -73,7 +73,7 @@ if test "$PHP_MEMCACHE" != "no"; then #error "PHP < 7" #endif ], [ - subdir=php7 + subdir=php8 AC_MSG_RESULT([PHP 7.x]) ], AC_MSG_ERROR([PHP 7.x required for pecl-php-memcache ver 4+. Use pecl-php-memcache ver 3.x for PHP 5.x.]) diff --git a/package.xml b/package.xml index 265aa1b..28bd913 100644 --- a/package.xml +++ b/package.xml @@ -66,7 +66,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> - + diff --git a/php7/memcache.c b/php8/memcache.c similarity index 100% rename from php7/memcache.c rename to php8/memcache.c diff --git a/php7/memcache_ascii_protocol.c b/php8/memcache_ascii_protocol.c similarity index 100% rename from php7/memcache_ascii_protocol.c rename to php8/memcache_ascii_protocol.c diff --git a/php7/memcache_binary_protocol.c b/php8/memcache_binary_protocol.c similarity index 100% rename from php7/memcache_binary_protocol.c rename to php8/memcache_binary_protocol.c diff --git a/php7/memcache_consistent_hash.c b/php8/memcache_consistent_hash.c similarity index 100% rename from php7/memcache_consistent_hash.c rename to php8/memcache_consistent_hash.c diff --git a/php7/memcache_pool.c b/php8/memcache_pool.c similarity index 100% rename from php7/memcache_pool.c rename to php8/memcache_pool.c diff --git a/php7/memcache_pool.h b/php8/memcache_pool.h similarity index 100% rename from php7/memcache_pool.h rename to php8/memcache_pool.h diff --git a/php7/memcache_queue.c b/php8/memcache_queue.c similarity index 100% rename from php7/memcache_queue.c rename to php8/memcache_queue.c diff --git a/php7/memcache_queue.h b/php8/memcache_queue.h similarity index 100% rename from php7/memcache_queue.h rename to php8/memcache_queue.h diff --git a/php7/memcache_session.c b/php8/memcache_session.c similarity index 100% rename from php7/memcache_session.c rename to php8/memcache_session.c diff --git a/php7/memcache_standard_hash.c b/php8/memcache_standard_hash.c similarity index 100% rename from php7/memcache_standard_hash.c rename to php8/memcache_standard_hash.c diff --git a/php7/php_memcache.h b/php8/php_memcache.h similarity index 100% rename from php7/php_memcache.h rename to php8/php_memcache.h From eb5593a9df0a7ce8fbcc7010fdfe37e205f31020 Mon Sep 17 00:00:00 2001 From: Zaffy Date: Thu, 1 Oct 2020 16:05:13 +0200 Subject: [PATCH 04/12] Add test for #53 --- tests/githubbug53.phpt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/githubbug53.phpt diff --git a/tests/githubbug53.phpt b/tests/githubbug53.phpt new file mode 100644 index 0000000..6db01f2 --- /dev/null +++ b/tests/githubbug53.phpt @@ -0,0 +1,26 @@ +--TEST-- +Module shouldn't crash on failed serialization +--SKIPIF-- + +--FILE-- +set('foobar', $oFoo); + +--EXPECTF-- +Warning: MemcachePool::set(): Failed to serialize value in %s on line %d + +Fatal error: Uncaught Exception: fail in %s:%d +Stack trace: +#0 [internal function]: foo->__sleep() +#1 %s(%d): MemcachePool->set('foobar', Object(foo)) +#2 {main} + thrown in %s on line %d From cab69b8afc2b86b536a65e2025e3c7b0b4849a6b Mon Sep 17 00:00:00 2001 From: Zaffy Date: Fri, 2 Oct 2020 01:24:22 +0200 Subject: [PATCH 05/12] Fix support for binary protocol --- docker/start.sh | 6 ++- php8/memcache_ascii_protocol.c | 7 ++- php8/memcache_binary_protocol.c | 86 +++++++++++++++++++++++++-------- tests/connect.inc | 2 +- tests/pecl17518.phpt | 9 ++-- 5 files changed, 82 insertions(+), 28 deletions(-) diff --git a/docker/start.sh b/docker/start.sh index 14b3524..38e06d5 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -29,4 +29,8 @@ chown memcache:memcache /var/run/memcached # Let's start tests cd /usr/src/pecl-memcache -NO_INTERACTION=1 TEST_PHP_ARGS="--show-diff --keep-all -w fails.log" make test +export NO_INTERACTION=1 +export TEST_PHP_ARGS="--show-diff --keep-all -w fails.log" + +MEMCACHE_PROTOCOL=ascii make test +MEMCACHE_PROTOCOL=binary make test diff --git a/php8/memcache_ascii_protocol.c b/php8/memcache_ascii_protocol.c index d2c9f27..a458da4 100644 --- a/php8/memcache_ascii_protocol.c +++ b/php8/memcache_ascii_protocol.c @@ -56,11 +56,16 @@ static int mmc_stream_get_line(mmc_stream_t *io, char **line) /* } /* }}} */ -static int mmc_request_check_response(const char *line, int line_len) /* +static int mmc_request_check_response(char *line, int line_len) /* checks for response status and error codes {{{ */ { int response; + // remove newline and thus prevent passing it to userland + if (line_len >= 2 && line[line_len - 2] == '\r' && line[line_len - 1] == '\n') { + line[line_len - 2] = '\0'; + } + if (mmc_str_left(line, "OK", line_len, sizeof("OK")-1) || mmc_str_left(line, "STORED", line_len, sizeof("STORED")-1) || mmc_str_left(line, "DELETED", line_len, sizeof("DELETED")-1)) diff --git a/php8/memcache_binary_protocol.c b/php8/memcache_binary_protocol.c index dfd8060..707b351 100644 --- a/php8/memcache_binary_protocol.c +++ b/php8/memcache_binary_protocol.c @@ -61,6 +61,12 @@ uint64_t mmc_htonll(uint64_t value); # define htonll mmc_htonll #endif +#ifdef __GNUC__ +# define MMC_ATTR_PACKED __attribute__((packed)) +#else +# define MMC_ATTR_PACKED +#endif /* UD_ATTR_PACKED */ + #define MMC_REQUEST_MAGIC 0x80 #define MMC_RESPONSE_MAGIC 0x81 @@ -79,6 +85,15 @@ uint64_t mmc_htonll(uint64_t value); #define MMC_BIN_OP_APPEND 0x0e #define MMC_BIN_OP_PREPEND 0x0f +#define MMC_BINARY_STATUS_OK 0x00 +#define MMC_BINARY_STATUS_KEY_NOT_FOUND 0x01 +#define MMC_BINARY_STATUS_KEY_EXISTS 0x02 +#define MMC_BINARY_STATUS_VALUE_TOO_LARGE 0x03 +#define MMC_BINARY_STATUS_INVALID_ARGS 0x04 +#define MMC_BINARY_STATUS_ITEM_NOT_STORED 0x05 +#define MMC_BINARY_STATUS_INCR_DECR_ERROR 0x06 /* Incr/Decr on non-numeric value */ +#define MMC_BINARY_STATUS_UNKNOWN_COMMAND 0x81 +#define MMC_BINARY_STATUS_OUT_OF_MEMORY 0x82 #define MMC_OP_SASL_LIST 0x20 #define MMC_OP_SASL_AUTH 0x21 @@ -90,7 +105,7 @@ typedef struct mmc_binary_request { mmc_queue_t keys; /* mmc_queue_t, reqid -> key mappings */ struct { uint8_t opcode; - uint8_t error; /* error received in current request */ + uint16_t error; /* error received in current request */ uint32_t reqid; /* current reqid being processed */ } command; struct { /* stores value info while the body is being read */ @@ -107,64 +122,63 @@ typedef struct mmc_request_header { uint8_t extras_len; uint8_t datatype; uint16_t _reserved; - uint32_t length; /* trailing body length (not including this header) */ + uint32_t length; /* trailing body total_body_length (not including this header) */ uint32_t reqid; /* opaque request id */ uint64_t cas; -} mmc_request_header_t; +} MMC_ATTR_PACKED mmc_request_header_t; typedef struct mmc_get_request_header { mmc_request_header_t base; -} mmc_get_request_header_t; +} MMC_ATTR_PACKED mmc_get_request_header_t; typedef struct mmc_version_request_header { mmc_request_header_t base; -} mmc_version_request_header_t; +} MMC_ATTR_PACKED mmc_version_request_header_t; typedef struct mmc_store_request_header { mmc_request_header_t base; uint32_t flags; uint32_t exptime; -} mmc_store_request_header_t; +} MMC_ATTR_PACKED mmc_store_request_header_t; typedef struct mmc_store_append_header { mmc_request_header_t base; -} mmc_store_append_header_t; +} MMC_ATTR_PACKED mmc_store_append_header_t; typedef struct mmc_delete_request_header { mmc_request_header_t base; - uint32_t exptime; -} mmc_delete_request_header_t; +} MMC_ATTR_PACKED mmc_delete_request_header_t; typedef struct mmc_mutate_request_header { mmc_request_header_t base; uint64_t delta; uint64_t initial; uint32_t expiration; -} mmc_mutate_request_header_t; +} MMC_ATTR_PACKED mmc_mutate_request_header_t; typedef struct mmc_sasl_request_header { mmc_request_header_t base; -} mmc_sasl_request_header; +} MMC_ATTR_PACKED mmc_sasl_request_header; typedef struct mmc_response_header { uint8_t magic; uint8_t opcode; - uint16_t error; + uint16_t key_len; uint8_t extras_len; uint8_t datatype; uint16_t status; - uint32_t length; /* trailing body length (not including this header) */ + uint32_t total_body_length; /* trailing body total_body_length (not including this header) */ uint32_t reqid; /* echo'ed from request */ uint64_t cas; -} mmc_response_header_t; +} MMC_ATTR_PACKED mmc_response_header_t; typedef struct mmc_get_response_header { uint32_t flags; -} mmc_get_response_header_t; +} MMC_ATTR_PACKED mmc_get_response_header_t; typedef struct mmc_mutate_response_header { uint64_t value; -} mmc_mutate_response_header_t; +} MMC_ATTR_PACKED mmc_mutate_response_header_t; static int mmc_request_read_response(mmc_t *, mmc_request_t *); static int mmc_request_parse_value(mmc_t *, mmc_request_t *); @@ -252,9 +266,40 @@ static int mmc_request_parse_response(mmc_t *mmc, mmc_request_t *request) /* } req->command.opcode = header->opcode; - req->command.error = ntohs(header->error); + + switch (ntohs(header->status)) { + case MMC_BINARY_STATUS_OK: + req->command.error = MMC_OK; + break; + case MMC_BINARY_STATUS_KEY_NOT_FOUND: + req->command.error = MMC_RESPONSE_NOT_FOUND; + break; + case MMC_BINARY_STATUS_KEY_EXISTS: + req->command.error = MMC_RESPONSE_EXISTS; + break; + case MMC_BINARY_STATUS_VALUE_TOO_LARGE: + req->command.error = MMC_RESPONSE_TOO_LARGE; + break; + case MMC_BINARY_STATUS_INVALID_ARGS: + case MMC_BINARY_STATUS_INCR_DECR_ERROR: + req->command.error = MMC_RESPONSE_CLIENT_ERROR; + break; + case MMC_BINARY_STATUS_ITEM_NOT_STORED: + req->command.error = MMC_RESPONSE_NOT_STORED; + break; + case MMC_BINARY_STATUS_UNKNOWN_COMMAND: + req->command.error = MMC_RESPONSE_UNKNOWN_CMD; + break; + case MMC_BINARY_STATUS_OUT_OF_MEMORY: + req->command.error = MMC_RESPONSE_OUT_OF_MEMORY; + break; + default: + req->command.error = MMC_RESPONSE_UNKNOWN; + break; + } + req->command.reqid = ntohl(header->reqid); - req->value.length = ntohl(header->length); + req->value.length = ntohl(header->total_body_length); req->value.cas = ntohll(header->cas); if (req->value.length == 0) { @@ -434,6 +479,7 @@ static inline void mmc_pack_header(mmc_request_header_t *header, uint8_t opcode, header->_reserved = 0; header->length = htonl(key_len + extras_len + length); header->reqid = htonl(reqid); + header->cas = 0; } /* }}} */ @@ -618,8 +664,7 @@ static void mmc_binary_delete(mmc_request_t *request, const char *key, unsigned request->parse = mmc_request_parse_response; req->next_parse_handler = mmc_request_read_response; - mmc_pack_header(&(header.base), MMC_OP_DELETE, 0, key_len, sizeof(header) - sizeof(header.base), 0); - header.exptime = htonl(exptime); + mmc_pack_header(&(header.base), MMC_OP_DELETE, 0, key_len, 0, 0); smart_string_appendl(&(request->sendbuf.value), (const char *)&header, sizeof(header)); smart_string_appendl(&(request->sendbuf.value), key, key_len); @@ -659,7 +704,6 @@ static void mmc_binary_mutate(mmc_request_t *request, zval *zkey, const char *ke else { /* server replies with NOT_FOUND if exptime ~0 and key doesn't exist */ header.expiration = ~(uint32_t)0; - header.expiration = htonl(0x00000e10); } /* mutate request is 43 bytes */ diff --git a/tests/connect.inc b/tests/connect.inc index 69fc3b0..8149b7c 100644 --- a/tests/connect.inc +++ b/tests/connect.inc @@ -20,7 +20,7 @@ $port2 = 11212; //ini_set('memcache.hash_strategy', 'standard'); //ini_set('memcache.hash_function', 'fnv'); -//ini_set('memcache.protocol', 'binary'); +ini_set('memcache.protocol', getenv('MEMCACHE_PROTOCOL') ?: 'ascii'); if (ini_get('memcache.protocol') == 'binary') { $udpPort = 0; diff --git a/tests/pecl17518.phpt b/tests/pecl17518.phpt index 4c342b3..93b4c7c 100644 --- a/tests/pecl17518.phpt +++ b/tests/pecl17518.phpt @@ -10,6 +10,10 @@ include 'connect.inc'; $m = new Memcache(); $m->connect('localhost', 11211); +$m->delete('a'); +$m->delete('b'); +$m->delete('c'); + var_dump($m->increment('a', 42)); var_dump($m->get('a')); @@ -21,14 +25,11 @@ $m->set('c', 1); var_dump($m->increment('c', 42)); var_dump($m->get('c')); -$m->flush(); -?> --EXPECTF-- bool(false) bool(false) -Notice: MemcachePool::increment(): Server localhost (tcp 11211, udp 0) failed with: CLIENT_ERROR cannot increment or decrement non-numeric value - (6) in %s/pecl17518.php on line 12 +Notice: MemcachePool::increment(): Server localhost (tcp 11211, udp 0) failed with: %s (%d) in %s bool(false) string(3) "bar" int(43) From 2ee0fffc350e2d8303e0504a50a723c2c49e31c8 Mon Sep 17 00:00:00 2001 From: Zaffy Date: Sat, 3 Oct 2020 14:13:46 +0200 Subject: [PATCH 06/12] php8 -> src --- config.w32 | 4 ++-- config9.m4 | 4 ++-- package.xml | 2 +- {php8 => src}/memcache.c | 0 {php8 => src}/memcache_ascii_protocol.c | 0 {php8 => src}/memcache_binary_protocol.c | 0 {php8 => src}/memcache_consistent_hash.c | 0 {php8 => src}/memcache_pool.c | 0 {php8 => src}/memcache_pool.h | 0 {php8 => src}/memcache_queue.c | 0 {php8 => src}/memcache_queue.h | 0 {php8 => src}/memcache_session.c | 0 {php8 => src}/memcache_standard_hash.c | 0 {php8 => src}/php_memcache.h | 0 14 files changed, 5 insertions(+), 5 deletions(-) rename {php8 => src}/memcache.c (100%) rename {php8 => src}/memcache_ascii_protocol.c (100%) rename {php8 => src}/memcache_binary_protocol.c (100%) rename {php8 => src}/memcache_consistent_hash.c (100%) rename {php8 => src}/memcache_pool.c (100%) rename {php8 => src}/memcache_pool.h (100%) rename {php8 => src}/memcache_queue.c (100%) rename {php8 => src}/memcache_queue.h (100%) rename {php8 => src}/memcache_session.c (100%) rename {php8 => src}/memcache_standard_hash.c (100%) rename {php8 => src}/php_memcache.h (100%) diff --git a/config.w32 b/config.w32 index 13c987e..65942ac 100644 --- a/config.w32 +++ b/config.w32 @@ -9,8 +9,8 @@ if (PHP_MEMCACHE != "no") { var dll = get_define('PHPDLL'); var old_conf_dir = configure_module_dirname; - if (dll.match(/^php8/) != null) { - configure_module_dirname = configure_module_dirname + "\\php8"; + if (dll.match(/^src/) != null) { + configure_module_dirname = configure_module_dirname + "\\src"; } else if (dll.match(/^php5/) != null) { ERROR("PHP 7.x required for pecl-php-memcache ver 4+. Use pecl-php-meachce ver 3.x for PHP 5.x."); } else { diff --git a/config9.m4 b/config9.m4 index d132937..d48316f 100644 --- a/config9.m4 +++ b/config9.m4 @@ -64,7 +64,7 @@ if test "$PHP_MEMCACHE" != "no"; then fi AC_MSG_CHECKING(PHP version) - if test -d $abs_srcdir/php8 ; then + if test -d $abs_srcdir/src ; then dnl # only when for PECL, not for PHP export OLD_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS $INCLUDES" @@ -73,7 +73,7 @@ if test "$PHP_MEMCACHE" != "no"; then #error "PHP < 7" #endif ], [ - subdir=php8 + subdir=src AC_MSG_RESULT([PHP 7.x]) ], AC_MSG_ERROR([PHP 7.x required for pecl-php-memcache ver 4+. Use pecl-php-memcache ver 3.x for PHP 5.x.]) diff --git a/package.xml b/package.xml index 28bd913..ced1921 100644 --- a/package.xml +++ b/package.xml @@ -66,7 +66,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> - + diff --git a/php8/memcache.c b/src/memcache.c similarity index 100% rename from php8/memcache.c rename to src/memcache.c diff --git a/php8/memcache_ascii_protocol.c b/src/memcache_ascii_protocol.c similarity index 100% rename from php8/memcache_ascii_protocol.c rename to src/memcache_ascii_protocol.c diff --git a/php8/memcache_binary_protocol.c b/src/memcache_binary_protocol.c similarity index 100% rename from php8/memcache_binary_protocol.c rename to src/memcache_binary_protocol.c diff --git a/php8/memcache_consistent_hash.c b/src/memcache_consistent_hash.c similarity index 100% rename from php8/memcache_consistent_hash.c rename to src/memcache_consistent_hash.c diff --git a/php8/memcache_pool.c b/src/memcache_pool.c similarity index 100% rename from php8/memcache_pool.c rename to src/memcache_pool.c diff --git a/php8/memcache_pool.h b/src/memcache_pool.h similarity index 100% rename from php8/memcache_pool.h rename to src/memcache_pool.h diff --git a/php8/memcache_queue.c b/src/memcache_queue.c similarity index 100% rename from php8/memcache_queue.c rename to src/memcache_queue.c diff --git a/php8/memcache_queue.h b/src/memcache_queue.h similarity index 100% rename from php8/memcache_queue.h rename to src/memcache_queue.h diff --git a/php8/memcache_session.c b/src/memcache_session.c similarity index 100% rename from php8/memcache_session.c rename to src/memcache_session.c diff --git a/php8/memcache_standard_hash.c b/src/memcache_standard_hash.c similarity index 100% rename from php8/memcache_standard_hash.c rename to src/memcache_standard_hash.c diff --git a/php8/php_memcache.h b/src/php_memcache.h similarity index 100% rename from php8/php_memcache.h rename to src/php_memcache.h From dd73db8155c7a7872c10262d74bd4d286d32db45 Mon Sep 17 00:00:00 2001 From: Zaffy Date: Sat, 3 Oct 2020 22:28:21 +0200 Subject: [PATCH 07/12] Backwards compatibility with php 7.3, 7.4 This will allow us to have one unified branch that will compile under different versions of php. --- src/memcache.c | 10 +++++ src/memcache_pool.c | 20 +++++++++- tests/001.phpt | 5 ++- tests/001b.phpt | 47 ++++++++++++++++++++++ tests/019a.phpt | 5 ++- tests/019b.phpt | 38 ++++++++++++++++++ tests/022a.phpt | 5 ++- tests/022b.phpt | 46 ++++++++++++++++++++++ tests/024a.phpt | 5 ++- tests/024b.phpt | 59 ++++++++++++++++++++++++++++ tests/027a.phpt | 5 ++- tests/027b.phpt | 71 ++++++++++++++++++++++++++++++++++ tests/100a.phpt | 5 ++- tests/100bphpt | 54 ++++++++++++++++++++++++++ tests/{100b.phpt => 100c.phpt} | 0 15 files changed, 368 insertions(+), 7 deletions(-) create mode 100644 tests/001b.phpt create mode 100644 tests/019b.phpt create mode 100644 tests/022b.phpt create mode 100644 tests/024b.phpt create mode 100644 tests/027b.phpt create mode 100644 tests/100bphpt rename tests/{100b.phpt => 100c.phpt} (100%) diff --git a/src/memcache.c b/src/memcache.c index a3b6c7a..653f959 100644 --- a/src/memcache.c +++ b/src/memcache.c @@ -1214,8 +1214,13 @@ static mmc_t *php_mmc_pool_addserver( if (pool->protocol == &mmc_binary_protocol) { zval rv1, rv2; +#if PHP_VERSION_ID >= 80000 zval *username = zend_read_property(memcache_ce, Z_OBJ_P(mmc_object), "username", strlen("username"), 1, &rv1); zval *password = zend_read_property(memcache_ce, Z_OBJ_P(mmc_object), "password", strlen("password"), 1, &rv2); +#else + zval *username = zend_read_property(memcache_ce, mmc_object, "username", strlen("username"), 1, &rv1); + zval *password = zend_read_property(memcache_ce, mmc_object, "password", strlen("password"), 1, &rv2); +#endif if (Z_TYPE_P(username) == IS_STRING && Z_TYPE_P(password) == IS_STRING) { if (Z_STRLEN_P(username) > 1 && Z_STRLEN_P(password) > 1) { mmc_request_t *request; @@ -2440,8 +2445,13 @@ PHP_FUNCTION(memcache_set_sasl_auth_data) if (user_length < 1 || password_length < 1) { RETURN_FALSE; } +#if PHP_VERSION_ID >= 80000 zend_update_property_stringl(memcache_pool_ce, Z_OBJ_P(mmc_object), "username", strlen("username"), user, user_length); zend_update_property_stringl(memcache_pool_ce, Z_OBJ_P(mmc_object), "password", strlen("password"), password, password_length); +#else + zend_update_property_stringl(memcache_pool_ce, mmc_object, "username", strlen("username"), user, user_length); + zend_update_property_stringl(memcache_pool_ce, mmc_object, "password", strlen("password"), password, password_length); +#endif RETURN_TRUE; } /* }}} */ diff --git a/src/memcache_pool.c b/src/memcache_pool.c index 2960301..30eb5c4 100644 --- a/src/memcache_pool.c +++ b/src/memcache_pool.c @@ -41,6 +41,24 @@ ZEND_DECLARE_MODULE_GLOBALS(memcache) +#if PHP_VERSION_ID >= 80000 +#define mmc_string_concat2 zend_string_concat2 +#else +static zend_string* mmc_string_concat2( + const char *str1, size_t str1_len, + const char *str2, size_t str2_len) +{ + size_t len = str1_len + str2_len; + zend_string *res = zend_string_alloc(len, 0); + + memcpy(ZSTR_VAL(res), str1, str1_len); + memcpy(ZSTR_VAL(res) + str1_len, str2, str2_len); + ZSTR_VAL(res)[len] = '\0'; + + return res; +} +#endif + MMC_POOL_INLINE void mmc_buffer_alloc(mmc_buffer_t *buffer, unsigned int size) /* ensures space for an additional size bytes {{{ */ { @@ -734,7 +752,7 @@ static int mmc_server_connect(mmc_pool_t *pool, mmc_t *mmc, mmc_stream_t *io, in /* check connection and extract socket for select() purposes */ if (!io->stream || php_stream_cast(io->stream, PHP_STREAM_AS_FD_FOR_SELECT, (void **)&fd, 1) != SUCCESS) { if (errstr != NULL) { - zend_string* error = zend_string_concat2( + zend_string* error = mmc_string_concat2( "Connection failed: ", sizeof("Connection failed: ") - 1, ZSTR_VAL(errstr), ZSTR_LEN(errstr)); diff --git a/tests/001.phpt b/tests/001.phpt index 582542a..e5e17a7 100644 --- a/tests/001.phpt +++ b/tests/001.phpt @@ -1,7 +1,10 @@ --TEST-- memcache_set() function --SKIPIF-- - += 80000) + die('skip php prior to 8 only'); +include 'connect.inc'; +--FILE-- +plain_attribute = 'value'; +$value->array_attribute = array('test1', 'test2'); +memcache_set($memcache, 'test_key', $value, false, 10); + +$key = 123; +$value = 123; +memcache_set($memcache, $key, $value, false, 10); + +var_dump($key); +var_dump($value); + +try { + memcache_set($memcache, $key); +} catch (ArgumentCountError $e) { + echo "{$e->getMessage()}\n"; +} + +try { + $memcache->set($key); +} catch (ArgumentCountError $e) { + echo "{$e->getMessage()}\n"; +} + +echo "Done\n"; + +?> +--EXPECTF-- +int(123) +int(123) + +Warning: %s parameter%s + +Warning: %s parameter%s +Done \ No newline at end of file diff --git a/tests/019a.phpt b/tests/019a.phpt index 461cc54..1a27a59 100644 --- a/tests/019a.phpt +++ b/tests/019a.phpt @@ -1,7 +1,10 @@ --TEST-- memcache_add_server() --SKIPIF-- - + --FILE-- = 80000) + die('skip php prior to 8 only'); +include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); ?> +--FILE-- +getMessage()}\n"; +} + +try { + var_dump(memcache_add_server($memcache, new stdclass, array())); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} + +echo "Done\n"; + +?> +--EXPECTF-- +bool(true) +bool(true) +Argument 1 passed to memcache_add_server() must be an instance of MemcachePool, instance of stdClass given + +Warning: memcache_add_server() expects parameter 2 to be string, object given in %s on line %d +NULL +Done \ No newline at end of file diff --git a/tests/022a.phpt b/tests/022a.phpt index 31de368..46614bc 100644 --- a/tests/022a.phpt +++ b/tests/022a.phpt @@ -1,7 +1,10 @@ --TEST-- memcache_get_extended_stats() --SKIPIF-- - += 80000) + die('skip php prior to 8 only'); +include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); if (ini_get('memcache.protocol') == 'binary') die('skip binary protocol does not support stats'); +--FILE-- +getMessage()}\n"; +} +try { + var_dump(memcache_get_extended_stats(new stdClass)); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} + +var_dump($result1['pid']); + +var_dump(count($result2)); +var_dump($result2["$host:$port"]['pid']); +var_dump($result2["$host2:$port2"]['pid']); +var_dump($result2["$nonExistingHost:$nonExistingPort"]); + +?> +--EXPECTF-- +Argument 1 passed to memcache_get_extended_stats() must be an instance of MemcachePool, array given +Argument 1 passed to memcache_get_extended_stats() must be an instance of MemcachePool, instance of stdClass given +string(%d) "%d" +int(3) +string(%d) "%d" +string(%d) "%d" +bool(false) \ No newline at end of file diff --git a/tests/024a.phpt b/tests/024a.phpt index 6a464dd..be4d067 100644 --- a/tests/024a.phpt +++ b/tests/024a.phpt @@ -1,7 +1,10 @@ --TEST-- memcache_close(), memcache_get() --SKIPIF-- - + --FILE-- = 80000) + die('skip php prior to 8 only'); +include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); ?> +--FILE-- +connect($host, $port); +$result3 = memcache_set($memcache, 'test_key', 'test', false, 1); +$result4 = memcache_close($memcache); + +// This will fail since all servers have been removed +$result5 = memcache_get($memcache, 'test_key'); + +var_dump($result2); +var_dump($result3); +var_dump($result4); +var_dump($result5); + + +var_dump(memcache_close($memcache)); +var_dump(memcache_close($memcache)); +try { + var_dump(memcache_close(new stdClass)); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} +try { + var_dump(memcache_close("")); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} + +echo "Done\n"; + +?> +--EXPECTF-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +Argument 1 passed to memcache_close() must be an instance of MemcachePool, instance of stdClass given +Argument 1 passed to memcache_close() must be an instance of MemcachePool, string given +Done diff --git a/tests/027a.phpt b/tests/027a.phpt index 50ef564..6543426 100644 --- a/tests/027a.phpt +++ b/tests/027a.phpt @@ -1,7 +1,10 @@ --TEST-- memcache_set_compress_threshold() --SKIPIF-- - + --FILE-- = 80000) + die('skip php prior to 8 only'); +include 'connect.inc'; ?> +--FILE-- +getMessage()}\n"; +} +var_dump(memcache_set_compress_threshold($memcache, -1, -1)); +var_dump(memcache_set_compress_threshold($memcache, 1, -1)); +var_dump(memcache_set_compress_threshold($memcache, -1, 1)); +try { + var_dump(memcache_set_compress_threshold(new stdClass, 1, 1)); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} + +echo "Done\n"; + +?> +--EXPECTF-- +bool(true) +int(15000) +bool(true) +bool(true) +bool(true) +string(3) "abc" +Argument 1 passed to memcache_set_compress_threshold() must be an instance of MemcachePool, array given + +Warning: memcache_set_compress_threshold()%s threshold must be a positive integer in %s on line %d +bool(false) + +Warning: memcache_set_compress_threshold()%s min_savings must be a float in the 0..1 range in %s on line %d +bool(false) + +Warning: memcache_set_compress_threshold()%s threshold must be a positive integer in %s on line %d +bool(false) +Argument 1 passed to memcache_set_compress_threshold() must be an instance of MemcachePool, instance of stdClass given +Done diff --git a/tests/100a.phpt b/tests/100a.phpt index 5cf1d3d..af6e3f9 100644 --- a/tests/100a.phpt +++ b/tests/100a.phpt @@ -1,7 +1,10 @@ --TEST-- memcache_flush() --SKIPIF-- - + --FILE-- = 80000) + die('skip php prior to 8 only'); +include 'connect.inc'; ?> +--FILE-- +addServer($nonExistingHost, $nonExistingPort); + +$result = @memcache_flush($memcache2); +var_dump($result); + +memcache_close($memcache); +var_dump(memcache_flush($memcache)); +try { + var_dump(memcache_flush(new stdClass)); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} +try { + var_dump(memcache_flush('')); +} catch (TypeError $e) { + echo "{$e->getMessage()}\n"; +} + +echo "Done\n"; + +?> +--EXPECTF-- +bool(true) +bool(false) +bool(false) +bool(true) +Argument 1 passed to memcache_flush() must be an instance of MemcachePool, instance of stdClass given +Argument 1 passed to memcache_flush() must be an instance of MemcachePool, string given +Done diff --git a/tests/100b.phpt b/tests/100c.phpt similarity index 100% rename from tests/100b.phpt rename to tests/100c.phpt From 6d9a49d5cf7b4482b983c2af65e2e2d1c70be8d7 Mon Sep 17 00:00:00 2001 From: Zaffy Date: Sat, 3 Oct 2020 23:32:29 +0200 Subject: [PATCH 08/12] Add test for pecl bug #77900 --- tests/pecl77900.phpt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/pecl77900.phpt diff --git a/tests/pecl77900.phpt b/tests/pecl77900.phpt new file mode 100644 index 0000000..8e1b769 --- /dev/null +++ b/tests/pecl77900.phpt @@ -0,0 +1,21 @@ +--TEST-- +PECL Bug #77900 (Memcache session handling, zend_mm_heap corrupted) +--SKIPIF-- + +--FILE-- + + bool(true) +} \ No newline at end of file From edb2e4ad36da9e4b90078231be45c524aa631bf0 Mon Sep 17 00:00:00 2001 From: Zaffy Date: Sun, 4 Oct 2020 02:27:02 +0200 Subject: [PATCH 09/12] Fix some memory leaks --- src/memcache_pool.c | 1 + src/memcache_session.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/memcache_pool.c b/src/memcache_pool.c index 30eb5c4..5f73a18 100644 --- a/src/memcache_pool.c +++ b/src/memcache_pool.c @@ -425,6 +425,7 @@ int mmc_pack_value(mmc_pool_t *pool, mmc_buffer_t *buffer, zval *value, unsigned PHP_VAR_SERIALIZE_DESTROY(value_hash); if (!buf.s) { + zval_dtor(&value_copy); php_error_docref(NULL, E_WARNING, "Failed to serialize value"); return MMC_REQUEST_FAILURE; } diff --git a/src/memcache_session.c b/src/memcache_session.c index 0e027f5..e4a80de 100644 --- a/src/memcache_session.c +++ b/src/memcache_session.c @@ -362,12 +362,12 @@ PS_READ_FUNC(memcache) if (skip_servers.len == pool->num_servers && skip_servers.len < MEMCACHE_G(session_redundancy)) { *val = ZSTR_EMPTY_ALLOC(); mmc_queue_free(&skip_servers); - zval_ptr_dtor(&dataresult); return SUCCESS; - } } else { + zval_dtor(&dataresult); + /* if missing lock, back off and retry same server */ last_index = prev_index; usleep(timeout); From d91338af0c493931cd49460cfc54428850ca0af5 Mon Sep 17 00:00:00 2001 From: Zaffy Date: Sun, 4 Oct 2020 11:39:18 +0200 Subject: [PATCH 10/12] Support for reflection - added / updated arginfos - fix functions returning NULL instead of advertised return type, For example, when memcached returned error on "delete", function returned null instead of false - added tests for both php8 and 7 --- src/memcache.c | 299 +++++++++++------- tests/059.phpt | 815 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/059b.phpt | 789 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1797 insertions(+), 106 deletions(-) create mode 100644 tests/059.phpt create mode 100644 tests/059b.phpt diff --git a/src/memcache.c b/src/memcache.c index 653f959..c1fa9f1 100644 --- a/src/memcache.c +++ b/src/memcache.c @@ -39,123 +39,145 @@ ZEND_EXTERN_MODULE_GLOBALS(memcache) /* {{{ memcache_functions[] */ +#ifndef ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX +#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(name, ref, num, type) \ + ZEND_BEGIN_ARG_INFO_EX(name, 0u, ref, num) +#endif + +#ifndef ZEND_ARG_TYPE_MASK +#define ZEND_ARG_TYPE_MASK(ref, name, mask, def) \ + ZEND_ARG_INFO(ref, name) +#endif + ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_connect, 0, 0, 1) ZEND_ARG_INFO(0, host) ZEND_ARG_INFO(0, port) - ZEND_ARG_INFO(0, udp_port) - ZEND_ARG_INFO(0, persistent) - ZEND_ARG_INFO(0, weight) ZEND_ARG_INFO(0, timeout) - ZEND_ARG_INFO(0, retry_interval) + ZEND_ARG_INFO(0, unused4) + ZEND_ARG_INFO(0, unused5) + ZEND_ARG_INFO(0, unused6) + ZEND_ARG_INFO(0, unused7) + ZEND_ARG_INFO(0, unugsed8) ZEND_END_ARG_INFO() #define arginfo_memcache_pconnect arginfo_memcache_connect -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_add_server, 0, 0, 2) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_add_server, 0, 2, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) ZEND_ARG_INFO(0, host) ZEND_ARG_INFO(0, port) + ZEND_ARG_INFO(0, tcp_port) ZEND_ARG_INFO(0, persistent) ZEND_ARG_INFO(0, weight) ZEND_ARG_INFO(0, timeout) ZEND_ARG_INFO(0, retry_interval) ZEND_ARG_INFO(0, status) ZEND_ARG_INFO(0, failure_callback) - ZEND_ARG_INFO(0, timeoutms) -ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_server_params, 0, 0, 1) - ZEND_ARG_INFO(0, host) - ZEND_ARG_INFO(0, port) - ZEND_ARG_INFO(0, timeout) - ZEND_ARG_INFO(0, retry_interval) - ZEND_ARG_INFO(0, status) - ZEND_ARG_INFO(0, failure_callback) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_failure_callback, 1, 0, 2) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_set_server_params, 0, 2, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) - ZEND_ARG_INFO(0, failure_callback) -ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get_server_status, 0, 0, 1) - ZEND_ARG_INFO(0, host) - ZEND_ARG_INFO(0, port) + ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, tcp_port, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) + ZEND_ARG_TYPE_INFO(0, retry_interval, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, status, _IS_BOOL, 0) + ZEND_ARG_INFO(0, failure_callbac) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get_version, 1, 0, 1) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_set_failure_callback, 0, 2, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) + ZEND_ARG_TYPE_INFO(0, failure_callback, IS_CALLABLE, 1) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_add, 0, 0, 2) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_get_server_status, 0, 2, MAY_BE_BOOL|MAY_BE_LONG) ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, value) - ZEND_ARG_INFO(0, flag) - ZEND_ARG_INFO(0, exptime) + ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, tcp_port, IS_LONG, 0) ZEND_END_ARG_INFO() -#define arginfo_memcache_set arginfo_memcache_add -#define arginfo_memcache_replace arginfo_memcache_add +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_get_version, 0, 1, MAY_BE_STRING|MAY_BE_BOOL) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) +ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_cas, 0, 0, 2) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_add, 0, 2, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) - ZEND_ARG_INFO(0, key) + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0) +#ifdef IS_MIXED + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) +#else ZEND_ARG_INFO(0, value) - ZEND_ARG_INFO(0, flag) - ZEND_ARG_INFO(0, exptime) - ZEND_ARG_INFO(0, cas) +#endif + ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, exptime, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, cas, IS_LONG, 0) ZEND_END_ARG_INFO() +#define arginfo_memcache_set arginfo_memcache_add +#define arginfo_memcache_replace arginfo_memcache_add +#define arginfo_memcache_cas arginfo_memcache_add #define arginfo_memcache_append arginfo_memcache_add #define arginfo_memcache_prepend arginfo_memcache_add -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get, 1, 0, 2) +#ifdef IS_MIXED +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_get, 0, 2, IS_MIXED, 0) +#else +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get, 0, 0, 1) +#endif ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) ZEND_ARG_INFO(0, key) ZEND_ARG_INFO(1, flags) ZEND_ARG_INFO(1, cas) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_delete, 0, 0, 2) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_delete, 0, 2, MAY_BE_BOOL|MAY_BE_ARRAY) ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) ZEND_ARG_INFO(0, key) ZEND_ARG_INFO(0, exptime) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_debug, 0, 0, 1) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_debug, 0, 1, _IS_BOOL, 0) ZEND_ARG_INFO(0, on_off) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get_stats, 0, 0, 1) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_get_stats, 0, 1, MAY_BE_BOOL|MAY_BE_ARRAY) ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) - ZEND_ARG_INFO(0, type) - ZEND_ARG_INFO(0, slabid) - ZEND_ARG_INFO(0, limit) + ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, slabid, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, limit, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_memcache_get_extended_stats arginfo_memcache_get_stats -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_compress_threshold, 0, 0, 2) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_set_compress_threshold, 0, 2, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) - ZEND_ARG_INFO(0, threshold) - ZEND_ARG_INFO(0, min_savings) + ZEND_ARG_TYPE_INFO(0, threshold, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, min_savings, IS_DOUBLE, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_increment, 0, 0, 2) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_increment, 0, 2, MAY_BE_BOOL|MAY_BE_ARRAY|MAY_BE_LONG) ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, value) - ZEND_ARG_INFO(0, defval) - ZEND_ARG_INFO(0, exptime) + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, defval, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, exptime, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_memcache_decrement arginfo_memcache_increment -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_close, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_close, 0, 1, _IS_BOOL, 0) + ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_flush, 0, 0, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_flush, 0, 1, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) - ZEND_ARG_INFO(0, delay) + ZEND_ARG_TYPE_INFO(0, delay, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_sasl_auth_data, 1, 0, 3) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_set_sasl_auth_data, 0, 3, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0) - ZEND_ARG_INFO(0, username) - ZEND_ARG_INFO(0, password) + ZEND_ARG_TYPE_INFO(0, username, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0) ZEND_END_ARG_INFO() zend_function_entry memcache_functions[] = { @@ -186,99 +208,142 @@ zend_function_entry memcache_functions[] = { ZEND_FE_END }; +ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_pool_object_connect, 0, 0, 1) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, tcp_port) + ZEND_ARG_INFO(0, udp_port) + ZEND_ARG_INFO(0, persistent) + ZEND_ARG_INFO(0, weight) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retry_interval) +ZEND_END_ARG_INFO() + #define arginfo_memcache_object_connect arginfo_memcache_connect +#define arginfo_memcache_object_pconnect arginfo_memcache_connect -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_addserver, 0, 0, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_pool_object_addserver, 0, 1, _IS_BOOL, 0) ZEND_ARG_INFO(0, host) - ZEND_ARG_INFO(0, port) + ZEND_ARG_INFO(0, tcp_port) + ZEND_ARG_INFO(0, udp_port) ZEND_ARG_INFO(0, persistent) ZEND_ARG_INFO(0, weight) ZEND_ARG_INFO(0, timeout) ZEND_ARG_INFO(0, retry_interval) ZEND_ARG_INFO(0, status) - ZEND_ARG_INFO(0, failure_callback) - ZEND_ARG_INFO(0, timeoutms) ZEND_END_ARG_INFO() -#define arginfo_memcache_object_setserverparams arginfo_memcache_set_server_params - -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_setfailurecallback, 0, 0, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_addserver, 0, 1, _IS_BOOL, 0) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, tcp_port) + ZEND_ARG_INFO(0, persistent) + ZEND_ARG_INFO(0, weight) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, retry_interval) + ZEND_ARG_INFO(0, status) ZEND_ARG_INFO(0, failure_callback) ZEND_END_ARG_INFO() -#define arginfo_memcache_object_getserverstatus arginfo_memcache_get_server_status +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_setserverparams, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, tcp_port, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) + ZEND_ARG_TYPE_INFO(0, retry_interval, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, status, _IS_BOOL, 0) + ZEND_ARG_INFO(0, failure_callbac) +ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_findserver, 0, 0, 1) - ZEND_ARG_INFO(0, key) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_setfailurecallback, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, failure_callback, IS_CALLABLE, 1) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_getversion, 0, 0, 0) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_getserverstatus, 0, 1, MAY_BE_BOOL|MAY_BE_LONG) + ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, tcp_port, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_add, 0, 0, 1) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, value) - ZEND_ARG_INFO(0, flag) - ZEND_ARG_INFO(0, exptime) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_findserver, 0, 1, MAY_BE_STRING|MAY_BE_BOOL) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_memcache_object_set arginfo_memcache_object_add -#define arginfo_memcache_object_replace arginfo_memcache_object_add +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_getversion, 0, 0, MAY_BE_STRING|MAY_BE_BOOL) +ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_cas, 0, 0, 1) - ZEND_ARG_INFO(0, key) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_add, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0) +#ifdef IS_MIXED + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) +#else ZEND_ARG_INFO(0, value) - ZEND_ARG_INFO(0, flag) - ZEND_ARG_INFO(0, exptime) - ZEND_ARG_INFO(0, cas) +#endif + ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, exptime, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, cas, IS_LONG, 0) ZEND_END_ARG_INFO() +#define arginfo_memcache_object_set arginfo_memcache_object_add +#define arginfo_memcache_object_replace arginfo_memcache_object_add +#define arginfo_memcache_object_set arginfo_memcache_object_add +#define arginfo_memcache_object_cas arginfo_memcache_object_add #define arginfo_memcache_object_append arginfo_memcache_object_add #define arginfo_memcache_object_prepend arginfo_memcache_object_add +#ifdef IS_MIXED +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_get, 0, 1, IS_MIXED, 0) +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_get, 0, 0, 1) - ZEND_ARG_INFO(0, key) +#endif + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0) +#ifdef IS_MIXED + ZEND_ARG_TYPE_INFO(1, flags, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(1, cas, IS_MIXED, 0) +#else ZEND_ARG_INFO(1, flags) ZEND_ARG_INFO(1, cas) +#endif ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_delete, 0, 0, 1) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, exptime) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_delete, 0, 1, MAY_BE_BOOL|MAY_BE_ARRAY) + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, exptime, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_getstats, 0, 0, 0) - ZEND_ARG_INFO(0, type) - ZEND_ARG_INFO(0, slabid) - ZEND_ARG_INFO(0, limit) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_getstats, 0, 0, MAY_BE_BOOL|MAY_BE_ARRAY) + ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, slabid, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, limit, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_memcache_object_getextendedstats arginfo_memcache_object_getstats -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_setcompressthreshold, 0, 0, 1) - ZEND_ARG_INFO(0, threshold) - ZEND_ARG_INFO(0, min_savings) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_setcompressthreshold, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, threshold, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, min_savings, IS_DOUBLE, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_increment, 0, 0, 1) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, value) - ZEND_ARG_INFO(0, defval) - ZEND_ARG_INFO(0, exptime) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_increment, 0, 1, MAY_BE_BOOL|MAY_BE_ARRAY|MAY_BE_LONG) + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, defval, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, exptime, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_memcache_object_decrement arginfo_memcache_object_increment -ZEND_BEGIN_ARG_INFO(arginfo_memcache_object_close, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_close, 0, 0, _IS_BOOL, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_flush, 0, 0, 0) - ZEND_ARG_INFO(0, delay) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_flush, 0, 0, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, delay, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_setSaslAuthData, 0, 0, 2) - ZEND_ARG_INFO(0, username) - ZEND_ARG_INFO(0, password) + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_setSaslAuthData, 0, 2, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, username, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0) ZEND_END_ARG_INFO() static zend_function_entry php_memcache_pool_class_functions[] = { - PHP_NAMED_FE(connect, zif_memcache_pool_connect, arginfo_memcache_object_connect) - PHP_NAMED_FE(addserver, zif_memcache_pool_addserver, arginfo_memcache_object_addserver) + PHP_NAMED_FE(connect, zif_memcache_pool_connect, arginfo_memcache_pool_object_connect) + PHP_NAMED_FE(addserver, zif_memcache_pool_addserver, arginfo_memcache_pool_object_addserver) PHP_FALIAS(setserverparams, memcache_set_server_params, arginfo_memcache_object_setserverparams) PHP_FALIAS(setfailurecallback, memcache_set_failure_callback, arginfo_memcache_object_setfailurecallback) PHP_FALIAS(getserverstatus, memcache_get_server_status, arginfo_memcache_object_getserverstatus) @@ -304,8 +369,8 @@ static zend_function_entry php_memcache_pool_class_functions[] = { }; static zend_function_entry php_memcache_class_functions[] = { - PHP_ME_MAPPING(connect, memcache_connect, arginfo_memcache_connect, ZEND_ACC_PUBLIC) - PHP_ME_MAPPING(pconnect, memcache_pconnect, arginfo_memcache_pconnect, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(connect, memcache_connect, arginfo_memcache_object_connect, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(pconnect, memcache_pconnect, arginfo_memcache_object_pconnect, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(addserver, memcache_add_server, arginfo_memcache_object_addserver, ZEND_ACC_PUBLIC) ZEND_FE_END }; @@ -1063,6 +1128,10 @@ static void php_mmc_numeric(INTERNAL_FUNCTION_PARAMETERS, int deleted, int inver /* execute all requests */ mmc_pool_run(pool); + + if (Z_TYPE_P(return_value) == IS_NULL) { + RETURN_FALSE; + } } /* }}} */ @@ -1893,6 +1962,10 @@ PHP_FUNCTION(memcache_get_version) } } } + + if (Z_TYPE_P(return_value) == IS_NULL) { + RETURN_FALSE; + } } /* }}} */ @@ -2085,19 +2158,23 @@ PHP_FUNCTION(memcache_get) if (mmc_prepare_key(keys, request->key, &(request->key_len)) != MMC_OK) { mmc_pool_release(pool, request); php_error_docref(NULL, E_WARNING, "Invalid key"); - return; + RETURN_FALSE; } pool->protocol->get(request, cas != NULL ? MMC_OP_GETS : MMC_OP_GET, keys, request->key, request->key_len); /* schedule request */ if (mmc_pool_schedule_key(pool, request->key, request->key_len, request, 1) != MMC_OK) { - return; + RETURN_FALSE; } } /* execute all requests */ mmc_pool_run(pool); + + if (Z_TYPE_P(return_value) == IS_NULL) { + RETURN_FALSE; + } } /* }}} */ @@ -2204,6 +2281,10 @@ PHP_FUNCTION(memcache_get_stats) /* execute all requests */ mmc_pool_run(pool); + + if (Z_TYPE_P(return_value) == IS_NULL) { + RETURN_FALSE; + } } /* }}} */ @@ -2261,6 +2342,10 @@ PHP_FUNCTION(memcache_get_extended_stats) /* execute all requests */ mmc_pool_run(pool); + + if (Z_TYPE_P(return_value) == IS_NULL) { + RETURN_FALSE; + } } /* }}} */ @@ -2461,6 +2546,8 @@ PHP_FUNCTION(memcache_set_sasl_auth_data) PHP_FUNCTION(memcache_debug) { php_error_docref(NULL, E_WARNING, "memcache_debug() is deprecated, please use a debugger (like Eclipse + CDT)"); + + RETVAL_BOOL(PHP_DEBUG); } /* }}} */ diff --git a/tests/059.phpt b/tests/059.phpt new file mode 100644 index 0000000..4140880 --- /dev/null +++ b/tests/059.phpt @@ -0,0 +1,815 @@ +--TEST-- +Reflection +--SKIPIF-- + class MemcachePool ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [23] { + Method [ public method connect ] { + + - Parameters [7] { + Parameter #0 [ $host ] + Parameter #1 [ $tcp_port = ] + Parameter #2 [ $udp_port = ] + Parameter #3 [ $persistent = ] + Parameter #4 [ $weight = ] + Parameter #5 [ $timeout = ] + Parameter #6 [ $retry_interval = ] + } + } + + Method [ public method addserver ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $tcp_port = ] + Parameter #2 [ $udp_port = ] + Parameter #3 [ $persistent = ] + Parameter #4 [ $weight = ] + Parameter #5 [ $timeout = ] + Parameter #6 [ $retry_interval = ] + Parameter #7 [ $status = ] + } + - Return [ bool ] + } + + Method [ public method setserverparams ] { + + - Parameters [6] { + Parameter #0 [ string $host ] + Parameter #1 [ int $tcp_port = ] + Parameter #2 [ float $timeout = ] + Parameter #3 [ int $retry_interval = ] + Parameter #4 [ bool $status = ] + Parameter #5 [ $failure_callbac = ] + } + - Return [ bool ] + } + + Method [ public method setfailurecallback ] { + + - Parameters [1] { + Parameter #0 [ ?callable $failure_callback ] + } + - Return [ bool ] + } + + Method [ public method getserverstatus ] { + + - Parameters [2] { + Parameter #0 [ string $host ] + Parameter #1 [ int $tcp_port = ] + } + - Return [ int|bool ] + } + + Method [ public method findserver ] { + + - Parameters [1] { + Parameter #0 [ string $key ] + } + - Return [ string|bool ] + } + + Method [ public method getversion ] { + + - Parameters [0] { + } + - Return [ string|bool ] + } + + Method [ public method add ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method set ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method replace ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method cas ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method append ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method prepend ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method get ] { + + - Parameters [3] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed &$flags = ] + Parameter #2 [ mixed &$cas = ] + } + - Return [ mixed ] + } + + Method [ public method delete ] { + + - Parameters [2] { + Parameter #0 [ array|string $key ] + Parameter #1 [ int $exptime = ] + } + - Return [ array|bool ] + } + + Method [ public method getstats ] { + + - Parameters [3] { + Parameter #0 [ string $type = ] + Parameter #1 [ int $slabid = ] + Parameter #2 [ int $limit = ] + } + - Return [ array|bool ] + } + + Method [ public method getextendedstats ] { + + - Parameters [3] { + Parameter #0 [ string $type = ] + Parameter #1 [ int $slabid = ] + Parameter #2 [ int $limit = ] + } + - Return [ array|bool ] + } + + Method [ public method setcompressthreshold ] { + + - Parameters [2] { + Parameter #0 [ int $threshold ] + Parameter #1 [ float $min_savings = ] + } + - Return [ bool ] + } + + Method [ public method increment ] { + + - Parameters [4] { + Parameter #0 [ array|string $key ] + Parameter #1 [ int $value = ] + Parameter #2 [ int $defval = ] + Parameter #3 [ int $exptime = ] + } + - Return [ array|int|bool ] + } + + Method [ public method decrement ] { + + - Parameters [4] { + Parameter #0 [ array|string $key ] + Parameter #1 [ int $value = ] + Parameter #2 [ int $defval = ] + Parameter #3 [ int $exptime = ] + } + - Return [ array|int|bool ] + } + + Method [ public method close ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method flush ] { + + - Parameters [1] { + Parameter #0 [ int $delay = ] + } + - Return [ bool ] + } + + Method [ public method setSaslAuthData ] { + + - Parameters [2] { + Parameter #0 [ string $username ] + Parameter #1 [ string $password ] + } + - Return [ bool ] + } + } +} +Class [ class Memcache extends MemcachePool ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [24] { + Method [ public method connect ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $port = ] + Parameter #2 [ $timeout = ] + Parameter #3 [ $unused4 = ] + Parameter #4 [ $unused5 = ] + Parameter #5 [ $unused6 = ] + Parameter #6 [ $unused7 = ] + Parameter #7 [ $unugsed8 = ] + } + } + + Method [ public method pconnect ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $port = ] + Parameter #2 [ $timeout = ] + Parameter #3 [ $unused4 = ] + Parameter #4 [ $unused5 = ] + Parameter #5 [ $unused6 = ] + Parameter #6 [ $unused7 = ] + Parameter #7 [ $unugsed8 = ] + } + } + + Method [ public method addserver ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $tcp_port = ] + Parameter #2 [ $persistent = ] + Parameter #3 [ $weight = ] + Parameter #4 [ $timeout = ] + Parameter #5 [ $retry_interval = ] + Parameter #6 [ $status = ] + Parameter #7 [ $failure_callback = ] + } + - Return [ bool ] + } + + Method [ public method setserverparams ] { + + - Parameters [6] { + Parameter #0 [ string $host ] + Parameter #1 [ int $tcp_port = ] + Parameter #2 [ float $timeout = ] + Parameter #3 [ int $retry_interval = ] + Parameter #4 [ bool $status = ] + Parameter #5 [ $failure_callbac = ] + } + - Return [ bool ] + } + + Method [ public method setfailurecallback ] { + + - Parameters [1] { + Parameter #0 [ ?callable $failure_callback ] + } + - Return [ bool ] + } + + Method [ public method getserverstatus ] { + + - Parameters [2] { + Parameter #0 [ string $host ] + Parameter #1 [ int $tcp_port = ] + } + - Return [ int|bool ] + } + + Method [ public method findserver ] { + + - Parameters [1] { + Parameter #0 [ string $key ] + } + - Return [ string|bool ] + } + + Method [ public method getversion ] { + + - Parameters [0] { + } + - Return [ string|bool ] + } + + Method [ public method add ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method set ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method replace ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method cas ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method append ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method prepend ] { + + - Parameters [5] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed $value = ] + Parameter #2 [ int $flags = ] + Parameter #3 [ int $exptime = ] + Parameter #4 [ int $cas = ] + } + - Return [ bool ] + } + + Method [ public method get ] { + + - Parameters [3] { + Parameter #0 [ array|string $key ] + Parameter #1 [ mixed &$flags = ] + Parameter #2 [ mixed &$cas = ] + } + - Return [ mixed ] + } + + Method [ public method delete ] { + + - Parameters [2] { + Parameter #0 [ array|string $key ] + Parameter #1 [ int $exptime = ] + } + - Return [ array|bool ] + } + + Method [ public method getstats ] { + + - Parameters [3] { + Parameter #0 [ string $type = ] + Parameter #1 [ int $slabid = ] + Parameter #2 [ int $limit = ] + } + - Return [ array|bool ] + } + + Method [ public method getextendedstats ] { + + - Parameters [3] { + Parameter #0 [ string $type = ] + Parameter #1 [ int $slabid = ] + Parameter #2 [ int $limit = ] + } + - Return [ array|bool ] + } + + Method [ public method setcompressthreshold ] { + + - Parameters [2] { + Parameter #0 [ int $threshold ] + Parameter #1 [ float $min_savings = ] + } + - Return [ bool ] + } + + Method [ public method increment ] { + + - Parameters [4] { + Parameter #0 [ array|string $key ] + Parameter #1 [ int $value = ] + Parameter #2 [ int $defval = ] + Parameter #3 [ int $exptime = ] + } + - Return [ array|int|bool ] + } + + Method [ public method decrement ] { + + - Parameters [4] { + Parameter #0 [ array|string $key ] + Parameter #1 [ int $value = ] + Parameter #2 [ int $defval = ] + Parameter #3 [ int $exptime = ] + } + - Return [ array|int|bool ] + } + + Method [ public method close ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method flush ] { + + - Parameters [1] { + Parameter #0 [ int $delay = ] + } + - Return [ bool ] + } + + Method [ public method setSaslAuthData ] { + + - Parameters [2] { + Parameter #0 [ string $username ] + Parameter #1 [ string $password ] + } + - Return [ bool ] + } + } +} +Function [ function memcache_connect ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $port = ] + Parameter #2 [ $timeout = ] + Parameter #3 [ $unused4 = ] + Parameter #4 [ $unused5 = ] + Parameter #5 [ $unused6 = ] + Parameter #6 [ $unused7 = ] + Parameter #7 [ $unugsed8 = ] + } +} +Function [ function memcache_pconnect ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $port = ] + Parameter #2 [ $timeout = ] + Parameter #3 [ $unused4 = ] + Parameter #4 [ $unused5 = ] + Parameter #5 [ $unused6 = ] + Parameter #6 [ $unused7 = ] + Parameter #7 [ $unugsed8 = ] + } +} +Function [ function memcache_add_server ] { + + - Parameters [10] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $host ] + Parameter #2 [ $port = ] + Parameter #3 [ $tcp_port = ] + Parameter #4 [ $persistent = ] + Parameter #5 [ $weight = ] + Parameter #6 [ $timeout = ] + Parameter #7 [ $retry_interval = ] + Parameter #8 [ $status = ] + Parameter #9 [ $failure_callback = ] + } + - Return [ bool ] +} +Function [ function memcache_set_server_params ] { + + - Parameters [7] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ string $host ] + Parameter #2 [ int $tcp_port = ] + Parameter #3 [ float $timeout = ] + Parameter #4 [ int $retry_interval = ] + Parameter #5 [ bool $status = ] + Parameter #6 [ $failure_callbac = ] + } + - Return [ bool ] +} +Function [ function memcache_set_failure_callback ] { + + - Parameters [2] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ ?callable $failure_callback ] + } + - Return [ bool ] +} +Function [ function memcache_get_server_status ] { + + - Parameters [3] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ string $host ] + Parameter #2 [ int $tcp_port = ] + } + - Return [ int|bool ] +} +Function [ function memcache_get_version ] { + + - Parameters [1] { + Parameter #0 [ MemcachePool $memcache ] + } + - Return [ string|bool ] +} +Function [ function memcache_add ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ array|string $key ] + Parameter #2 [ mixed $value = ] + Parameter #3 [ int $flags = ] + Parameter #4 [ int $exptime = ] + Parameter #5 [ int $cas = ] + } + - Return [ bool ] +} +Function [ function memcache_set ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ array|string $key ] + Parameter #2 [ mixed $value = ] + Parameter #3 [ int $flags = ] + Parameter #4 [ int $exptime = ] + Parameter #5 [ int $cas = ] + } + - Return [ bool ] +} +Function [ function memcache_replace ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ array|string $key ] + Parameter #2 [ mixed $value = ] + Parameter #3 [ int $flags = ] + Parameter #4 [ int $exptime = ] + Parameter #5 [ int $cas = ] + } + - Return [ bool ] +} +Function [ function memcache_cas ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ array|string $key ] + Parameter #2 [ mixed $value = ] + Parameter #3 [ int $flags = ] + Parameter #4 [ int $exptime = ] + Parameter #5 [ int $cas = ] + } + - Return [ bool ] +} +Function [ function memcache_append ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ array|string $key ] + Parameter #2 [ mixed $value = ] + Parameter #3 [ int $flags = ] + Parameter #4 [ int $exptime = ] + Parameter #5 [ int $cas = ] + } + - Return [ bool ] +} +Function [ function memcache_prepend ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ array|string $key ] + Parameter #2 [ mixed $value = ] + Parameter #3 [ int $flags = ] + Parameter #4 [ int $exptime = ] + Parameter #5 [ int $cas = ] + } + - Return [ bool ] +} +Function [ function memcache_get ] { + + - Parameters [4] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ &$flags = ] + Parameter #3 [ &$cas = ] + } + - Return [ mixed ] +} +Function [ function memcache_delete ] { + + - Parameters [3] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ $exptime = ] + } + - Return [ array|bool ] +} +Function [ function memcache_debug ] { + + - Parameters [1] { + Parameter #0 [ $on_off ] + } + - Return [ bool ] +} +Function [ function memcache_get_stats ] { + + - Parameters [4] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ string $type = ] + Parameter #2 [ int $slabid = ] + Parameter #3 [ int $limit = ] + } + - Return [ array|bool ] +} +Function [ function memcache_get_extended_stats ] { + + - Parameters [4] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ string $type = ] + Parameter #2 [ int $slabid = ] + Parameter #3 [ int $limit = ] + } + - Return [ array|bool ] +} +Function [ function memcache_set_compress_threshold ] { + + - Parameters [3] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ int $threshold ] + Parameter #2 [ float $min_savings = ] + } + - Return [ bool ] +} +Function [ function memcache_increment ] { + + - Parameters [5] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ array|string $key ] + Parameter #2 [ int $value = ] + Parameter #3 [ int $defval = ] + Parameter #4 [ int $exptime = ] + } + - Return [ array|int|bool ] +} +Function [ function memcache_decrement ] { + + - Parameters [5] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ array|string $key ] + Parameter #2 [ int $value = ] + Parameter #3 [ int $defval = ] + Parameter #4 [ int $exptime = ] + } + - Return [ array|int|bool ] +} +Function [ function memcache_close ] { + + - Parameters [1] { + Parameter #0 [ MemcachePool $memcache ] + } + - Return [ bool ] +} +Function [ function memcache_flush ] { + + - Parameters [2] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ int $delay = ] + } + - Return [ bool ] +} +Function [ function memcache_set_sasl_auth_data ] { + + - Parameters [3] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ string $username ] + Parameter #2 [ string $password ] + } + - Return [ bool ] +} \ No newline at end of file diff --git a/tests/059b.phpt b/tests/059b.phpt new file mode 100644 index 0000000..ce3dfe9 --- /dev/null +++ b/tests/059b.phpt @@ -0,0 +1,789 @@ +--TEST-- +Reflection +--SKIPIF-- += 80000) + die('skip php prior to 8 only'); +--FILE-- + class MemcachePool ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [23] { + Method [ public method connect ] { + + - Parameters [7] { + Parameter #0 [ $host ] + Parameter #1 [ $tcp_port ] + Parameter #2 [ $udp_port ] + Parameter #3 [ $persistent ] + Parameter #4 [ $weight ] + Parameter #5 [ $timeout ] + Parameter #6 [ $retry_interval ] + } + } + + Method [ public method addserver ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $tcp_port ] + Parameter #2 [ $udp_port ] + Parameter #3 [ $persistent ] + Parameter #4 [ $weight ] + Parameter #5 [ $timeout ] + Parameter #6 [ $retry_interval ] + Parameter #7 [ $status ] + } + - Return [ bool ] + } + + Method [ public method setserverparams ] { + + - Parameters [6] { + Parameter #0 [ string $host ] + Parameter #1 [ int $tcp_port ] + Parameter #2 [ float $timeout ] + Parameter #3 [ int $retry_interval ] + Parameter #4 [ bool $status ] + Parameter #5 [ $failure_callbac ] + } + - Return [ bool ] + } + + Method [ public method setfailurecallback ] { + + - Parameters [1] { + Parameter #0 [ callable or NULL $failure_callback ] + } + - Return [ bool ] + } + + Method [ public method getserverstatus ] { + + - Parameters [2] { + Parameter #0 [ string $host ] + Parameter #1 [ int $tcp_port ] + } + } + + Method [ public method findserver ] { + + - Parameters [1] { + Parameter #0 [ string $key ] + } + } + + Method [ public method getversion ] { + + - Parameters [0] { + } + } + + Method [ public method add ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method set ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method replace ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method cas ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method append ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method prepend ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method get ] { + + - Parameters [3] { + Parameter #0 [ $key ] + Parameter #1 [ &$flags ] + Parameter #2 [ &$cas ] + } + } + + Method [ public method delete ] { + + - Parameters [2] { + Parameter #0 [ $key ] + Parameter #1 [ int $exptime ] + } + } + + Method [ public method getstats ] { + + - Parameters [3] { + Parameter #0 [ string $type ] + Parameter #1 [ int $slabid ] + Parameter #2 [ int $limit ] + } + } + + Method [ public method getextendedstats ] { + + - Parameters [3] { + Parameter #0 [ string $type ] + Parameter #1 [ int $slabid ] + Parameter #2 [ int $limit ] + } + } + + Method [ public method setcompressthreshold ] { + + - Parameters [2] { + Parameter #0 [ int $threshold ] + Parameter #1 [ float $min_savings ] + } + - Return [ bool ] + } + + Method [ public method increment ] { + + - Parameters [4] { + Parameter #0 [ $key ] + Parameter #1 [ int $value ] + Parameter #2 [ int $defval ] + Parameter #3 [ int $exptime ] + } + } + + Method [ public method decrement ] { + + - Parameters [4] { + Parameter #0 [ $key ] + Parameter #1 [ int $value ] + Parameter #2 [ int $defval ] + Parameter #3 [ int $exptime ] + } + } + + Method [ public method close ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method flush ] { + + - Parameters [1] { + Parameter #0 [ int $delay ] + } + - Return [ bool ] + } + + Method [ public method setSaslAuthData ] { + + - Parameters [2] { + Parameter #0 [ string $username ] + Parameter #1 [ string $password ] + } + - Return [ bool ] + } + } +} +Class [ class Memcache extends MemcachePool ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [24] { + Method [ public method connect ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $port ] + Parameter #2 [ $timeout ] + Parameter #3 [ $unused4 ] + Parameter #4 [ $unused5 ] + Parameter #5 [ $unused6 ] + Parameter #6 [ $unused7 ] + Parameter #7 [ $unugsed8 ] + } + } + + Method [ public method pconnect ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $port ] + Parameter #2 [ $timeout ] + Parameter #3 [ $unused4 ] + Parameter #4 [ $unused5 ] + Parameter #5 [ $unused6 ] + Parameter #6 [ $unused7 ] + Parameter #7 [ $unugsed8 ] + } + } + + Method [ public method addserver ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $tcp_port ] + Parameter #2 [ $persistent ] + Parameter #3 [ $weight ] + Parameter #4 [ $timeout ] + Parameter #5 [ $retry_interval ] + Parameter #6 [ $status ] + Parameter #7 [ $failure_callback ] + } + - Return [ bool ] + } + + Method [ public method setserverparams ] { + + - Parameters [6] { + Parameter #0 [ string $host ] + Parameter #1 [ int $tcp_port ] + Parameter #2 [ float $timeout ] + Parameter #3 [ int $retry_interval ] + Parameter #4 [ bool $status ] + Parameter #5 [ $failure_callbac ] + } + - Return [ bool ] + } + + Method [ public method setfailurecallback ] { + + - Parameters [1] { + Parameter #0 [ callable or NULL $failure_callback ] + } + - Return [ bool ] + } + + Method [ public method getserverstatus ] { + + - Parameters [2] { + Parameter #0 [ string $host ] + Parameter #1 [ int $tcp_port ] + } + } + + Method [ public method findserver ] { + + - Parameters [1] { + Parameter #0 [ string $key ] + } + } + + Method [ public method getversion ] { + + - Parameters [0] { + } + } + + Method [ public method add ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method set ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method replace ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method cas ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method append ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method prepend ] { + + - Parameters [5] { + Parameter #0 [ $key ] + Parameter #1 [ $value ] + Parameter #2 [ int $flags ] + Parameter #3 [ int $exptime ] + Parameter #4 [ int $cas ] + } + - Return [ bool ] + } + + Method [ public method get ] { + + - Parameters [3] { + Parameter #0 [ $key ] + Parameter #1 [ &$flags ] + Parameter #2 [ &$cas ] + } + } + + Method [ public method delete ] { + + - Parameters [2] { + Parameter #0 [ $key ] + Parameter #1 [ int $exptime ] + } + } + + Method [ public method getstats ] { + + - Parameters [3] { + Parameter #0 [ string $type ] + Parameter #1 [ int $slabid ] + Parameter #2 [ int $limit ] + } + } + + Method [ public method getextendedstats ] { + + - Parameters [3] { + Parameter #0 [ string $type ] + Parameter #1 [ int $slabid ] + Parameter #2 [ int $limit ] + } + } + + Method [ public method setcompressthreshold ] { + + - Parameters [2] { + Parameter #0 [ int $threshold ] + Parameter #1 [ float $min_savings ] + } + - Return [ bool ] + } + + Method [ public method increment ] { + + - Parameters [4] { + Parameter #0 [ $key ] + Parameter #1 [ int $value ] + Parameter #2 [ int $defval ] + Parameter #3 [ int $exptime ] + } + } + + Method [ public method decrement ] { + + - Parameters [4] { + Parameter #0 [ $key ] + Parameter #1 [ int $value ] + Parameter #2 [ int $defval ] + Parameter #3 [ int $exptime ] + } + } + + Method [ public method close ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method flush ] { + + - Parameters [1] { + Parameter #0 [ int $delay ] + } + - Return [ bool ] + } + + Method [ public method setSaslAuthData ] { + + - Parameters [2] { + Parameter #0 [ string $username ] + Parameter #1 [ string $password ] + } + - Return [ bool ] + } + } +} +Function [ function memcache_connect ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $port ] + Parameter #2 [ $timeout ] + Parameter #3 [ $unused4 ] + Parameter #4 [ $unused5 ] + Parameter #5 [ $unused6 ] + Parameter #6 [ $unused7 ] + Parameter #7 [ $unugsed8 ] + } +} +Function [ function memcache_pconnect ] { + + - Parameters [8] { + Parameter #0 [ $host ] + Parameter #1 [ $port ] + Parameter #2 [ $timeout ] + Parameter #3 [ $unused4 ] + Parameter #4 [ $unused5 ] + Parameter #5 [ $unused6 ] + Parameter #6 [ $unused7 ] + Parameter #7 [ $unugsed8 ] + } +} +Function [ function memcache_add_server ] { + + - Parameters [10] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $host ] + Parameter #2 [ $port ] + Parameter #3 [ $tcp_port ] + Parameter #4 [ $persistent ] + Parameter #5 [ $weight ] + Parameter #6 [ $timeout ] + Parameter #7 [ $retry_interval ] + Parameter #8 [ $status ] + Parameter #9 [ $failure_callback ] + } + - Return [ bool ] +} +Function [ function memcache_set_server_params ] { + + - Parameters [7] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ string $host ] + Parameter #2 [ int $tcp_port ] + Parameter #3 [ float $timeout ] + Parameter #4 [ int $retry_interval ] + Parameter #5 [ bool $status ] + Parameter #6 [ $failure_callbac ] + } + - Return [ bool ] +} +Function [ function memcache_set_failure_callback ] { + + - Parameters [2] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ callable or NULL $failure_callback ] + } + - Return [ bool ] +} +Function [ function memcache_get_server_status ] { + + - Parameters [3] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ string $host ] + Parameter #2 [ int $tcp_port ] + } +} +Function [ function memcache_get_version ] { + + - Parameters [1] { + Parameter #0 [ MemcachePool $memcache ] + } +} +Function [ function memcache_add ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ $value ] + Parameter #3 [ int $flags ] + Parameter #4 [ int $exptime ] + Parameter #5 [ int $cas ] + } + - Return [ bool ] +} +Function [ function memcache_set ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ $value ] + Parameter #3 [ int $flags ] + Parameter #4 [ int $exptime ] + Parameter #5 [ int $cas ] + } + - Return [ bool ] +} +Function [ function memcache_replace ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ $value ] + Parameter #3 [ int $flags ] + Parameter #4 [ int $exptime ] + Parameter #5 [ int $cas ] + } + - Return [ bool ] +} +Function [ function memcache_cas ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ $value ] + Parameter #3 [ int $flags ] + Parameter #4 [ int $exptime ] + Parameter #5 [ int $cas ] + } + - Return [ bool ] +} +Function [ function memcache_append ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ $value ] + Parameter #3 [ int $flags ] + Parameter #4 [ int $exptime ] + Parameter #5 [ int $cas ] + } + - Return [ bool ] +} +Function [ function memcache_prepend ] { + + - Parameters [6] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ $value ] + Parameter #3 [ int $flags ] + Parameter #4 [ int $exptime ] + Parameter #5 [ int $cas ] + } + - Return [ bool ] +} +Function [ function memcache_get ] { + + - Parameters [4] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ &$flags ] + Parameter #3 [ &$cas ] + } +} +Function [ function memcache_delete ] { + + - Parameters [3] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ $exptime ] + } +} +Function [ function memcache_debug ] { + + - Parameters [1] { + Parameter #0 [ $on_off ] + } + - Return [ bool ] +} +Function [ function memcache_get_stats ] { + + - Parameters [4] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ string $type ] + Parameter #2 [ int $slabid ] + Parameter #3 [ int $limit ] + } +} +Function [ function memcache_get_extended_stats ] { + + - Parameters [4] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ string $type ] + Parameter #2 [ int $slabid ] + Parameter #3 [ int $limit ] + } +} +Function [ function memcache_set_compress_threshold ] { + + - Parameters [3] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ int $threshold ] + Parameter #2 [ float $min_savings ] + } + - Return [ bool ] +} +Function [ function memcache_increment ] { + + - Parameters [5] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ int $value ] + Parameter #3 [ int $defval ] + Parameter #4 [ int $exptime ] + } +} +Function [ function memcache_decrement ] { + + - Parameters [5] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ $key ] + Parameter #2 [ int $value ] + Parameter #3 [ int $defval ] + Parameter #4 [ int $exptime ] + } +} +Function [ function memcache_close ] { + + - Parameters [1] { + Parameter #0 [ MemcachePool $memcache ] + } + - Return [ bool ] +} +Function [ function memcache_flush ] { + + - Parameters [2] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ int $delay ] + } + - Return [ bool ] +} +Function [ function memcache_set_sasl_auth_data ] { + + - Parameters [3] { + Parameter #0 [ MemcachePool $memcache ] + Parameter #1 [ string $username ] + Parameter #2 [ string $password ] + } + - Return [ bool ] +} \ No newline at end of file From 4dd4b80ef2f6ee5bf3dbb7edd5aa1e310ef41e2b Mon Sep 17 00:00:00 2001 From: Zaffy Date: Thu, 8 Oct 2020 15:06:16 +0200 Subject: [PATCH 11/12] Fix typo --- src/memcache.c | 4 ++-- tests/059.phpt | 6 +++--- tests/059b.phpt | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/memcache.c b/src/memcache.c index c1fa9f1..f994c1b 100644 --- a/src/memcache.c +++ b/src/memcache.c @@ -82,7 +82,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_set_server_params, 0, 2 ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) ZEND_ARG_TYPE_INFO(0, retry_interval, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, status, _IS_BOOL, 0) - ZEND_ARG_INFO(0, failure_callbac) + ZEND_ARG_INFO(0, failure_callback) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_set_failure_callback, 0, 2, _IS_BOOL, 0) @@ -249,7 +249,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_setserverparams, ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) ZEND_ARG_TYPE_INFO(0, retry_interval, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, status, _IS_BOOL, 0) - ZEND_ARG_INFO(0, failure_callbac) + ZEND_ARG_INFO(0, failure_callback) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_setfailurecallback, 0, 1, _IS_BOOL, 0) diff --git a/tests/059.phpt b/tests/059.phpt index 4140880..c7c3d21 100644 --- a/tests/059.phpt +++ b/tests/059.phpt @@ -87,7 +87,7 @@ Class [ class MemcachePool ] { Parameter #2 [ float $timeout = ] Parameter #3 [ int $retry_interval = ] Parameter #4 [ bool $status = ] - Parameter #5 [ $failure_callbac = ] + Parameter #5 [ $failure_callback = ] } - Return [ bool ] } @@ -357,7 +357,7 @@ Class [ class Memcache extends MemcachePool ] { Parameter #2 [ float $timeout = ] Parameter #3 [ int $retry_interval = ] Parameter #4 [ bool $status = ] - Parameter #5 [ $failure_callbac = ] + Parameter #5 [ $failure_callback = ] } - Return [ bool ] } @@ -612,7 +612,7 @@ Function [ function memcache_set_server_params ] { Parameter #3 [ float $timeout = ] Parameter #4 [ int $retry_interval = ] Parameter #5 [ bool $status = ] - Parameter #6 [ $failure_callbac = ] + Parameter #6 [ $failure_callback = ] } - Return [ bool ] } diff --git a/tests/059b.phpt b/tests/059b.phpt index ce3dfe9..d789fe4 100644 --- a/tests/059b.phpt +++ b/tests/059b.phpt @@ -87,7 +87,7 @@ Class [ class MemcachePool ] { Parameter #2 [ float $timeout ] Parameter #3 [ int $retry_interval ] Parameter #4 [ bool $status ] - Parameter #5 [ $failure_callbac ] + Parameter #5 [ $failure_callback ] } - Return [ bool ] } @@ -348,7 +348,7 @@ Class [ class Memcache extends MemcachePool ] { Parameter #2 [ float $timeout ] Parameter #3 [ int $retry_interval ] Parameter #4 [ bool $status ] - Parameter #5 [ $failure_callbac ] + Parameter #5 [ $failure_callback ] } - Return [ bool ] } @@ -594,7 +594,7 @@ Function [ function memcache_set_server_params ] { Parameter #3 [ float $timeout ] Parameter #4 [ int $retry_interval ] Parameter #5 [ bool $status ] - Parameter #6 [ $failure_callbac ] + Parameter #6 [ $failure_callback ] } - Return [ bool ] } From 252f28af1c892763f1fd53d6f446536bd727c62f Mon Sep 17 00:00:00 2001 From: Zaffy Date: Thu, 8 Oct 2020 15:36:37 +0200 Subject: [PATCH 12/12] Update config.w32 Co-authored-by: Tyson Andre --- config.w32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.w32 b/config.w32 index 65942ac..5df350a 100644 --- a/config.w32 +++ b/config.w32 @@ -9,7 +9,7 @@ if (PHP_MEMCACHE != "no") { var dll = get_define('PHPDLL'); var old_conf_dir = configure_module_dirname; - if (dll.match(/^src/) != null) { + if (dll.match(/^php[78]/) != null) { configure_module_dirname = configure_module_dirname + "\\src"; } else if (dll.match(/^php5/) != null) { ERROR("PHP 7.x required for pecl-php-memcache ver 4+. Use pecl-php-meachce ver 3.x for PHP 5.x.");