Merge "Improve how slashes are stripped from filenames"
[lhc/web/wiklou.git] / includes / session / SessionBackend.php
index 1e2b476..264e1ae 100644 (file)
@@ -31,7 +31,7 @@ use WebRequest;
 /**
  * This is the actual workhorse for Session.
  *
- * Most code does not need to use this class, you want \\MediaWiki\\Session\\Session.
+ * Most code does not need to use this class, you want \MediaWiki\Session\Session.
  * The exceptions are SessionProviders and SessionMetadata hook functions,
  * which get an instance of this class rather than Session.
  *
@@ -94,6 +94,8 @@ final class SessionBackend {
        private $usePhpSessionHandling = true;
        private $checkPHPSessionRecursionGuard = false;
 
+       private $shutdown = false;
+
        /**
         * @param SessionId $id Session ID object
         * @param SessionInfo $info Session info to populate from
@@ -176,17 +178,26 @@ final class SessionBackend {
 
        /**
         * Deregister a Session
-        * @private For use by \\MediaWiki\\Session\\Session::__destruct() only
+        * @private For use by \MediaWiki\Session\Session::__destruct() only
         * @param int $index
         */
        public function deregisterSession( $index ) {
                unset( $this->requests[$index] );
-               if ( !count( $this->requests ) ) {
+               if ( !$this->shutdown && !count( $this->requests ) ) {
                        $this->save( true );
                        $this->provider->getManager()->deregisterSessionBackend( $this );
                }
        }
 
+       /**
+        * Shut down a session
+        * @private For use by \MediaWiki\Session\SessionManager::shutdown() only
+        */
+       public function shutdown() {
+               $this->save( true );
+               $this->shutdown = true;
+       }
+
        /**
         * Returns the session ID.
         * @return string
@@ -498,7 +509,7 @@ final class SessionBackend {
         * Note the caller is responsible for calling $this->dirty() if anything in
         * the array is changed.
         *
-        * @private For use by \\MediaWiki\\Session\\Session only.
+        * @private For use by \MediaWiki\Session\Session only.
         * @return array
         */
        public function &getData() {
@@ -530,7 +541,7 @@ final class SessionBackend {
 
        /**
         * Mark data as dirty
-        * @private For use by \\MediaWiki\\Session\\Session only.
+        * @private For use by \MediaWiki\Session\Session only.
         */
        public function dirty() {
                $this->dataDirty = true;