File tree 1 file changed +51
-0
lines changed
ext/session/tests/user_session_module
1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Test SessionHandler with serialization failure locks session
3
+ --EXTENSIONS--
4
+ session
5
+ --SKIPIF--
6
+ <?php if (!is_dir ('/proc/self/fd ' )) die ('skip /proc/self/fd does not exist ' );
7
+ --FILE --
8
+ <?php
9
+
10
+ $ savePath = __DIR__ ;
11
+
12
+ session_set_save_handler (new \SessionHandler (), true );
13
+
14
+ session_start ([
15
+ 'save_path ' => $ savePath ,
16
+ ]);
17
+
18
+ $ sessionFile = $ savePath .'/sess_ ' .session_id ();
19
+
20
+ $ _SESSION ['test ' ] = function () {};
21
+
22
+ try {
23
+ session_write_close ();
24
+ } catch (\Throwable $ e ) {
25
+ echo $ e ->getMessage (), "\n" ;
26
+ }
27
+
28
+ // At this point the session handler should have closed the file handle, unlocking
29
+ // the session for the next request.
30
+
31
+ $ dir = '/proc/self/fd/ ' ;
32
+ $ h = opendir ($ dir );
33
+
34
+ while (false !== $ entry = readdir ($ h )) {
35
+ $ target = realpath ($ dir .$ entry );
36
+
37
+ if ($ target === $ sessionFile ) {
38
+ echo "Fail session ` {$ sessionFile }` is still open \n" ;
39
+ @unlink ($ sessionFile );
40
+
41
+ return ;
42
+ }
43
+ }
44
+
45
+ echo "Passed \n" ;
46
+ @unlink ($ sessionFile );
47
+
48
+ ?>
49
+ --EXPECT--
50
+ Serialization of 'Closure' is not allowed
51
+ Passed
You can’t perform that action at this time.
0 commit comments