[Pkg-owncloud-commits] [owncloud] 01/23: keep session in sync

David Prévot taffit at moszumanska.debian.org
Tue Jul 22 15:21:34 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 0cde504e8084fe7b643386918d005932e900d682
Author: Jörn Friedrich Dreyer <jfd at butonic.de>
Date:   Thu Jul 17 13:03:56 2014 +0200

    keep session in sync
---
 lib/private/user/session.php | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/lib/private/user/session.php b/lib/private/user/session.php
index 8c9b3e2..3e0d7ab 100644
--- a/lib/private/user/session.php
+++ b/lib/private/user/session.php
@@ -89,9 +89,9 @@ class Session implements IUserSession, Emitter {
 	 */
 	public function setUser($user) {
 		if (is_null($user)) {
-			$this->session->remove('user_id');
+			$this->getSession()->remove('user_id');
 		} else {
-			$this->session->set('user_id', $user->getUID());
+			$this->getSession()->set('user_id', $user->getUID());
 		}
 		$this->activeUser = $user;
 	}
@@ -105,7 +105,7 @@ class Session implements IUserSession, Emitter {
 		if ($this->activeUser) {
 			return $this->activeUser;
 		} else {
-			$uid = $this->session->get('user_id');
+			$uid = $this->getSession()->get('user_id');
 			if ($uid) {
 				$this->activeUser = $this->manager->get($uid);
 				return $this->activeUser;
@@ -122,9 +122,9 @@ class Session implements IUserSession, Emitter {
 	 */
 	public function setLoginName($loginName) {
 		if (is_null($loginName)) {
-			$this->session->remove('loginname');
+			$this->getSession()->remove('loginname');
 		} else {
-			$this->session->set('loginname', $loginName);
+			$this->getSession()->set('loginname', $loginName);
 		}
 	}
 
@@ -135,12 +135,12 @@ class Session implements IUserSession, Emitter {
 	 */
 	public function getLoginName() {
 		if ($this->activeUser) {
-			return $this->session->get('loginname');
+			return $this->getSession()->get('loginname');
 		} else {
-			$uid = $this->session->get('user_id');
+			$uid = $this->getSession()->get('user_id');
 			if ($uid) {
 				$this->activeUser = $this->manager->get($uid);
-				return $this->session->get('loginname');
+				return $this->getSession()->get('loginname');
 			} else {
 				return null;
 			}
@@ -246,4 +246,21 @@ class Session implements IUserSession, Emitter {
 		setcookie('oc_token', '', time()-3600, \OC::$WEBROOT . '/');
 		setcookie('oc_remember_login', '', time()-3600, \OC::$WEBROOT . '/');
 	}
+
+	/**
+	 * will keep the session instance in sync with \OC::$session
+	 * @return \OC\Session\Session
+	 */
+	private function getSession() {
+		//keep $this->session in sync with \OC::$session
+		if ($this->session !== \OC::$session) {
+			\OC::$server->getLogger()->debug(
+				'\OC::$session has been replaced with a new instance. '.
+				'Closing and replacing session in UserSession instance.'
+			);
+			$this->session->close();
+			$this->session = \OC::$session;
+		}
+		return $this->session;
+	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list