Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memcache extension can't read from memcached #23

Closed
nicolacontu opened this issue Apr 18, 2017 · 13 comments
Closed

Memcache extension can't read from memcached #23

nicolacontu opened this issue Apr 18, 2017 · 13 comments

Comments

@nicolacontu
Copy link

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

@tomassrnka
Copy link
Member

Hi, can you use memcache outside of the extension? We use the extension with PHP 7.1 without any problems.

@nicolacontu
Copy link
Author

nicolacontu commented Apr 19, 2017 via email

@klandaika
Copy link

klandaika commented May 23, 2017

Having same issue here when using native session handler via php.ini directives and calling session_start() on PHP 7.1.4 :

session.save_handler = memcache
session.save_path = 'tcp://host:11211'

However when using new Memcache() with addServer all object functions work as expected and I am able to read/write data to the server.

On PHP 7.0.17 and same configs session_start() works correctly with native session handler

I compile for windows, tried x86 and also as x64 with same results.

@krzaczek
Copy link

Same here

session_start(): Failed to read session data: memcache (path: tcp://127.0.0.1:11211)

PHP 7.1.7-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jul  7 2017 09:41:45) ( NTS )
Version => 3.0.9-dev

new Memcache() is working fine. Only session support is broken.

@tomassrnka

@ramsey
Copy link

ramsey commented Aug 16, 2017

I'm experiencing the same issue with PHP 7.1.7 and the latest commit of the memcache extension: e702b5f

Error message is the same:

session_start(): Failed to read session data: memcache (path: tcp://127.0.0.1:11211)

Has anyone found a work-around yet? I'm able to use the same version of the extension on PHP 7.0.x without any problems.

@nicolacontu
Copy link
Author

nicolacontu commented Aug 17, 2017 via email

ramsey added a commit to ramsey/pecl-memcache-issue-23 that referenced this issue Aug 17, 2017
@ramsey
Copy link

ramsey commented Aug 17, 2017

I was able to create a simple reproducible version of this, using Docker. The repository is here: /~https://github.com/ramsey/pecl-memcache-issue-23

To run it to see the session_start() warning:

git clone /~https://github.com/ramsey/pecl-memcache-issue-23
cd pecl-memcache-issue-23/
docker-compose up

Now, the two containers should be running, and you can open the following in your browser to verify:

To test the session_start() issue and see the warning, open the following:

See the repository for more information.

I hope this helps! 😄

@ramsey
Copy link

ramsey commented Sep 5, 2017

@tomassrnka, have you been able to take a look at my reproduction steps yet?

@Roze
Copy link

Roze commented Sep 7, 2017

Since the php 7+ session module now expects a string for a valid response the error appears when the memcache extension returns that the key doesn't exist for a fresh/uninitialised session.

For me kind of works (haven't fully tested though (for example with binary protocol)) this small change:

--- pecl-memcache-NON_BLOCKING_IO_php7/php7/memcache_session.c  2017-08-02 12:38:18.000000000 +0300
+++ pecl-memcache-NON_BLOCKING_IO_php7/php7/memcache_session.c   2017-09-06 15:40:59.101003326 +0300
@@ -289,7 +289,7 @@
                        ZVAL_NULL(&addresult);

                        /* third request fetches the data, data is only valid if either of the lock requests succeeded */
-                       ZVAL_NULL(&dataresult);
+                       ZVAL_EMPTY_STRING(&dataresult);

                        /* create requests */
                        if (php_mmc_session_read_request(pool, &zkey, lockparam, &addresult, dataparam, &lockrequest, &addrequest, &datarequest) != MMC_OK) {

@krzaczek
Copy link

@Roze yep that fixes the problem ... thx

@remicollet
Copy link
Contributor

@Roze could be better to open a pull request.

@nono303
Copy link

nono303 commented Jan 19, 2018

@remicollet Thanks for the patch!
Work fine on Windows.
dll build for 7.2.x VC15, x86 & X64 / TS & NTS available @ /~https://github.com/nono303/PHP7-memcache-dll

zjcjoaquin added a commit to zjcjoaquin/pecl-memcache that referenced this issue Dec 28, 2018
taomaree added a commit to taomaree/pecl-memcache that referenced this issue Jan 18, 2019
Fix websupport-sk#23 Failed to read session data with 7.1/7.2
thesource93 added a commit that referenced this issue Feb 27, 2019
Fix #23 Failed to read session data with 7.1/7.2
@JonathanFinch-awin
Copy link

I was getting the following error on PHP 7.2 with debian php-memcache 3.0.9:

Error #2 session_start(): Failed to read session data: memcache

I manually installed the latest php memcache version 4.0.4 in my dockerfile and this resolved the issue.

RUN apt-get install libz-dev \
&& cd /tmp \
&& wget -O "memcache-4.0.4.tar.gz" "/~https://github.com/websupport-sk/pecl-memcache/archive/4.0.4.tar.gz" \
&& tar -xvzf "memcache-4.0.4.tar.gz" \
&& cd "pecl-memcache-4.0.4" \
&& phpize \
&& ./configure \
&& make \
&& make install

Vancelot11 pushed a commit to iusrepo/php73-pecl-memcache that referenced this issue Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants