-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #78624: session_gc return value for user defined session handlers
- Loading branch information
Showing
4 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--TEST-- | ||
Test session_set_save_handler() : session_gc() returns the number of deleted records. | ||
--INI-- | ||
session.name=PHPSESSID | ||
session.save_handler=files | ||
--SKIPIF-- | ||
<?php include('skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
ob_start(); | ||
|
||
/* | ||
* Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) | ||
* Description : Sets user-level session storage functions | ||
* Source code : ext/session/session.c | ||
*/ | ||
|
||
echo "*** Test session_set_save_handler() : session_gc() returns the number of deleted records. ***\n"; | ||
|
||
class MySession implements SessionHandlerInterface { | ||
public function open($path, $name) { | ||
echo 'Open', "\n"; | ||
return true; | ||
} | ||
public function read($key) { | ||
echo 'Read ', session_id(), "\n"; | ||
return ''; | ||
} | ||
public function write($key, $data) { | ||
echo 'Write ', session_id(), "\n"; | ||
return true; | ||
} | ||
public function close() { | ||
echo 'Close ', session_id(), "\n"; | ||
return true; | ||
} | ||
public function destroy($key) { | ||
echo 'Destroy ', session_id(), "\n"; | ||
return true; | ||
} | ||
public function gc($ts) { | ||
echo 'Garbage collect', "\n"; | ||
return 1; | ||
} | ||
} | ||
|
||
$handler = new MySession; | ||
session_set_save_handler($handler); | ||
session_start(); | ||
var_dump(session_gc()); | ||
session_write_close(); | ||
|
||
--EXPECTF-- | ||
*** Test session_set_save_handler() : session_gc() returns the number of deleted records. *** | ||
Open | ||
Read %s | ||
Garbage collect | ||
int(1) | ||
Write %s | ||
Close %s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters