Git Product home page Git Product logo

pecl-memcache's People

Contributors

aidvu avatar andypost avatar bobvandevijver avatar borodiychuk avatar drealecs avatar dward avatar edinkad avatar elbandi avatar fmk avatar glensc avatar gsmaul avatar jan-e avatar kolsys avatar pierrejoye avatar pmurzakov avatar remicollet avatar rlerdorf avatar rossaffandy avatar shyim avatar szabolcsbalogh avatar thesource93 avatar timgates42 avatar tomassrnka avatar tony2001 avatar tyrael avatar vnsavage avatar weltling avatar wez avatar willfitch avatar zaffy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pecl-memcache's Issues

Remove support for PHP 5

Let's make 4+ version just PHP7+ version.

We should drop support for php5 and remove the code. If you are still using PHP5, you can use 3.x version of pecl-memcache.

session_start(): Failed to read session data: memcache using php7.2

Hey,

I tried some debugging but I think php is the problem:

php-fpm configuration

php_admin_value[session.save_handler] = memcache
php_admin_value[session.save_path] = tcp://10.100.128.54:11211, tcp://10.100.128.55:11211

Error message:

[12-Jul-2019 10:31:32 Europe/Berlin] PHP Warning:  session_start(): Failed to read session data: memcache (path: tcp://10.100.128.54:11211, tcp://10.100.128.55:11211) in /var/www/vhosts/cuschtomer/htdocs/backend/__test_dc1_memcached.php on line 11

Test file:

<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

#echo $_SERVER['SERVER_ADDR'];
#ini_set("memcache
session_start();
#$_SESSION["dc1"] = "test";
#echo $_SESSION["dc1"];
#phpinfo();
echo "done\n";
?>

ngrep log:

root@cuschtomer:~# ngrep -d any -q -W byline port 11211 and host 10.100.128.54
interface: any
filter: ( port 11211 and host 10.100.128.54 ) and (ip || ip6)

T 10.100.128.160:44808 -> 10.100.128.54:11211 [AP] #4
incr r9v63n79qkva4igrme08vce2n3.lock 1.

T 10.100.128.160:44808 -> 10.100.128.54:11211 [AP] #6
add r9v63n79qkva4igrme08vce2n3.lock 768 15 1.
1.
get r9v63n79qkva4igrme08vce2n3.

T 10.100.128.54:11211 -> 10.100.128.160:44808 [AP] #7
NOT_FOUND.

T 10.100.128.54:11211 -> 10.100.128.160:44808 [AP] #9
STORED.

T 10.100.128.54:11211 -> 10.100.128.160:44808 [AP] #11
END.

We are using php7.2-fpm on Ubuntu 18.04 with php-memcache (3.0.9~20160311.4991c2f-5build2). The Memcached server runs on Ubuntu 16.04 (1.4.25-2ubuntu1.2). There are no erros in the log file. Any idea what's wrong?

Greetings

kmille

Provide a getResultCode() to check if the most recent memcache operation had an error?

The related Memcached pecl provides
https://www.php.net/manual/en/memcached.getresultcode.php
https://www.php.net/manual/en/memcached.getresultmessage.php

Otherwise, workarounds have to be used to distinguish between

  1. The value false, from unserialize() (if applications used them)
  2. A cache miss (absence can be detected with $flags)
  3. An memcache protocol error/timeout that caused Memcache to return false (error_clear_last()/error_get_last() can be used as a workaround, unless set_error_handler's callback has the possibility of clearing the last error or triggering other notices)

https://bugs.php.net/bug.php?id=69809 is vaguely related but I'm guessing behavior changed in php7

PHP 7.3 memcache losing sessions

Hi on a Wamp installation (Windows 10 / x64) i have noticed that after upgrading to php 7.3 from 7.2 i face issue with memcache losing session data. I haven't found any references online on similar issue, apart from this one nono303/PHP-memcache-dll#15 . However we have been able to reproduce it in two different setups, on two different machines. Any advice would be much appreciated.

PHP 8

Hello.

I got errors:

Command:
make

Errors:

NON_BLOCKING_IO_php80/php7/memcache.c:43:2: error: initializer element is not constant

...
te: expected 'struct zend_object *' but argument is of type 'stru
...

warning: passing argument 2 of 'zend_read_property' from incompatible pointer type [enabled by 

Thank you.

PHP 7 support ready?

How ready is this for production use? It appears to compile. If it is somewhat stable, which branches do you recommend? Non blocking IO seems nice, but I'm unclear whether that branch is experimental work or completed work.

Thanks for your work on this module.

Installation procedure?

Hello please could someone put to the readme how to install this in a php 7 FPM? I'm newbie :)

Causes PHP 7.0.14 Crash

Hi guys.

Appears this port does not work when installed on PHP 7.0.14 - the current FreeBSD distro. It actually causes a complete PHP crash on every execution.

Any help appreciated.

Thanks.

PECL Release

If you maintain this extension and tag versions (4.0.x), please see to publish them on PECL.

MemcachePool not found

hey, thanks for porting :)

if i use this extension (i checked in phpinfo, and yes its loaded) i get: ClassNotFoundException: Attempted to load class "MemcachePool" from the global namespace. Did you forget a "use" statement? i guess, the object oriented layer is missing in the pecl extension?

my php env:

$ php --version
PHP 7.0.0RC6 (cli) (built: Oct 29 2015 13:46:05) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

but if i use the attached memcache.php it seems to work :/

merge/replace?

Hi,

Great work on the port to 7! Thanks :)

Are you interested to merge into the official (but lacking love, blame me) extension?

I would also like to move the repository to the friendsofphp organization to ease additions of more contributors as well as making it more visible.

Let me know if it sounds good, it would be then easier to move this repository to the organization instead of merging or syncing :)

Allow overriding the hardcoded retry timeout of 15 in php.ini for connect, as well as for connect/memcache_pconnect calls?

E.g. this could be added to the options after $timeoutms in memcache_connect($host, $port, $timeout) and memcache_pconnect().

It's possible through addServer but not pconnect()

https://www.php.net/manual/en/memcache.addserver.php

The c code doesn't seem to have a way to do this in 4.0.5

static void php_mmc_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool persistent) /* {{{ */
{
	zval *mmc_object = getThis();
	mmc_pool_t *pool;
	mmc_t *mmc;
	char *host;
	size_t host_len;
	zend_long tcp_port = MEMCACHE_G(default_port);
	double timeout = MMC_DEFAULT_TIMEOUT;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|ld", &host, &host_len, &tcp_port, &timeout) == FAILURE) {
		return;
	}

Example use cases:

  • Running a proxy on localhost where connection attempts are quick and the memcache server itself would not be affected by repeated connection attempts from php to the proxy
  • or connect for use cases where getting the result or updating memcache is worth a higher wait time.

when i make,this problem has occurred.

root/php-7.0.5/ext/memcached/php_memcached_session.c: In function 's_configure_from_ini_values':
/root/php-7.0.5/ext/memcached/php_memcached_session.c:221:22: error: 'MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS' undeclared (first use in this function)
check_set_behavior(MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS, 1);
^
/root/php-7.0.5/ext/memcached/php_memcached_session.c:195:42: note: in definition of macro 'check_set_behavior'
if ((rc = memcached_behavior_set(memc, (behavior), (value))) != MEMCACHED_SUCCESS) {
^
/root/php-7.0.5/ext/memcached/php_memcached_session.c:221:22: note: each undeclared identifier is reported only once for each function it appears in
check_set_behavior(MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS, 1);
^
/root/php-7.0.5/ext/memcached/php_memcached_session.c:195:42: note: in definition of macro 'check_set_behavior'
if ((rc = memcached_behavior_set(memc, (behavior), (value))) != MEMCACHED_SUCCESS) {
^
/root/php-7.0.5/ext/memcached/php_memcached_session.c:229:32: error: 'MEMCACHED_CALLBACK_NAMESPACE' undeclared (first use in this function)
memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, MEMC_SESS_STR_INI(prefix));
^
make: *** [php_memcached_session.lo] Error 1

how to solve this problem

ZTS support

Looking at code I've noticed all TSRMLS_* macros were removed from php7 code. Doesn't this mean that it won't work when ZTS is enabled?

Was there a specific reason why TSRMLS_* macros were removed from code, e.g.

-static void _mmc_pool_list_dtor(zend_rsrc_list_entry * TSRMLS_DC);
+static void _mmc_pool_list_dtor(zend_resource *);

or

-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "memcache.max_failover_attempts must be a positive integer ('%s' given)", new_value);
+		php_error_docref(NULL, E_WARNING, "memcache.max_failover_attempts must be a positive integer ('%s' given)", ZSTR_VAL(new_value));

Memcache extension can't read from memcached

Hello
I've installed php 7.1.1 and the extensions is version 3.0.9-dev

