From 47c269ead37c5f0a2f71cb5c505571786694d36c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 10 Apr 2016 19:20:39 +0200 Subject: [PATCH] Resolved some session/cookie-related issues --- com.woltlab.wcf/option.xml | 2 +- .../lib/data/acp/session/ACPSession.class.php | 2 +- .../files/lib/system/WCFSetup.class.php | 2 +- .../system/session/SessionHandler.class.php | 23 ++++++++++++------- wcfsetup/install/files/options.inc.php | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/com.woltlab.wcf/option.xml b/com.woltlab.wcf/option.xml index 9c65f88687..55d77cf867 100644 --- a/com.woltlab.wcf/option.xml +++ b/com.woltlab.wcf/option.xml @@ -519,7 +519,7 @@ private:wcf.acp.option.exception_privacy.private]]> diff --git a/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php b/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php index 06e3b69e46..78383a3f78 100644 --- a/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php @@ -59,7 +59,7 @@ class ACPSession extends DatabaseObject { * @return boolean */ public static function supportsVirtualSessions() { - return false; + return true; } /** diff --git a/wcfsetup/install/files/lib/system/WCFSetup.class.php b/wcfsetup/install/files/lib/system/WCFSetup.class.php index fd2241ff21..c2c8786b86 100644 --- a/wcfsetup/install/files/lib/system/WCFSetup.class.php +++ b/wcfsetup/install/files/lib/system/WCFSetup.class.php @@ -1223,7 +1223,7 @@ class WCFSetup extends WCF { } // login as admin - define('COOKIE_PREFIX', 'wcf2_'); + define('COOKIE_PREFIX', 'wcf22_'); $factory = new ACPSessionFactory(); $factory->load(); diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index 7b3823d548..62a713c4c2 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -67,6 +67,12 @@ class SessionHandler extends SingletonFactory { */ protected $hasValidCookie = false; + /** + * true if within ACP or WCFSetup + * @var boolean + */ + protected $isACP = false; + /** * language id for active user * @var integer @@ -163,6 +169,7 @@ class SessionHandler extends SingletonFactory { * @see \wcf\system\SingletonFactory::init() */ protected function init() { + $this->isACP = (class_exists(WCFACP::class, false) || !PACKAGE_ID); $this->usersOnlyPermissions = UserGroupOptionCacheBuilder::getInstance()->getData(array(), 'usersOnlyOptions'); } @@ -397,7 +404,7 @@ class SessionHandler extends SingletonFactory { } $this->user = new User($this->session->userID); - if (class_exists(WCFACP::class, false)) { + if ($this->isACP) { $this->virtualSession = ACPSessionVirtual::getExistingSession($sessionID); } else { @@ -425,7 +432,7 @@ class SessionHandler extends SingletonFactory { protected function loadVirtualSession($forceReload = false) { if ($this->virtualSession === null || $forceReload) { $this->virtualSession = null; - if (class_exists(WCFACP::class, false)) { + if ($this->isACP) { $virtualSessionAction = new ACPSessionVirtualAction(array(), 'create', array('data' => array('sessionID' => $this->session->sessionID))); } else { @@ -440,7 +447,7 @@ class SessionHandler extends SingletonFactory { // MySQL error 23000 = unique key // do not check against the message itself, some weird systems localize them if ($e->getCode() == 23000) { - if (class_exists(WCFACP::class, false)) { + if ($this->isACP) { $this->virtualSession = ACPSessionVirtual::getExistingSession($this->session->sessionID); } else { @@ -730,7 +737,7 @@ class SessionHandler extends SingletonFactory { case 0: // delete virtual session if ($this->virtualSession) { - if (class_exists(WCFACP::class, false)) { + if ($this->isACP) { $virtualSessionEditor = new ACPSessionVirtualEditor($this->virtualSession); } else { @@ -739,7 +746,7 @@ class SessionHandler extends SingletonFactory { $virtualSessionEditor->delete(); } - if (class_exists(WCFACP::class, false)) { + if ($this->isACP) { $sessionCount = ACPSessionVirtual::countVirtualSessions($this->session->sessionID); } else { @@ -864,7 +871,7 @@ class SessionHandler extends SingletonFactory { $sessionEditor->update($data); if ($this->virtualSession instanceof ACPSessionVirtual) { - if (class_exists(WCFACP::class, false)) { + if ($this->isACP) { $virtualSessionEditor = new ACPSessionVirtualEditor($this->virtualSession); } else { @@ -894,7 +901,7 @@ class SessionHandler extends SingletonFactory { )); if ($this->virtualSession instanceof ACPSessionVirtual) { - if (class_exists(WCFACP::class, false)) { + if ($this->isACP) { $virtualSessionEditor = new ACPSessionVirtualEditor($this->virtualSession); } else { @@ -913,7 +920,7 @@ class SessionHandler extends SingletonFactory { self::resetSessions(array($this->user->userID)); // update last activity time - if (!class_exists(WCFACP::class, false)) { + if (!$this->isACP) { $editor = new UserEditor($this->user); $editor->update(array('lastActivityTime' => TIME_NOW)); } diff --git a/wcfsetup/install/files/options.inc.php b/wcfsetup/install/files/options.inc.php index d4d68b4ebc..857f96f69c 100644 --- a/wcfsetup/install/files/options.inc.php +++ b/wcfsetup/install/files/options.inc.php @@ -8,7 +8,7 @@ */ define('LAST_UPDATE_TIME', TIME_NOW); -define('COOKIE_PREFIX', 'wcf2_'); +define('COOKIE_PREFIX', 'wcf22_'); define('COOKIE_PATH', ''); define('COOKIE_DOMAIN', ''); -- 2.20.1