Resolved some session/cookie-related issues
authorAlexander Ebert <ebert@woltlab.com>
Sun, 10 Apr 2016 17:20:39 +0000 (19:20 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 10 Apr 2016 17:20:46 +0000 (19:20 +0200)
com.woltlab.wcf/option.xml
wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php
wcfsetup/install/files/lib/system/WCFSetup.class.php
wcfsetup/install/files/lib/system/session/SessionHandler.class.php
wcfsetup/install/files/options.inc.php

index 9c65f886878248fc2ed2981e0afe993e6894d45f..55d77cf8672d4506349508603dea625638104b37 100644 (file)
@@ -519,7 +519,7 @@ private:wcf.acp.option.exception_privacy.private]]></selectoptions>
                        <option name="cookie_prefix">
                                <categoryname>general.system.cookie</categoryname>
                                <optiontype>text</optiontype>
-                               <defaultvalue>wcf21_</defaultvalue>
+                               <defaultvalue>wcf22_</defaultvalue>
                                <validationpattern>.+</validationpattern>
                        </option>
                        <!-- /general.system.cookie-->
index 06e3b69e46abfe40118d7ea34770aff21ab26d58..78383a3f78b1685018d6ad11aae543739f0f0016 100644 (file)
@@ -59,7 +59,7 @@ class ACPSession extends DatabaseObject {
         * @return      boolean
         */
        public static function supportsVirtualSessions() {
-               return false;
+               return true;
        }
        
        /**
index fd2241ff21de036f43629018b71675318c8a8e31..c2c8786b86ad7dfff9b0b0fcf4dafcbbd35efb3d 100644 (file)
@@ -1223,7 +1223,7 @@ class WCFSetup extends WCF {
                }
                
                // login as admin
-               define('COOKIE_PREFIX', 'wcf2_');
+               define('COOKIE_PREFIX', 'wcf22_');
                
                $factory = new ACPSessionFactory();
                $factory->load();
index 7b3823d5482c982e6d767da3208c3d205f8565a1..62a713c4c2eb0e540e48d550d719e409f2afb38a 100644 (file)
@@ -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));
                        }
index d4d68b4ebc0ae7feb6674d83d577f905d0588748..857f96f69cef33047a095a4549e150ee0ade2427 100644 (file)
@@ -8,7 +8,7 @@
  */
 define('LAST_UPDATE_TIME', TIME_NOW);
 
-define('COOKIE_PREFIX', 'wcf2_');
+define('COOKIE_PREFIX', 'wcf22_');
 define('COOKIE_PATH', '');
 define('COOKIE_DOMAIN', '');