When I try to do a session_start I get :
Warning: session_start(): Failed to read session data: memcache (path: tcp://127.0.0.1:11211) in /usr/local/httpd-2.4.25/logs/test.php on line 1
array(0) {
}

This the script I used :

This is my php.ini
session.save_handler = memcache
session.save_path = '127.0.0.1:11211'
memcache.lock_timeout = 60
extension=memcache.so

Can you please check?
Thanks

install of memcache-3.0.8 fails

Starting to download memcache-3.0.8.tgz (70,523 bytes)
.....done: 70,523 bytes
15 source files, building
running: phpize
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012

/usr/local/apache2/php5/include/php/Zend/zend_hash.h:171:30: note: declared here
/tmp/pear/temp/memcache/memcache.c: In function ‘zif_memcache_get_stats’:
/tmp/pear/temp/memcache/memcache.c:1785:34: error: ‘IS_BOOL’ undeclared (first use in this function)
/tmp/pear/temp/memcache/memcache.c:1785:31: warning: comparison between pointer and integer [enabled by default]
make: *** [memcache.lo] Fehler 1
ERROR: `make' failed


any ideas?

php7.3 + WHM error

Trying to install on WHM controled server.

/opt/cpanel/ea-php73/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php73/root/usr/bin/php-config && make;


Configuring for:
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /opt/cpanel/ea-php73/root/usr
checking for PHP includes... -I/opt/cpanel/ea-php73/root/usr/include/php -I/opt/cpanel/ea-php73/root/usr/include/php/main -I/opt/cpanel/ea-php73/root/usr/include/php/TSRM -I/opt/cpanel/ea-php73/root/usr/include/php/Zend -I/opt/cpanel/ea-php73/root/usr/include/php/ext -I/opt/cpanel/ea-php73/root/usr/include/php/ext/date/lib
checking for PHP extension directory... /opt/cpanel/ea-php73/root/usr/lib64/php/modules
checking for PHP installed headers prefix... /opt/cpanel/ea-php73/root/usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable memcache support... yes, shared
checking whether to enable memcache session handler support... yes
checking for the location of ZLIB... no
checking for the location of zlib... /usr
checking PHP version... PHP 7.x
checking for session includes... /opt/cpanel/ea-php73/root/usr/include/php
checking for memcache session support... enabled
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @file support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) gawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
/bin/sh /usr/local/src/pecl-memcache-4.0.1-php73/libtool --mode=compile cc -I/opt/cpanel/ea-php73/root/usr/include/php -I. -I/usr/local/src/pecl-memcache-4.0.1-php73 -DPHP_ATOM_INC -I/usr/local/src/pecl-memcache-4.0.1-php73/include -I/usr/local/src/pecl-memcache-4.0.1-php73/main -I/usr/local/src/pecl-memcache-4.0.1-php73 -I/opt/cpanel/ea-php73/root/usr/include/php -I/opt/cpanel/ea-php73/root/usr/include/php/main -I/opt/cpanel/ea-php73/root/usr/include/php/TSRM -I/opt/cpanel/ea-php73/root/usr/include/php/Zend -I/opt/cpanel/ea-php73/root/usr/include/php/ext -I/opt/cpanel/ea-php73/root/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/pecl-memcache-4.0.1-php73/php7/memcache.c -o php7/memcache.lo
libtool: compile: cc -I/opt/cpanel/ea-php73/root/usr/include/php -I. -I/usr/local/src/pecl-memcache-4.0.1-php73 -DPHP_ATOM_INC -I/usr/local/src/pecl-memcache-4.0.1-php73/include -I/usr/local/src/pecl-memcache-4.0.1-php73/main -I/usr/local/src/pecl-memcache-4.0.1-php73 -I/opt/cpanel/ea-php73/root/usr/include/php -I/opt/cpanel/ea-php73/root/usr/include/php/main -I/opt/cpanel/ea-php73/root/usr/include/php/TSRM -I/opt/cpanel/ea-php73/root/usr/include/php/Zend -I/opt/cpanel/ea-php73/root/usr/include/php/ext -I/opt/cpanel/ea-php73/root/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/pecl-memcache-4.0.1-php73/php7/memcache.c -fPIC -DPIC -o php7/.libs/memcache.o
/usr/local/src/pecl-memcache-4.0.1-php73/php7/memcache.c: In function 'php_mmc_store':
/usr/local/src/pecl-memcache-4.0.1-php73/php7/memcache.c:643:4: error: too many arguments to function 'mmc_prepare_key_ex'
if (mmc_prepare_key_ex(ZSTR_VAL(key), ZSTR_LEN(key), request->key, &(request->key_len), MEMCACHE_G(key_prefix)) != MMC_OK) {
^
In file included from /usr/local/src/pecl-memcache-4.0.1-php73/php7/php_memcache.h:34:0,
from /usr/local/src/pecl-memcache-4.0.1-php73/php7/memcache.c:30:
/usr/local/src/pecl-memcache-4.0.1-php73/php7/memcache_pool.h:399:5: note: declared here
int mmc_prepare_key_ex(const char *, unsigned int, char *, unsigned int *);
^
make: *** [php7/memcache.lo] Error 1

Cannot install on Homebrew PHP 7.2

Trying to do

  • sudo pecl install memcache
  • on macOS 10.14.6 Mojave
  • PHP: PHP 7.2.23 (cli) (built: Oct 3 2019 19:49:50) ( NTS )

Expected

Extension installs

Observed

Failure because zlib cannot be located.

downloading memcache-4.0.5.2.tgz ...
Starting to download memcache-4.0.5.2.tgz (75,061 bytes)
.................done: 75,061 bytes
18 source files, building

Warning: preg_match(): Unknown modifier '7' in Builder.php on line 310

Warning: preg_match(): Unknown modifier '7' in /usr/local/Cellar/[email protected]/7.2.23/share/[email protected]/pear/PEAR/Builder.php on line 310

Call Stack:
    0.0004     421224   1. {main}() /usr/local/Cellar/[email protected]/7.2.23/share/[email protected]/pear/peclcmd.php:0
    0.0021     496344   2. require_once('/usr/local/Cellar/[email protected]/7.2.23/share/[email protected]/pear/pearcmd.php') /usr/local/Cellar/[email protected]/7.2.23/share/[email protected]/pear/peclcmd.php:31
    0.0370    2086784   3. PEAR_Command_Install->run() /usr/local/Cellar/[email protected]/7.2.23/share/[email protected]/pear/pearcmd.php:316
    0.0370    2086784   4. PEAR_Command_Install->doInstall() /usr/local/Cellar/[email protected]/7.2.23/share/[email protected]/pear/PEAR/Command/Common.php:270
    2.8958    5614936   5. PEAR_Installer->install() /usr/local/Cellar/[email protected]/7.2.23/share/[email protected]/pear/PEAR/Command/Install.php:713
    3.0049    5925200   6. PEAR_Installer->_compileSourceFiles() /usr/local/Cellar/[email protected]/7.2.23/share/[email protected]/pear/PEAR/Installer.php:1415
    3.0058    6007240   7. PEAR_Builder->build() /usr/local/Cellar/[email protected]/7.2.23/share/[email protected]/pear/PEAR/Installer.php:1519
    3.0062    6008424   8. preg_match() /usr/local/Cellar/[email protected]/7.2.23/share/[email protected]/pear/PEAR/Builder.php:310

running: phpize
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
Enable memcache session handler support? [yes] :
building in /private/tmp/pear/temp/pear-build-rootaIqbJi/memcache-4.0.5.2
running: /private/tmp/pear/temp/memcache/configure --with-php-config=/usr/local/opt/[email protected]/bin/php-config --enable-memcache-session=yes
checking for grep that handles long lines and -e... /usr/bin/grep
// ...snip...
checking for PHP prefix... /usr/local/Cellar/[email protected]/7.2.23
checking for PHP includes... -I/usr/local/Cellar/[email protected]/7.2.23/include/php -I/usr/local/Cellar/[email protected]/7.2.23/include/php/main -I/usr/local/Cellar/[email protected]/7.2.23/include/php/TSRM -I/usr/local/Cellar/[email protected]/7.2.23/include/php/Zend -I/usr/local/Cellar/[email protected]/7.2.23/include/php/ext -I/usr/local/Cellar/[email protected]/7.2.23/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/Cellar/[email protected]/7.2.23/pecl/20170718
checking for PHP installed headers prefix... /usr/local/Cellar/[email protected]/7.2.23/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking whether to enable memcache support... yes, shared
checking whether to enable memcache session handler support... yes
checking for the location of ZLIB... no
checking for the location of zlib... configure: error: memcache support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
ERROR: `/private/tmp/pear/temp/memcache/configure --with-php-config=/usr/local/opt/[email protected]/bin/php-config --enable-memcache-session=yes' failed

Although it is actually present in the PHP configuration:

php -i | grep zlib 
Configure Command =>  './configure'  
  '--prefix=/usr/local/Cellar/[email protected]/7.2.23' 
  '--localstatedir=/usr/local/var' 
  '--sysconfdir=/usr/local/etc/php/7.2' 
   '--with-config-file-path=/usr/local/etc/php/7.2' 
   /* ...snip... */ 
   '--with-zlib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr'

And the header exists:

ls -l /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/zlib*
-rw-r--r--  7 root  wheel  98288  3 nov 18:24 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/zlib.h

Add ReflectionParameter param information for functions and methods?

and return for some methods.

Currently, ReflectionFunctionAbstract->getParameters() reports most of these have no parameters, in 4.0.5.2.

Instead of arginfo, NULL is passed.

Would you be interested in PRs to add this info, or on working on it yourself?

EDIT: public function get($arg, &$arg, &$arg) {} and function memcache_get($arg, $arg, &$arg, &$arg) {} should also use distinct parameter names

https://github.com/php/php-src/blob/master/scripts/dev/gen_stub.php may be useful to generate readable stub info from a php stub file, but the output is only meant for php 8 and would need to be changed.

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_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}
};

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_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}
};

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}
};

Motivations

  • Improve quality of PHP's error messages and static analysis of code using memcache (e.g. with Phan/Psalm)
  • Make tooling using Reflection information work better.

PHP 7.2 compatibility

Hey there,
I wanted to ask about the current Status of PHP 7.2 compatibility as "make test" throws some Errors.

Centos 7
memcached Server Version: 1.4.15
PHP: 7.2.2

Number of tests : 74 73
Tests skipped : 1 ( 1.4%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 22 ( 29.7%) ( 30.1%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 51 ( 68.9%) ( 69.9%)

make test | grep -i fail
FAIL memcache->addServer() [tests/019.phpt]
FAIL memcache->set()/memcache->get() with multiple keys and load balancing [tests/020.phpt]
FAIL memcache->getExtendedStats() [tests/022.phpt]
FAIL memcache_get_extended_stats() [tests/022a.phpt]
FAIL memcache->delete() with load balancing [tests/023.phpt]
FAIL memcache->increment() with load balancing [tests/025.phpt]
FAIL memcache->delete() with load balancing [tests/026.phpt]
FAIL memcache->addServer() adding server in failed mode [tests/031.phpt]
FAIL memcache->getServerStatus(), memcache->setServerParams() [tests/032.phpt]
FAIL memcache::connect() with unix domain socket [tests/035.phpt]
FAIL ini_set('session.save_handler') [tests/036.phpt]
FAIL memcache->get() over UDP [tests/038.phpt]
FAIL memcache->get() over multi-datagram UDP [tests/039.phpt]
FAIL memcache->increment()/decrement() with multiple keys [tests/040.phpt]
FAIL memcache->delete() with multiple keys [tests/041.phpt]
FAIL memcache->set() with multiple values [tests/042.phpt]
FAIL ini_set('memcache.redundancy') [tests/043.phpt]
FAIL ini_set('memcache.session_redundancy') [tests/044.phpt]
FAIL hash strategies and functions [tests/046.phpt]
FAIL ini_set('session.save_handler') with unix domain socket [tests/053.phpt]
FAIL session locking [tests/057.phpt]
FAIL memcache multi host save path function [tests/bug73539.phpt]

thx
Andreas Schnederle-Wagner

Php 7.2.15 issue compile

/php-7.2.15/ext/memcache/php7/memcache.c:643:8: error: too many arguments to function 'mmc_prepare_key_ex'
if (mmc_prepare_key_ex(ZSTR_VAL(key), ZSTR_LEN(key), request->key, &(request->key_len), MEMCACHE_G(key_prefix)) != MMC_OK) {
^~~~~~~~~~~~~~~~~~
In file included from /php-7.2.15/ext/memcache/php7/php_memcache.h:34,
from /php-7.2.15/ext/memcache/php7/memcache.c:30:
/php-7.2.15/ext/memcache/php7/memcache_pool.h:399:5: note: declared here
int mmc_prepare_key_ex(const char *, unsigned int, char *, unsigned int *);
^~~~~~~~~~~~~~~~~~

php7.3 error

[root@localhost pecl-memcache-php7]# /server/php7/bin/phpize
Configuring for:
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
[root@localhost pecl-memcache-php7]# ./configure --with-php-config=/server/php7/bin/php-config
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /server/php7
checking for PHP includes... -I/server/php7/include/php -I/server/php7/include/php/main -I/server/php7/include/php/TSRM -I/server/php7/include/php/Zend -I/server/php7/include/php/ext -I/server/php7/include/php/ext/date/lib
checking for PHP extension directory... /server/php7/lib/php/extensions/no-debug-zts-20180731
checking for PHP installed headers prefix... /server/php7/include/php
checking if debug is enabled... no
checking if zts is enabled... yes
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable memcache support... yes, shared
checking whether to enable memcache session handler support... yes
checking for the location of ZLIB... no
checking for the location of zlib... /usr
checking for session includes... /server/php7/include/php
checking for memcache session support... enabled
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
[root@localhost pecl-memcache-php7]# make
/bin/sh /home/pecl-memcache-php7/libtool --mode=compile cc -I/server/php7/include/php -I. -I/home/pecl-memcache-php7 -DPHP_ATOM_INC -I/home/pecl-memcache-php7/include -I/home/pecl-memcache-php7/main -I/home/pecl-memcache-php7 -I/server/php7/include/php -I/server/php7/include/php/main -I/server/php7/include/php/TSRM -I/server/php7/include/php/Zend -I/server/php7/include/php/ext -I/server/php7/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /home/pecl-memcache-php7/memcache.c -o memcache.lo
mkdir .libs
cc -I/server/php7/include/php -I. -I/home/pecl-memcache-php7 -DPHP_ATOM_INC -I/home/pecl-memcache-php7/include -I/home/pecl-memcache-php7/main -I/home/pecl-memcache-php7 -I/server/php7/include/php -I/server/php7/include/php/main -I/server/php7/include/php/TSRM -I/server/php7/include/php/Zend -I/server/php7/include/php/ext -I/server/php7/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /home/pecl-memcache-php7/memcache.c -fPIC -DPIC -o .libs/memcache.o
/home/pecl-memcache-php7/memcache.c: In function ‘php_mmc_store’:
/home/pecl-memcache-php7/memcache.c:1842:3: warning: passing argument 1 of ‘smart_string_free_ex’ from incompatible pointer type [enabled by default]
smart_string_free(&buf);
^
In file included from /server/php7/include/php/ext/standard/php_smart_string.h:21:0,
from /home/pecl-memcache-php7/memcache.c:42:
/server/php7/include/php/Zend/zend_smart_string.h:67:32: note: expected ‘struct smart_string *’ but argument is of type ‘struct smart_str *’
static zend_always_inline void smart_string_free_ex(smart_string *str, zend_bool persistent) {
^
/home/pecl-memcache-php7/memcache.c: In function ‘php_mmc_connect’:
/home/pecl-memcache-php7/memcache.c:1946:24: error: lvalue required as increment operand
GC_REFCOUNT(list_res)++;
^
/home/pecl-memcache-php7/memcache.c:1965:24: error: lvalue required as increment operand
GC_REFCOUNT(list_res)++;
^
/home/pecl-memcache-php7/memcache.c: In function ‘zif_memcache_add_server’:
/home/pecl-memcache-php7/memcache.c:2057:24: error: lvalue required as increment operand
GC_REFCOUNT(list_res)++;
^
/home/pecl-memcache-php7/memcache.c: In function ‘mmc_find_persistent’:
/home/pecl-memcache-php7/memcache.c:2203:19: error: lvalue required as left operand of assignment
GC_REFCOUNT(le) = 1;
^
/home/pecl-memcache-php7/memcache.c:2220:19: error: lvalue required as left operand of assignment
GC_REFCOUNT(le) = 1;
^
make: *** [memcache.lo] Error 1

pecl install failed: cannot create directory 'php7/.libs': No such file or directory

Sample session (started with docker run --rm -it php:7.0-cli bash):

root@04ba66c5990a:/# apt-get update -qq && apt-get install -qqy zlib1g-dev
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package zlib1g-dev:amd64.
(Reading database ... 12291 files and directories currently installed.)
Preparing to unpack .../zlib1g-dev_1%3a1.2.8.dfsg-5_amd64.deb ...
Unpacking zlib1g-dev:amd64 (1:1.2.8.dfsg-5) ...
Setting up zlib1g-dev:amd64 (1:1.2.8.dfsg-5) ...

root@04ba66c5990a:/# printf 'yes\n' | pecl install memcache
downloading memcache-4.0.5.1.tgz ...
Starting to download memcache-4.0.5.1.tgz (75,057 bytes)
.................done: 75,057 bytes
18 source files, building
running: phpize
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
Enable memcache session handler support? [yes] : building in /tmp/pear/temp/pear-build-defaultuserySTvhd/memcache-4.0.5.1
running: /tmp/pear/temp/memcache/configure --with-php-config=/usr/local/bin/php-config --enable-memcache-session=yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20151012
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 0.16 (ok)
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking whether to enable memcache support... yes, shared
checking whether to enable memcache session handler support... yes
checking for the location of ZLIB... no
checking for the location of zlib... /usr
checking PHP version... PHP 7.x
checking for session includes... /usr/local/include/php
checking for memcache session support... enabled
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/bash /tmp/pear/temp/pear-build-defaultuserySTvhd/memcache-4.0.5.1/libtool --mode=compile cc -I/usr/local/include/php -I. -I/tmp/pear/temp/memcache -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserySTvhd/memcache-4.0.5.1/include -I/tmp/pear/temp/pear-build-defaultuserySTvhd/memcache-4.0.5.1/main -I/tmp/pear/temp/memcache -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/memcache/php7/memcache.c -o php7/memcache.lo
/tmp/pear/temp/pear-build-defaultuserySTvhd/memcache-4.0.5.1/libtool: line 1283: php7/memcache.loT: No such file or directory
mkdir php7/.libs
mkdir: cannot create directory 'php7/.libs': No such file or directory
Makefile:194: recipe for target 'php7/memcache.lo' failed
make: *** [php7/memcache.lo] Error 1
ERROR: `make' failed

Cannot build 3.x releases for php 5.6 in gcc 5.4.0 due to use of "inline"

The patch 82480df was applied to the latest releases, but never backported to 3.x for php 5.

From #49 , I'm not sure whether or not there are plans to continue supporting the 3.x release line. I didn't find any related issues.

  • Ideally, a 3.0.9 release would be available to fix the uses of inline (extern inline in functions declared in headers?)
  • https://github.com/TysonAndre/pecl-memcache/pull/1/files includes the uses of inline that needed to be changed (extern inline would probably also work, but I didn't test that). mmc_prepare_key_ex is used from 2 different files.

https://gcc.gnu.org/gcc-5/porting_to.html mentions that the way inline was compiled changed, and that extern inline should be used instead (see 82480df)

Motivation: Give projects still using the "memcache" PECL in 5.x a way to update and test in php 5.6 (a newer compiler may be needed on newer OSes) then to php 7.x

configure abort with php 7.2.x compile as extension

abort configure at PHP version check

please see for patch in config9.m4:

AC_MSG_CHECKING(PHP version)
  if test -z "$PHP_MAJOR_VERSION"; then
	if test ! -z "$phpincludedir"; then
    	PHP_MAJOR_VERSION=`grep 'PHP_MAJOR_VERSION ' $phpincludedir/main/php_version.h | sed -e 's/.*\([[0-9\.]]*\).*/\1/g' 2>/dev/null`
	elif test ! -z "$PHP_CONFIG"; then
    	PHP_MAJOR_VERSION=`$PHP_CONFIG --version | cut -d. -f1 2>/dev/null`
        else 
        PHP_MAJOR_VERSION=0
	fi
  fi
  		
  if test $PHP_MAJOR_VERSION -ge 7; then
  	subdir=php7
  	AC_MSG_RESULT([PHP 7.x])
  else
  	AC_MSG_ERROR([PHP 7.x required for pecl-php-memcache ver 4+. Use pecl-php-memcache ver 3.x for PHP 5.x.])
  fi

"Memcache session handling, zend_mm_heap corrupted" on bugs.php.net

https://bugs.php.net/bug.php?id=77900

Sorry if you've already seen this. (The issue has no assignee or response comments on bugs.php.net, so I can't tell, and I personally don't check bugs.php.net frequently or know how to subscribe to bug reports for a given extension.)

The bug was for memcache 3.0.9 with php 7.3. I can't reproduce the zend_mm_heap issue in 4.0.5.2 from PECL (trying with NTS on 7.4 only). However, I see a memory leak (same leak 4 times) instead in 4.0.5.2, when running with a PHP 7.4.3-dev NTS DEBUG build.
(The impact is hopefully limited to just a few http requests for sessions, and should get garbage collected after the HTTP response is sent? I haven't investigated further)

» php --no-php-ini --php-ini test.ini test.php
array(1) {                                     
  ["test"]=>                                   
  bool(true)                                   
}                                              
[Fri Mar  6 15:40:14 2020]  Script:  '/path/to/test.php'
/tmp/pear/temp/memcache/php7/memcache_queue.c(35) :  Freeing 0x00007f0542e7d700 (208 bytes), script=/path/to/test.php
Last leak repeated 3 times
=== Total 4 memory leaks detected ===

Is there a bug with prefix_host_key?

I'm having a problem with the configuration of prefix_host_key and/or session_prefix_host_key.
It appears that under certain conditions versions 4.0.3/4.0.4 (Windows, x64, TS, PHP7.3.6) ignore their settings and always add a prefix to each key. Unfortunately, I'm currently not able to reproduce these conditions, it seems to be a random behavior. When I restart PHP the problem is resolved but after few time it appears again.
I have also used different memcached servers (under linux, under windows native + cygwin).

I'm using this code to test:

<?php

$pool = new MemcachePool();
$pool->addServer( '127.0.0.1' );


$pool->set( 'test1', 'value1', 0, time() + 24 * 3600 );
$pool->delete( 'test1' );
$pool->set( 'test1', 'value2', 0, time() + 24 * 3600 );
$pool->delete( 'test1' );
$pool->set( 'test1', 'value3', 0, time() + 24 * 3600 );

$_SERVER['SERVER_NAME'] = '';

echo "SERVER_NAME='$_SERVER[SERVER_NAME]' -> " . $pool->get( 'test1' ) . PHP_EOL;

$_SERVER['SERVER_NAME'] = 'this.is.a.test';

echo "SERVER_NAME='$_SERVER[SERVER_NAME]' -> " . $pool->get( 'test1' ) . PHP_EOL;

$_SERVER['SERVER_NAME'] = '';

$N = 500;

echo 'testing ' . $N . ' keys...' . PHP_EOL;

$base_key = sprintf( '%x', crc32( mt_rand() ) );

$errors = 0;

for ( $i = 0; $i < $N; $i ++ ) {
	$pool->set( $base_key . ':' . $i, $i, 0, time() + 24 * 3600 );
}
for ( $i = 0; $i < $N; $i ++ ) {
	$r = $pool->get( $base_key . ':' . $i );
	if ( $r !== $i ) {
		$errors ++;
	}
}

echo "tested keys: $N - errors: $errors" . PHP_EOL;

$errors = 0;
for ( $i = 0; $i < $N; $i ++ ) {
	$pool->delete( $base_key . ':' . $i );
	$r = $pool->get( $base_key . ':' . $i );
	if ( $r === $i ) {
		$errors ++;
	}
}

echo "deleted keys: $N - errors: $errors" . PHP_EOL;

$gets = $deletes = 0;
for ( $i = 0; $i < $N; $i ++ ) {
	$pool->set( $key = md5( mt_rand() ), ( $value = md5( mt_rand() ) ), 0, time() + 24 * 3600 );
	if ( $pool->get( $key ) === $value ) {
		$gets ++;
	}
	$pool->replace( $key, '.:|-deleted-|:.', 0, time() + 24 * 3600 );
	if ( $pool->get( $key ) !== $value ) {
		$deletes ++;
	}
}

echo "checks: $N - get: $gets - delete: $deletes" . PHP_EOL;

$pool->set( 'test1', 'value4', 0, time() + 24 * 3600 );
$pool->delete( 'test1' );
$pool->set( 'test1', 'value5', 0, time() + 24 * 3600 );
$pool->delete( 'test1' );
$pool->set( 'test1', 'value6', 0, time() + 24 * 3600 );

$_SERVER['SERVER_NAME'] = '';

echo "SERVER_NAME='$_SERVER[SERVER_NAME]' -> " . $pool->get( 'test1' ) . PHP_EOL;

$_SERVER['SERVER_NAME'] = 'this.is.a.test';

echo "SERVER_NAME='$_SERVER[SERVER_NAME]' -> " . $pool->get( 'test1' ) . PHP_EOL;

Sometimes it returns:

SERVER_NAME='' -> value3
SERVER_NAME='this.is.a.test' -> value3
testing 500 keys...
tested keys: 500 - errors: 0
deleted keys: 500 - errors: 0
checks: 500 - get: 500 - delete: 500
SERVER_NAME='' -> value6
SERVER_NAME='this.is.a.test' -> value6

Other times something like this:

SERVER_NAME='' -> value3
SERVER_NAME='this.is.a.test' -> value3
testing 500 keys...
tested keys: 500 - errors: 0
deleted keys: 500 - errors: 0
checks: 500 - get: 44 - delete: 500
SERVER_NAME='' -> 
SERVER_NAME='this.is.a.test' -> 

These results suggest to me that there are at least 2 issues.

wrong return value

php7.0.14 + pecl-memcache

problem with return value

$memcache->set('user21721',FALSE,0,10);
$ar =$memcache->get('user21721');
var_dump($ar);

returns string(0) "" instead bool(false)

Test in Symfony's HttpFoundation failing with websupport-sk/pecl-memcache under PHP 7

Note: Referencing this from symfony/symfony#17873 in which a proposed fix for Symfony was rejected with the wish to fix this upstream (in websupport-sk/pecl-memcache).

Problem

Using websupport-sk/pecl-memcache (branch php7 / commit 88750b4) with PHP 7 a test in Symfony's HttpFoundation (v3.0.2) component is failing with the following error:

# php7.0 -f /tmp/phpunit.phar -- src/Symfony/Component/HttpFoundation
PHPUnit 5.2.9 by Sebastian Bergmann and contributors.

...............................................................  63 / 809 (  7%)
................................................S.............. 126 / 809 ( 15%)
...................................................S........... 189 / 809 ( 23%)
............................................................... 252 / 809 ( 31%)
............................................................... 315 / 809 ( 38%)
..............................................SS............... 378 / 809 ( 46%)
S.............................................................. 441 / 809 ( 54%)
............................................................... 504 / 809 ( 62%)
............................................................... 567 / 809 ( 70%)
............................................................... 630 / 809 ( 77%)
........................................................E...... 693 / 809 ( 85%)
..SSSSSSSSSSSSSSSSSSSSSS..........SSSSSSSSSSSSSSS.............. 756 / 809 ( 93%)
.....................................................           809 / 809 (100%)

Time: 8.4 seconds, Memory: 14.00Mb

There was 1 error:

1) Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\MemcacheSessionHandlerTest::testReadSession
Missing argument 2 for Mock_Memcache_f8a5b6df::get(), called in /tmp/dabe/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php on line 82 and defined

/tmp/dabe/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php:82
/tmp/dabe/symfony/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php:72

FAILURES!
Tests: 1239, Assertions: 1658, Errors: 1, Skipped: 42.

This does does not happen with the PHP5 version of websupport-sk/pecl-memcache (branch NON_BLOCKING_IO_php7 / commit fdbd46b):

# php5 -f /tmp/phpunit.phar -- src/Symfony/Component/HttpFoundation
PHPUnit 5.2.9 by Sebastian Bergmann and contributors.

...............................................................  63 / 809 (  7%)
................................................S.............. 126 / 809 ( 15%)
...................................................S........... 189 / 809 ( 23%)
............................................................... 252 / 809 ( 31%)
............................................................... 315 / 809 ( 38%)
..............................................SS............... 378 / 809 ( 46%)
S.............................................................. 441 / 809 ( 54%)
............................................................... 504 / 809 ( 62%)
............................................................... 567 / 809 ( 70%)
............................................................... 630 / 809 ( 77%)
............................................................... 693 / 809 ( 85%)
..SSSSSSSSSSSSSSSSSSSSSS..........SSSSSSSSSSSSSSS.............. 756 / 809 ( 93%)
.....................................................           809 / 809 (100%)

Time: 10.24 seconds, Memory: 23.25Mb

OK, but incomplete, skipped, or risky tests!
Tests: 1239, Assertions: 1660, Skipped: 42.

How to reproduce

  • Build websupport-sk/pecl-memcache for php7 and configure php7 to use it
  • Get composer and phpunit in place
  • Checkout Symfony:
    # git clone https://github.com/symfony/symfony.git && cd symfony
  • Reset Symfony to v3.0.2:
    # git reset --hard v3.0.2
  • Install dependencies using composer:
    # composer install
  • Run tests for HttpFoundation component:
    # phpunit src/Symfony/Component/HttpFoundation

Further information

The mocked object generated by phpunit is different for the php7 and the php5 version:

diff -u php5.mock.php php7.mock.php 
--- php5.mock.php   2016-02-28 12:08:01.521713978 +0100
+++ php7.mock.php   2016-02-28 12:06:48.600997172 +0100
@@ -1,4 +1,4 @@
-class Mock_Memcache_988c5512 extends Memcache implements PHPUnit_Framework_MockObject_MockObject
+class Mock_Memcache_2739b378 extends Memcache implements PHPUnit_Framework_MockObject_MockObject
 {
     private $__phpunit_invocationMocker;
     private $__phpunit_originalObject;
@@ -316,15 +316,15 @@
         return $result;
     }

-    public function get()
+    public function get($arg0, &$arg1, &$arg2)
     {
-        $arguments = array();
+        $arguments = array($arg0, &$arg1, &$arg2);
         $count     = func_num_args();

-        if ($count > 0) {
+        if ($count > 3) {
             $_arguments = func_get_args();

-            for ($i = 0; $i < $count; $i++) {
+            for ($i = 3; $i < $count; $i++) {
                 $arguments[] = $_arguments[$i];
             }
         }

Thus I suspect to the php7 version exposes something different through the reflection API, than the php5 version does.

Need explanations regarding RPM packaging errors

Hi!

I'm trying to create RPM package for PHP7 on CentOS7. I have 2 question:

  1. In commit 1a28da3 you've made next change:

diff -rup -x .git pecl-memcache.php5.orig/memcache.c pecl-memcache.php5/memcache.c
--- pecl-memcache.php5.orig/memcache.c 2016-07-29 03:06:28.657638787 +0200
+++ pecl-memcache.php5/memcache.c 2016-07-29 02:57:22.434994396 +0200
@@ -1658,7 +1658,7 @@ PHP_FUNCTION(memcache_get)

/* allocate request */
request = mmc_pool_request_get(
- pool, MMC_PROTO_UDP,
+ pool, MMC_PROTO_TCP,
mmc_value_handler_single, value_handler_param,
mmc_pool_failover_handler, NULL);

Could you explain why do you done this? This caused 038.phpt test fail with next result:

/usr/bin/php7 --no-php-ini --define extension=/root/rpmbuild/BUILDROOT/php7-pecl-memcache-3.0.8-1.el7.centos.x86_64/usr/lib64/php7/modules/memcache.so /root/rpmbuild/BUILD/php7-pecl-memcache-3.0.8/NTS/tests/038.php
bool(true)
bool(true)
array(2) {
["test_key1"]=>
string(3) "abc"
["test_key2"]=>
string(3) "def"
}
array(1) {
["test_key1"]=>
string(3) "abc"
}

Notice: MemcachePool::get(): Server localhost (tcp 11213, udp 11211) failed with: Connection refused (111) in /root/rpmbuild/BUILD/php7-pecl-memcache-3.0.8/NTS/tests/038.php on line 20
bool(false)

It tries to connect to non-existing TCP port 11213 instead of UDP 11211. I'm expect that you've made an error in mentioned commit

  1. In commit f9d3342 you've added to file memcache_binary_protocol.c next line:

header = (mmc_store_request_header_t *)(request->sendbuf.value.c + prevlen);

Variable header (its pointer) is declared using type "mmc_store_append_header_t" but in this commit you use type cast to "mmc_store_request_header_t"

This causes compiler warning. Is it correct casting in this particular case or could be changed to declaration type "mmc_store_append_header_t"

Thanks

PHP 7.3.17 segmentation fault

Hello,
it seems this does not support 7.3.17

I am still using it on PHP 7.2.27 but with 7.3 I get segmentation fault :

[20200609 11:47 1011 [email protected]:~/downloads/memcache-4.0.5.2]# TEST_PHP_EXECUTABLE=/usr/local/php/bin/php php -dextension=memcache.so run-tests.php -d extension=memcache.so

=====================================================================
PHP : /usr/local/php/bin/php
PHP_SAPI : cli
PHP_VERSION : 7.3.17
ZEND_VERSION: 3.3.17
PHP_OS : Linux - Linux cmd-preprod1.nyh.gt-t.net 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64
INI actual : /usr/local/php7.3.17/etc/php.ini
More .INIs :

PHP : /usr/local/php7.3.17/bin/phpdbg
PHP_SAPI : phpdbg
PHP_VERSION : 7.3.17
ZEND_VERSION: 3.3.17
PHP_OS : Linux - Linux cmd-preprod1.nyh.gt-t.net 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64
INI actual : /usr/local/php7.3.17/etc/php.ini
More .INIs :

CWD : /root/downloads/memcache-4.0.5.2
Extra dirs :
VALGRIND : Not used

TIME START 2020-06-09 11:47:28

PASS memcache_set() function [tests/001.phpt]
PASS memcache_get() function [tests/002.phpt]
PASS memcache_set()/memcache_get() using compression [tests/003.phpt]
PASS memcache_add() & memcache_replace() [tests/004.phpt]
PASS strange keys [tests/005.phpt]
PASS memcache_increment() & memcache_decrement() [tests/006.phpt]
PASS memcache_get_version() & memcache_get_stats() [tests/007.phpt]
PASS memcache_delete() [tests/008.phpt]
FAIL memcache->set() method [tests/009.phpt]
PASS memcache->get() function [tests/010.phpt]
PASS memcache->set()/memcache->get() using compression [tests/011.phpt]
PASS memcache_add() & memcache_replace() [tests/012.phpt]
PASS memcache->set() & memcache->get() with strange keys [tests/013.phpt]
PASS memcache->increment() & memcache->decrement() [tests/014.phpt]
PASS memcache->getVersion() & memcache->getStats() [tests/015.phpt]
PASS memcache->delete() [tests/016.phpt]
PASS Memcache class should be inheritable [tests/017.phpt]
PASS memcache_set() & memcache_add() [tests/018.phpt]
FAIL memcache->addServer() [tests/019.phpt]
PASS memcache_add_server() [tests/019a.phpt]
FAIL memcache->set()/memcache->get() with multiple keys and load balancing [tests/020.phpt]
PASS memcache->set()/memcache->get() with failover [tests/021.phpt]
FAIL memcache->getExtendedStats() [tests/022.phpt]
FAIL memcache_get_extended_stats() [tests/022a.phpt]
FAIL memcache->delete() with load balancing [tests/023.phpt]
PASS memcache->close(), memcache->get() [tests/024.phpt]
PASS memcache_close(), memcache_get() [tests/024a.phpt]
FAIL memcache->increment() with load balancing [tests/025.phpt]
FAIL memcache->delete() with load balancing [tests/026.phpt]
PASS memcache->setCompressThreshold() [tests/027.phpt]
PASS memcache_set_compress_threshold() [tests/027a.phpt]
PASS memcache->addServer() and memcache->close() [tests/028.phpt]
PASS ini_set("memcache.allow_failover") [tests/029.phpt]
PASS ini_set("memcache.chunk_size") [tests/030.phpt]
FAIL memcache->addServer() adding server in failed mode [tests/031.phpt]
FAIL memcache->getServerStatus(), memcache->setServerParams() [tests/032.phpt]
PASS memcache->addServer() with server failure callback [tests/033.phpt]
PASS memcache->getStats() with arguments [tests/034.phpt]
FAIL memcache::connect() with unix domain socket [tests/035.phpt]
PASS ini_set('session.save_handler') [tests/036.phpt]
PASS ini_set('session.save_path') [tests/036b.phpt]
PASS ini_set('memcache.hash_strategy') [tests/037.phpt]
SKIP memcache->get() over UDP [tests/038.phpt] reason: known bug
SKIP memcache->get() over multi-datagram UDP [tests/039.phpt] reason: UDP is not enabled in connect.inc
FAIL memcache->increment()/decrement() with multiple keys [tests/040.phpt]
FAIL memcache->delete() with multiple keys [tests/041.phpt]
FAIL memcache->set() with multiple values [tests/042.phpt]
FAIL ini_set('memcache.redundancy') [tests/043.phpt]
SKIP ini_set('memcache.session_redundancy') [tests/044.phpt]
PASS Nested get's in __wakeup() [tests/045.phpt]
FAIL hash strategies and functions [tests/046.phpt]
PASS memcache->get() with flags [tests/047.phpt]
PASS memcache->get(), set() with CAS [tests/048.phpt]
PASS memcache->append(), memcache->prepend() [tests/049.phpt]
PASS failure callback throws exception [tests/050.phpt]
PASS memcache->set() with duplicate keys [tests/051.phpt]
PASS memcache->connect() and memcache->close() in loop [tests/052.phpt]
FAIL ini_set('session.save_handler') with unix domain socket [tests/053.phpt]
PASS memcache->set() with value larger than MTU [tests/054.phpt]
PASS memcache->set()/get() datatype preservation [tests/055.phpt]
PASS memcache->addServer() with microsecond timeout [tests/056.phpt]
PASS session locking [tests/057.phpt]
PASS memcache->findServer() [tests/058.phpt]
PASS memcache->flush() [tests/100.phpt]
PASS memcache_flush() [tests/100a.phpt]
PASS memcache->flush() with time in future [tests/100b.phpt]
SKIP memcache multi host save path function [tests/bug73539.phpt] reason: not relevant for php 7.1+
PASS session_regenerate_id() should not cause fatal error [tests/githubbug13.phpt]
PASS PECL bug #11221 (Double free when returning cached object with __sleep) [tests/pecl11221.phpt]
PASS PECL bug #16442 (memcache_set fail with integer value) [tests/pecl16442.phpt]
PASS PECL bug #16536 (Weight of 0 causes SegFault on memcache_add_server) [tests/pecl16536.phpt]
PASS PECL bug #17518 (Strange behavior in increment on non integer and after) [tests/pecl17518.phpt]
PASS PECL bug #17566 (3.0.4 cache delete bug) [tests/pecl17566.phpt]
PASS PECL bug #63142 (memcache 3.0.7 segfaults with object (un)serialization) [tests/pecl63142.phpt]

TIME END 2020-06-09 11:47:38

=====================================================================
TEST RESULT SUMMARY

Exts skipped : 0
Exts tested : 61

Number of tests : 74 70
Tests skipped : 4 ( 5.4%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 17 ( 23.0%) ( 24.3%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 53 ( 71.6%) ( 75.7%)

Time taken : 10 seconds

=====================================================================
FAILED TEST SUMMARY

memcache->set() method [tests/009.phpt]
memcache->addServer() [tests/019.phpt]
memcache->set()/memcache->get() with multiple keys and load balancing [tests/020.phpt]
memcache->getExtendedStats() [tests/022.phpt]
memcache_get_extended_stats() [tests/022a.phpt]
memcache->delete() with load balancing [tests/023.phpt]
memcache->increment() with load balancing [tests/025.phpt]
memcache->delete() with load balancing [tests/026.phpt]
memcache->addServer() adding server in failed mode [tests/031.phpt]
memcache->getServerStatus(), memcache->setServerParams() [tests/032.phpt]
memcache::connect() with unix domain socket [tests/035.phpt]
memcache->increment()/decrement() with multiple keys [tests/040.phpt]
memcache->delete() with multiple keys [tests/041.phpt]
memcache->set() with multiple values [tests/042.phpt]
ini_set('memcache.redundancy') [tests/043.phpt]
hash strategies and functions [tests/046.phpt]
ini_set('session.save_handler') with unix domain socket [tests/053.phpt]

Here are the tests I run.

Can you please check and let me know?

Thanks

session redundancy weird behaviour when reopening session during request

if session is commited, then reopened, changed and during that time key becomes missing on one of the servers in pool , session is not loaded. however after the final session_write the keys are available on both memcached instances.

eg code from tests/044.phpt

// Test lost session on server1
session_id($balanceKey1);
@session_start();
$_SESSION['key'] = 'Test2';
session_write_close();
unset($_SESSION['key']);

$result = $memcache1->delete($balanceKey1);
var_dump($result);

session_id($balanceKey1);
@session_start();
var_dump($_SESSION);
session_write_close();

// Test lost session on server2                                                                                                                                                                                    
session_id($balanceKey1);
@session_start();
$_SESSION['key'] = 'Test3';
session_write_close();
unset($_SESSION['key']);

$result = $memcache2->delete($balanceKey1);
var_dump($result);

session_id($balanceKey1);
@session_start();
var_dump($_SESSION);
session_write_close();

v4.0.1-php73 tagged failed on PHP 7.3.2

Trying to compile on PHP-FPM 7.3.2 the (memcache v4.0.1-php73 tagged version](https://github.com/websupport-sk/pecl-memcache/tree/v4.0.1-php73) . Prior to latest memcache 4.x commits, i had memcache 3.0.9 dev working on PHP 7.3.2 with the pull patch at #30. If i rollback to commit 4a9e4ab and apply the patch, memcache 3.0.9 compiles fine on PHP 7.3.2

on make this is error I get

make -j$(nproc)
/bin/sh /svr-setup/pecl-memcache-4.0.1-php73/libtool --mode=compile ccache gcc -I/usr/local/include/php -I. -I/svr-setup/pecl-memcache-4.0.1-php73 -DPHP_ATOM_INC -I/svr-setup/pecl-memcache-4.0.1-php73/include -I/svr-setup/pecl-memcache-4.0.1-php73/main -I/svr-setup/pecl-memcache-4.0.1-php73 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /svr-setup/pecl-memcache-4.0.1-php73/php7/memcache.c -o php7/memcache.lo 
/bin/sh /svr-setup/pecl-memcache-4.0.1-php73/libtool --mode=compile ccache gcc -I/usr/local/include/php -I. -I/svr-setup/pecl-memcache-4.0.1-php73 -DPHP_ATOM_INC -I/svr-setup/pecl-memcache-4.0.1-php73/include -I/svr-setup/pecl-memcache-4.0.1-php73/main -I/svr-setup/pecl-memcache-4.0.1-php73 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /svr-setup/pecl-memcache-4.0.1-php73/php7/memcache_pool.c -o php7/memcache_pool.lo 
mkdir php7/.libs
mkdir php7/.libs
mkdir: cannot create directory 'php7/.libs': File exists
 ccache gcc -I/usr/local/include/php -I. -I/svr-setup/pecl-memcache-4.0.1-php73 -DPHP_ATOM_INC -I/svr-setup/pecl-memcache-4.0.1-php73/include -I/svr-setup/pecl-memcache-4.0.1-php73/main -I/svr-setup/pecl-memcache-4.0.1-php73 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /svr-setup/pecl-memcache-4.0.1-php73/php7/memcache_pool.c  -fPIC -DPIC -o php7/.libs/memcache_pool.o
 ccache gcc -I/usr/local/include/php -I. -I/svr-setup/pecl-memcache-4.0.1-php73 -DPHP_ATOM_INC -I/svr-setup/pecl-memcache-4.0.1-php73/include -I/svr-setup/pecl-memcache-4.0.1-php73/main -I/svr-setup/pecl-memcache-4.0.1-php73 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /svr-setup/pecl-memcache-4.0.1-php73/php7/memcache.c  -fPIC -DPIC -o php7/.libs/memcache.o
/svr-setup/pecl-memcache-4.0.1-php73/php7/memcache_pool.c:1647:21: error: conflicting types for ‘mmc_prepare_key_ex’
 MMC_POOL_INLINE int mmc_prepare_key_ex(const char *key, unsigned int key_len, char *result, unsigned int *result_len, char *prefix)  /* {{{ */
                     ^
In file included from /svr-setup/pecl-memcache-4.0.1-php73/php7/memcache_pool.c:40:0:
/svr-setup/pecl-memcache-4.0.1-php73/php7/memcache_pool.h:399:5: note: previous declaration of ‘mmc_prepare_key_ex’ was here
 int mmc_prepare_key_ex(const char *, unsigned int, char *, unsigned int *);
     ^
make: *** [php7/memcache_pool.lo] Error 1
make: *** Waiting for unfinished jobs....
/svr-setup/pecl-memcache-4.0.1-php73/php7/memcache.c: In function ‘php_mmc_store’:
/svr-setup/pecl-memcache-4.0.1-php73/php7/memcache.c:643:4: error: too many arguments to function ‘mmc_prepare_key_ex’
    if (mmc_prepare_key_ex(ZSTR_VAL(key), ZSTR_LEN(key), request->key, &(request->key_len), MEMCACHE_G(key_prefix)) != MMC_OK) {
    ^
In file included from /svr-setup/pecl-memcache-4.0.1-php73/php7/php_memcache.h:34:0,
                 from /svr-setup/pecl-memcache-4.0.1-php73/php7/memcache.c:30:
/svr-setup/pecl-memcache-4.0.1-php73/php7/memcache_pool.h:399:5: note: declared here
 int mmc_prepare_key_ex(const char *, unsigned int, char *, unsigned int *);
     ^
make: *** [php7/memcache.lo] Error 1

system

  • CentOS 7.6 64bit
  • PHP-FPM 7.3.2
  • Centmin Mod 123.09beta01 LEMP stack

PHP 7.3.2 build info

php-config
Usage: /usr/local/bin/php-config [OPTION]
Options:
  --prefix            [/usr/local]
  --includes          [-I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib]
  --ldflags           [ -L/usr/local/lib64]
  --libs              [-lcrypt  -lc-client  -lzip -lzip -lz -lexslt -ltidy -largon2 -lresolv -lcrypt -lsodium -ledit -lncurses -laspell -lpspell -lrt -lldap -llber -lstdc++ -lcrypt -lpam -lgmp -lX11 -lXpm -lpng -lz -ljpeg -lwebp -lenchant -lbz2 -lz -lrt -lm -ldl -lnsl  -lsystemd -lxml2 -lz -lm -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -lcurl -lxml2 -lz -lm -ldl -lssl -lcrypto -lfreetype -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -licui18n -licuuc -licudata -licuio -lxml2 -lz -lm -ldl -lnetsnmp -lssl -lssl -lcrypto -lm -lxml2 -lz -lm -ldl -lcrypt -largon2 -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxslt -lxml2 -lz -ldl -lm -lssl -lcrypto -lcrypt ]
  --extension-dir     [/usr/local/lib/php/extensions/no-debug-non-zts-20180731]
  --include-dir       [/usr/local/include/php]
  --man-dir           [/usr/local/php/man]
  --php-binary        [/usr/local/bin/php]
  --php-sapis         [ cli embed fpm phpdbg cgi]
  --configure-options [--enable-fpm --enable-opcache --enable-intl --enable-pcntl --with-mcrypt --with-snmp --enable-embed=shared --with-mhash --with-zlib --with-gettext --enable-exif --enable-zip --with-libzip --with-bz2 --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --with-pear --enable-mbstring --with-openssl --with-mysql=mysqlnd --with-libdir=lib64 --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-curl --with-gd --with-xmlrpc --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr --with-webp-dir=/usr --with-t1lib=/usr --enable-pdo --with-pdo-sqlite --with-pdo-mysql=mysqlnd --enable-inline-optimization --with-imap --with-imap-ssl --with-kerberos --with-readline --with-libedit --with-gmp --with-pspell --with-tidy --with-enchant --with-fpm-user=nginx --with-fpm-group=nginx --with-ldap --with-ldap-sasl --with-password-argon2 --with-sodium --with-config-file-scan-dir=/etc/centminmod/php.d --with-fpm-systemd --with-xsl]
  --version           [7.3.2]
  --vernum            [70302]

Any official word on future plans for Memcache? PHP 7?

The README here is a few years old now, and some of the functions it describes are still not implemented as documented (in the Windows DLL of 3.0.8 at least).

3.0.8 has been in beta for 3 years I think. Now that we're making plans to move to PHP 7, we'd like some clarity please on whether this project should be considered dormant.

We're trying to decide whether to make plans to switch from this extension to Memcached, since that extension is actively working to be PHP 7 compatible. Any guidance would be welcome. We really don't want to switch unless we have to.

Using PHP 5.6.23 with Memcache 3.0.8 on Windows 7 (development) and CentOS 7 (production)

Memcache extension doesn't play nice with large MTU's?

Hi, i come across a very weird issue when i SET (GET is not affected) a key with long value for memcached via memcache plugin and loopback interface. Basically requests on remote hosts were 50-100 times faster than on loopback.

After doing some tests, i narrowed the problem to large MTU of loopback interface. So as you can see setting 3x30kb of data takes 80ms when connecting to memcache using TCP on localhost. It takes <1 ms when memcache is on remote machine.

screencast.com/t/bja6rafah

To fix the issue, we can do following:

  1. Set memcache.chunk_size to be larger than item size (which is probably pointless to use so large buffers).
    OR
  2. Lower the MTU on loopback to 1500 which is standard for other interfaces, as on picture below:

http://screencast.com/t/XGp2MtkbQIgn

The 65k MTU is probably there for a reason, so you think it could be some problem with memcache plugin's networking code?

I found some related info:
http://comments.gmane.org/gmane.comp.web.cache.memcached/1259
When the problem occur it's a whole lot slower, more like:
7168 bytes: 8680 set/s
8192 bytes: 25 set/s

UPDATE: Actually if you set MTU to
ifconfig lo mtu 32820 up
it's working ok with req time <1ms, after you increase just by 1 byte to 32821 - the requests start to take over 80ms.

Thanks,
Slawomir.

php8 windows build

Hi @tomassrnka!
Thanks for release 8.0 👍
Here is my current changes on commit 36d7181 for building on windows

diff --git a/src/memcache_binary_protocol.c b/src/memcache_binary_protocol.c
index 707b351..60d828f 100644
--- a/src/memcache_binary_protocol.c
+++ b/src/memcache_binary_protocol.c
@@ -26,7 +26,7 @@
 #define MMC_DEBUG 0
 
 #ifdef PHP_WIN32
-#include <win32/php_stdint.h>
+#include <main/php_stdint.h> 
 #include <winsock2.h>
 #else
 #include <stdint.h>
diff --git a/src/memcache_pool.h b/src/memcache_pool.h
index cb3d086..402372f 100644
--- a/src/memcache_pool.h
+++ b/src/memcache_pool.h
@@ -35,7 +35,7 @@
 #endif
 
 #ifdef PHP_WIN32
-#include <win32/php_stdint.h>
+#include <main/php_stdint.h> 
 #else
 #include <stdint.h>
 #endif
diff --git a/src/php_memcache.h b/src/php_memcache.h
index 4181849..4d1a89d 100644

Version 4.0.5.2 is still present in php_memcache.h

--- a/src/php_memcache.h
+++ b/src/php_memcache.h
@@ -67,7 +67,7 @@ PHP_FUNCTION(memcache_close);
 PHP_FUNCTION(memcache_flush);
 PHP_FUNCTION(memcache_set_sasl_auth_data);
 
-#define PHP_MEMCACHE_VERSION "4.0.5.2"
+#define PHP_MEMCACHE_VERSION "8.0"
 
 #define MMC_DEFAULT_TIMEOUT 1				/* seconds */
 #define MMC_DEFAULT_RETRY 15 				/* retry failed server after x seconds */

Note, I also generate $Revision$ string on my windows releases at build time like this:

diff --git "a/src/memcache.c" "b/src/memcache.c"
index f994c1b..7f71313 100644
--- "a/src/memcache.c"
+++ "b/src/memcache.c"
@@ -780,7 +780,7 @@ PHP_MINFO_FUNCTION(memcache)
 	php_info_print_table_start();
 	php_info_print_table_header(2, "memcache support", "enabled");
 	php_info_print_table_row(2, "Version", PHP_MEMCACHE_VERSION);
-	php_info_print_table_row(2, "Revision", "$Revision$");
+	php_info_print_table_row(2, "Revision", "b:NON_BLOCKING_IO_php8 v:8.0 c:36d7181 d:2020-12-06");
 	php_info_print_table_end();
 
 	DISPLAY_INI_ENTRIES();

Could you also move tag 8.0 on latest commit? (36d7181 not 1ae74d7)

Thanks in advance!

Compilation errors in php 8.0-dev due to removed macros.

  1. ZEND_ARG_PASS_INFO is a deprecated macro, ZEND_ARG_INFO(0, paramname) should probably be used instead. Also see #64
  2. TSRMLS_CC, TSRMLS_C, and TSRMLS_DC were no-op macros since php 7.0 was released, and can safely be taken out, I think
/tmp/pear/temp/memcache/php7/memcache.c:42:2: warning: implicit declaration of function ‘ZEND_ARG_PASS_INFO’ [-Wimplicit-function-declaration]
  ZEND_ARG_PASS_INFO(0)
  ^
/tmp/pear/temp/memcache/php7/memcache.c:42:2: error: initializer element is not constant
/tmp/pear/temp/memcache/php7/memcache.c:42:2: note: (near initialization for ‘arginfo_memcache_get[1].name’)
/tmp/pear/temp/memcache/php7/memcache.c:43:2: error: expected ‘}’ before ‘ZEND_ARG_PASS_INFO’
  ZEND_ARG_PASS_INFO(0)
  ^
/tmp/pear/temp/memcache/php7/memcache.c:49:2: error: initializer element is not constant
  ZEND_ARG_PASS_INFO(0)
  ^
/tmp/pear/temp/memcache/php7/memcache.c:49:2: note: (near initialization for ‘arginfo_memcache_object_get[1].name’)
/tmp/pear/temp/memcache/php7/memcache.c:50:2: error: expected ‘}’ before ‘ZEND_ARG_PASS_INFO’
  ZEND_ARG_PASS_INFO(1)
  ^
/tmp/pear/temp/memcache/php7/memcache.c: In function ‘OnUpdatePrefixStaticKey’:
/tmp/pear/temp/memcache/php7/memcache.c:272:27: error: expected ‘)’ before ‘TSRMLS_CC’
     php_error_docref(NULL TSRMLS_CC, E_WARNING, "memcache.session_prefix_static_key cannot have dot inside (.)");
                           ^
/tmp/pear/temp/memcache/php7/memcache.c:272:5: error: too few arguments to function ‘php_error_docref’
     php_error_docref(NULL TSRMLS_CC, E_WARNING, "memcache.session_prefix_static_key cannot have dot inside (.)");
     ^
In file included from /tmp/pear/temp/memcache/php7/memcache.c:26:0:
/home/tyson/php-8.0.0-dev-install-experiments/include/php/main/php.h:339:23: note: declared here
 PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format, ...)
                       ^
/tmp/pear/temp/memcache/php7/memcache.c: In function ‘zm_activate_memcache’:
/tmp/pear/temp/memcache/php7/memcache.c:461:58: error: ‘TSRMLS_C’ undeclared (first use in this function)
  MEMCACHE_G(session_key_prefix) = get_session_key_prefix(TSRMLS_C);
                                                          ^
/tmp/pear/temp/memcache/php7/memcache.c:461:58: note: each undeclared identifier is reported only once for each function it appears in
Makefile:209: recipe for target 'php7/memcache.lo' failed
make: *** [php7/memcache.lo] Error 1
ERROR: `make' failed

PHP 7.4.0-alpha1: 1 failed test - 040.phpt

PHP_VERSION : 7.4.0alpha1

TEST 45/77 [tests/040.phpt]
========DIFF========
003+ int(3)
004+ ["key1_abc"]=>
004- ["%s"]=>
005- int(3)
011+ int(2)
012+ ["key1_abc"]=>
014+ }
015+ array(2) {
017+ int(3)
018+ ["key1_abc"]=>
019- int(3)
021- array(2) {
022- ["%s"]=>
023- int(1)
024- ["%s"]=>
025- int(2)
026- }
025+ int(1)
========DONE========

Segmentation fault with php7.1

OS: CentOS Linux release 7.3.1611 (Core)

PHP: PHP 7.1.2

stack:

Core was generated by `php-fpm: pool www '.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f7a0efe92d3 in mmc_value_handler_multi (key=0x7ffff953bee0 "dao_key_pk_v2_1_user_db_seo_search_words_645574", key_len=47, value=0x7ffff953beb0, flags=1, cas=0, param=0x7ffff953c150) at /home/work/pecl-memcache-4.0.4/php7/memcache.c:1754
1754 /home/work/pecl-memcache-4.0.4/php7/memcache.c: No such file or directory.
Missing separate debuginfos, use: debuginfo-install bzip2-libs-1.0.6-13.el7.x86_64 cyrus-sasl-lib-2.1.26-20.el7_2.x86_64 expat-2.1.0-10.el7_3.x86_64 fontconfig-2.10.95-10.el7.x86_64 glibc-2.17-157.el7_3.1.x86_64 gmp-6.0.0-12.el7_1.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.14.1-27.el7_3.x86_64 libcom_err-1.42.9-9.el7.x86_64 libcurl-7.43.0-1.el7.x86_64 libgcc-4.8.5-11.el7.x86_64 libgcrypt-1.5.3-13.el7_3.1.x86_64 libgomp-4.8.5-11.el7.x86_64 libgpg-error-1.12-3.el7.x86_64 libidn-1.28-4.el7.x86_64 libselinux-2.5-6.el7.x86_64 libssh2-1.4.3-10.el7_2.1.x86_64 libstdc++-4.8.5-11.el7.x86_64 libxml2-2.9.1-6.el7_2.3.x86_64 nspr-4.11.0-1.el7_2.x86_64 nss-3.21.3-2.el7_3.x86_64 nss-softokn-freebl-3.16.2.3-14.4.el7.x86_64 nss-util-3.21.3-1.1.el7_3.x86_64 openldap-2.4.40-13.el7.x86_64 openssl-libs-1.0.1e-60.el7.x86_64 pcre-8.32-15.el7_2.1.x86_64 xz-libs-5.2.2-1.el7.x86_64 zlib-1.2.7-17.el7.x86_64
(gdb) bt
#0 0x00007f7a0efe92d3 in mmc_value_handler_multi (key=0x7ffff953bee0 "dao_key_pk_v2_1_user_db_seo_search_words_645574", key_len=47, value=0x7ffff953beb0, flags=1, cas=0, param=0x7ffff953c150) at /home/work/pecl-memcache-4.0.4/php7/memcache.c:1754
#1 0x00007f7a0efedb85 in mmc_unpack_value (mmc=mmc@entry=0x21b1840, request=request@entry=0x7f7a13ca8900, buffer=buffer@entry=0x7f7a13ca8928,
key=key@entry=0x7f7a13ca8ab8 "dao_key_pk_v2_1_user_db_seo_search_words_645574", key_len=47, flags=1, cas=0, bytes=bytes@entry=106)
at /home/work/pecl-memcache-4.0.4/php7/memcache_pool.c:500
#2 0x00007f7a0eff3aa2 in mmc_server_read_value (mmc=0x21b1840, request=0x7f7a13ca8900) at /home/work/pecl-memcache-4.0.4/php7/memcache_ascii_protocol.c:190
#3 0x00007f7a0efefb0c in mmc_pool_select (pool=pool@entry=0x7f79454eb500) at /home/work/pecl-memcache-4.0.4/php7/memcache_pool.c:1559
#4 0x00007f7a0eff06a8 in mmc_pool_run (pool=0x7f79454eb500) at /home/work/pecl-memcache-4.0.4/php7/memcache_pool.c:1645
#5 0x00007f7a0efea6f3 in php_mmc_store (execute_data=, return_value=0x7f7a13c14d50, op=1) at /home/work/pecl-memcache-4.0.4/php7/memcache.c:697 #6 0x00000000008bfb78 in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER () at /opt/px/php-7.1.2/Zend/zend_vm_execute.h:1097
#7 0x000000000086ef7b in execute_ex (ex=) at /opt/px/php-7.1.2/Zend/zend_vm_execute.h:429
#8 0x00000000008c1e04 in zend_execute (op_array=0x7f7a13c700e0, op_array@entry=0x7f794b188950, return_value=return_value@entry=0x7f7a13c14cb0)
at /opt/px/php-7.1.2/Zend/zend_vm_execute.h:474
#9 0x000000000082a454 in zend_execute_scripts (type=type@entry=8, retval=0x7f7a13c14cb0, retval@entry=0x0, file_count=file_count@entry=3)
at /opt/px/php-7.1.2/Zend/zend.c:1475
#10 0x00000000007cbe50 in php_execute_script (primary_file=primary_file@entry=0x7ffff953e620) at /opt/px/php-7.1.2/main/main.c:2537
#11 0x000000000044262c in main (argc=, argv=) at /opt/px/php-7.1.2/sapi/fpm/fpm/fpm_main.c:1966

Please follow semver and keep GitHub tags and PECL in sync

Thanks for picking up work again on this extension! Looking forward to people using it again and eventually making it available for users on Heroku :)

In the interest of transparency and trust in the project, I'd like to ask for the following process changes:

  • do not publish to PECL without a corresponding GitHub tag - this is important for trust (I can't see the source for that latest 4.0.5.2 tag on GitHub and easily verify what changed)
  • use strict semantic versioning for this project, meaning
    • no fourth part to the version - the recent 4.0.5.1 release with the version number mismatch in php_memcache.h should simply have been 4.0.6
    • 4.0.x for additional fixes
    • 4.1.0 for any additions to the API
    • 5.0.0 for any breakage
  • maintain a changelog that lists all changes, including stuff like those trivial version bumps that fixed the headers
  • remove the latest version mentions from README, it'll otherwise just always be stale

Keep up the good work, and happy holidays!

SEGV on php 7.0.7 / debian jessie 8.5

Hi!
Just have tried 'php7' branch with memcache extension on nginx / fpm / memcache v 1.4.21...
And unfortunately it didn't work.

[17-Jun-2016 05:50:02] NOTICE: fpm is running, pid 20837
[17-Jun-2016 05:50:02] NOTICE: ready to handle connections
[17-Jun-2016 05:50:02] NOTICE: systemd monitor interval set to 10000ms
[17-Jun-2016 05:50:33] WARNING: [pool www] child 20841 exited on signal 11 (SIGSEGV) after 30.785240 seconds from start
[17-Jun-2016 05:50:33] NOTICE: [pool www] child 20890 started
[17-Jun-2016 05:50:35] WARNING: [pool www] child 20840 exited on signal 11 (SIGSEGV) after 33.142703 seconds from start
[17-Jun-2016 05:50:35] NOTICE: [pool www] child 20891 started
[17-Jun-2016 05:50:36] WARNING: [pool www] child 20890 exited on signal 11 (SIGSEGV) after 3.093615 seconds from start
[17-Jun-2016 05:50:36] NOTICE: [pool www] child 20892 started
[17-Jun-2016 05:50:36] WARNING: [pool www] child 20891 exited on signal 11 (SIGSEGV) after 1.481995 seconds from start
[17-Jun-2016 05:50:36] NOTICE: [pool www] child 20893 started
[17-Jun-2016 05:50:37] WARNING: [pool www] child 20892 exited on signal 11 (SIGSEGV) after 1.509357 seconds from start
[17-Jun-2016 05:50:37] NOTICE: [pool www] child 20894 started

I didn't get if there are any open issues with this branch? Could the problem be on my side?
Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.