summaryrefslogtreecommitdiffstats
path: root/45.patch
diff options
context:
space:
mode:
Diffstat (limited to '45.patch')
-rw-r--r--45.patch114
1 files changed, 114 insertions, 0 deletions
diff --git a/45.patch b/45.patch
new file mode 100644
index 0000000..3e7e196
--- /dev/null
+++ b/45.patch
@@ -0,0 +1,114 @@
+From fd0cc8c9b0171a36116917332acc9f479e45ec81 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Tue, 19 Mar 2019 11:12:37 +0100
+Subject: [PATCH] allow to work with standard session.save_path option and
+ session_save_path function
+
+---
+ php7/memcache_session.c | 8 +++--
+ tests/036b.phpt | 70 +++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 76 insertions(+), 2 deletions(-)
+ create mode 100644 tests/036b.phpt
+
+diff --git a/php7/memcache_session.c b/php7/memcache_session.c
+index 7807942..4cc356d 100644
+--- a/php7/memcache_session.c
++++ b/php7/memcache_session.c
+@@ -56,7 +56,12 @@ PS_OPEN_FUNC(memcache)
+ zval params, *param;
+ int i, j, path_len;
+
+- char *path = MEMCACHE_G(session_save_path);
++ const char *path = MEMCACHE_G(session_save_path);
++ if (!path) {
++ /* allow to work with standard session.save_path option
++ and session_save_path function */
++ path = save_path;
++ }
+ if (!path) {
+ PS_SET_MOD_DATA(NULL);
+ return FAILURE;
+@@ -98,7 +103,6 @@ PS_OPEN_FUNC(memcache)
+ if (!url) {
+ php_error_docref(NULL, E_WARNING,
+ "Failed to parse memcache.save_path (error at offset %d, url was '%s')", i, path);
+- efree(path);
+
+ mmc_pool_free(pool);
+ PS_SET_MOD_DATA(NULL);
+diff --git a/tests/036b.phpt b/tests/036b.phpt
+new file mode 100644
+index 0000000..858807a
+--- /dev/null
++++ b/tests/036b.phpt
+@@ -0,0 +1,70 @@
++--TEST--
++ini_set('session.save_path')
++--SKIPIF--
++<?php include 'connect.inc'; if (!MEMCACHE_HAVE_SESSION) print 'skip not compiled with session support'; ?>
++--FILE--
++<?php
++
++include 'connect.inc';
++
++$session_save_path = "tcp://$host:$port?persistent=1&udp_port=0&weight=2&timeout=2&retry_interval=10,tcp://$host2:$port2";
++ini_set('session.save_handler', 'memcache');
++session_save_path($session_save_path);
++
++
++$result1 = session_start();
++$id = session_id();
++
++$_SESSION['_test_key'] = 'Test';
++
++$result2 = $memcache->get($id);
++session_write_close();
++$result3 = $memcache->get($id);
++
++// Test destroy
++$result4 = session_start();
++$result5 = session_destroy();
++$result6 = $memcache->get($id);
++
++// Test large session
++$session_save_path = "tcp://$host:$port";
++session_save_path($session_save_path);
++
++session_start();
++$largeval = str_repeat('a', 1024*2048);
++$_SESSION['_test_key']= $largeval;
++session_write_close();
++
++// test large cookie lifetime
++ini_set('session.gc_maxlifetime', 1209600);
++$result7 = session_start();
++$id = session_id();
++$_SESSION['_test_key'] = 'Test';
++$result8 = $memcache->get($id);
++session_write_close();
++$result9 = $memcache->get($id);
++
++
++var_dump($result1);
++var_dump($id);
++var_dump($result2);
++var_dump($result3);
++var_dump($result4);
++var_dump($result5);
++var_dump($result6);
++var_dump($result7);
++var_dump($result8);
++var_dump($result9);
++
++?>
++--EXPECTF--
++bool(true)
++string(%d) "%s"
++bool(false)
++string(%d) "%s"
++bool(true)
++bool(true)
++bool(false)
++bool(true)
++string(%d) "%s"
++string(%d) "%s"