summaryrefslogtreecommitdiffstats
path: root/lib/private/user
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-07-16 19:40:22 +0200
committerRobin Appelman <icewind@owncloud.com>2014-08-29 10:22:21 +0200
commitf551917a3ca2cedf748337646ed4b1d398ac8437 (patch)
treeeccf53eb77c44019ef59e90c41af43297993ddf9 /lib/private/user
parented2424c3822a3470065788ff113a3807d24d80dc (diff)
downloadnextcloud-server-f551917a3ca2cedf748337646ed4b1d398ac8437.tar.gz
nextcloud-server-f551917a3ca2cedf748337646ed4b1d398ac8437.zip
kill OC::$session
maintain deprecated \OC::$session when getting or setting the session via the server container or UserSession restore order os OC::$session and OC::$CLI remove unneded initialization of dummy session write back session when $useCustomSession is true log warning when deprecated app is used
Diffstat (limited to 'lib/private/user')
-rw-r--r--lib/private/user/session.php44
1 files changed, 41 insertions, 3 deletions
diff --git a/lib/private/user/session.php b/lib/private/user/session.php
index 6abf8fb80d2..11938db5076 100644
--- a/lib/private/user/session.php
+++ b/lib/private/user/session.php
@@ -47,10 +47,10 @@ class Session implements IUserSession, Emitter {
protected $activeUser;
/**
- * @param \OC\User\Manager $manager
- * @param \OC\Session\Session $session
+ * @param \OCP\IUserManager $manager
+ * @param \OCP\ISession $session
*/
- public function __construct($manager, $session) {
+ public function __construct(\OCP\IUserManager $manager, \OCP\ISession $session) {
$this->manager = $manager;
$this->session = $session;
}
@@ -83,6 +83,44 @@ class Session implements IUserSession, Emitter {
}
/**
+ * get the session object
+ *
+ * @return \OCP\ISession
+ */
+ public function getSession() {
+ // fetch the deprecated \OC::$session if it changed for backwards compatibility
+ if (isset(\OC::$session) && \OC::$session !== $this->session) {
+ \OC::$server->getLogger()->warning(
+ 'One of your installed apps still seems to use the deprecated '.
+ '\OC::$session and has replaced it with a new instance. Please file a bug against it.'.
+ 'Closing and replacing session in UserSession instance.'
+ );
+ $this->setSession(\OC::$session);
+ }
+ return $this->session;
+ }
+
+ /**
+ * set the session object
+ *
+ * @param \OCP\ISession $session
+ */
+ public function setSession(\OCP\ISession $session) {
+ if ($this->session instanceof \OCP\ISession) {
+ $this->session->close();
+ }
+ $this->session = $session;
+
+ // maintain deprecated \OC::$session
+ if (\OC::$session !== $this->session) {
+ if (\OC::$session instanceof \OCP\ISession) {
+ \OC::$session->close();
+ }
+ \OC::$session = $session;
+ }
+ }
+
+ /**
* set the currently active user
*
* @param \OC\User\User|null $user