Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-03-10 17:21:12 +0400
committerThomas Müller <thomas.mueller@tmit.eu>2014-03-10 17:21:12 +0400
commit73a1ece7533b9d90305e11052947809b91850184 (patch)
treeef77e774fe93694559cdd8642ddc5b821c3090ba /lib/private/session
parent0ffd32a1ae8c4b9da2434a0b5623c1fe6e910467 (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.php2
-rw-r--r--lib/private/session/memory.php8
-rw-r--r--lib/private/session/session.php6
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;
+ }
}