diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-03-10 17:21:12 +0400 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-03-10 17:21:12 +0400 |
commit | 73a1ece7533b9d90305e11052947809b91850184 (patch) | |
tree | ef77e774fe93694559cdd8642ddc5b821c3090ba /lib/private/session | |
parent | 0ffd32a1ae8c4b9da2434a0b5623c1fe6e910467 (diff) |
adding an explicit close method to class session - write operations (set and remove) being called after close() will throw an exception
Diffstat (limited to 'lib/private/session')
-rw-r--r-- | lib/private/session/internal.php | 2 | ||||
-rw-r--r-- | lib/private/session/memory.php | 8 | ||||
-rw-r--r-- | lib/private/session/session.php | 6 |
3 files changed, 15 insertions, 1 deletions
diff --git a/lib/private/session/internal.php b/lib/private/session/internal.php index a7c9e2fdefd..d589932d425 100644 --- a/lib/private/session/internal.php +++ b/lib/private/session/internal.php @@ -27,7 +27,7 @@ class Internal extends Memory { public function __destruct() { $_SESSION = array_merge($_SESSION, $this->data); - session_write_close(); + \OC::$session->close(); } /** diff --git a/lib/private/session/memory.php b/lib/private/session/memory.php index 1b9ac452575..1562c2ce037 100644 --- a/lib/private/session/memory.php +++ b/lib/private/session/memory.php @@ -28,6 +28,7 @@ class Memory extends Session { * @param integer $value */ public function set($key, $value) { + $this->validateSession(); $this->data[$key] = $value; } @@ -54,10 +55,17 @@ class Memory extends Session { * @param string $key */ public function remove($key) { + $this->validateSession(); unset($this->data[$key]); } public function clear() { $this->data = array(); } + + private function validateSession() { + if ($this->sessionClosed) { + throw new \Exception('Session has been closed - no further changes to the session as allowed'); + } + } } diff --git a/lib/private/session/session.php b/lib/private/session/session.php index fe160faa267..5c18f3e495d 100644 --- a/lib/private/session/session.php +++ b/lib/private/session/session.php @@ -49,4 +49,10 @@ abstract class Session implements \ArrayAccess, ISession { public function offsetUnset($offset) { $this->remove($offset); } + + protected $sessionClosed = false; + + public function close() { + $this->sessionClosed = true; + } } |