From a36bf5c2b5430eb4bcbabead92c9d2c1a669b035 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 9 Dec 2013 12:38:27 +0100 Subject: [PATCH 1/2] preserve 3rd party values in in the Session destructor --- lib/private/session/internal.php | 11 ++++++++++- lib/private/session/memory.php | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/private/session/internal.php b/lib/private/session/internal.php index 60aecccc8aa..49b52b5c796 100644 --- a/lib/private/session/internal.php +++ b/lib/private/session/internal.php @@ -26,10 +26,19 @@ class Internal extends Memory { } public function __destruct() { - $_SESSION = $this->data; + $_SESSION = array_merge($_SESSION, $this->data); session_write_close(); } + /** + * @param string $key + */ + public function remove($key) { + // also remove it from $_SESSION to prevent re-setting the old value during the merge + unset($_SESSION[$key]); + parent::remove($key); + } + public function clear() { session_unset(); @session_regenerate_id(true); diff --git a/lib/private/session/memory.php b/lib/private/session/memory.php index c148ff4b9b9..134cee582ed 100644 --- a/lib/private/session/memory.php +++ b/lib/private/session/memory.php @@ -11,7 +11,7 @@ namespace OC\Session; /** * Class Internal * - * store session data in an in-memory array, not persistance + * store session data in an in-memory array, not persistent * * @package OC\Session */ From 5c7a08aab45a7f24086066549e1992f3dc2fdde6 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 11 Dec 2013 12:59:48 +0100 Subject: [PATCH 2/2] check if a $_SESSION entry exists before we try to remove it --- lib/private/session/internal.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/private/session/internal.php b/lib/private/session/internal.php index 49b52b5c796..a7c9e2fdefd 100644 --- a/lib/private/session/internal.php +++ b/lib/private/session/internal.php @@ -35,7 +35,9 @@ class Internal extends Memory { */ public function remove($key) { // also remove it from $_SESSION to prevent re-setting the old value during the merge - unset($_SESSION[$key]); + if (isset($_SESSION[$key])) { + unset($_SESSION[$key]); + } parent::remove($key); }