summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2021-03-19 17:05:32 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2021-03-19 17:05:32 +0100
commit64e589cab6fcc953f111d6da2a4c137f6f97d5f3 (patch)
tree87f641d0b445b434f821d14ca8247a375956be03 /ext
parent5fd2a5b13b6e0bb5261f1032056856c09649c5fa (diff)
parent2a1ed81ffcd50d493cfbabe2a155328081c6e6c8 (diff)
downloadphp-git-64e589cab6fcc953f111d6da2a4c137f6f97d5f3.tar.gz
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #80889: Cannot set save handler when save_handler is invalid
Diffstat (limited to 'ext')
-rw-r--r--ext/session/session.c2
-rw-r--r--ext/session/tests/bug80889.phpt37
2 files changed, 38 insertions, 1 deletions
diff --git a/ext/session/session.c b/ext/session/session.c
index f9d111768a..b2c05f04bd 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -2051,7 +2051,7 @@ PHP_FUNCTION(session_set_save_handler)
remove_user_shutdown_function("session_shutdown", sizeof("session_shutdown") - 1);
}
- if (PS(mod) && PS(session_status) != php_session_active && PS(mod) != &ps_mod_user) {
+ if (PS(session_status) != php_session_active && (!PS(mod) || PS(mod) != &ps_mod_user)) {
ini_name = zend_string_init("session.save_handler", sizeof("session.save_handler") - 1, 0);
ini_val = zend_string_init("user", sizeof("user") - 1, 0);
PS(set_handler) = 1;
diff --git a/ext/session/tests/bug80889.phpt b/ext/session/tests/bug80889.phpt
new file mode 100644
index 0000000000..78e1a6ab64
--- /dev/null
+++ b/ext/session/tests/bug80889.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Bug #80889 (Cannot set save handler when save_handler is invalid)
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--INI--
+session.save_handler=whatever
+--FILE--
+<?php
+class DummyHandler implements SessionHandlerInterface {
+ public function open($savePath, $sessionName) {
+ return true;
+ }
+ public function close() {
+ return true;
+ }
+ public function read($id) {
+ return '';
+ }
+ public function write($id, $data) {
+ return true;
+ }
+ public function destroy($id) {
+ return true;
+ }
+ public function gc($maxlifetime) {
+ return true;
+ }
+}
+
+$initHandler = ini_get('session.save_handler');
+session_set_save_handler(new DummyHandler());
+$setHandler = ini_get('session.save_handler');
+var_dump($initHandler, $setHandler);
+?>
+--EXPECT--
+string(8) "whatever"
+string(4) "user"