1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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"
|