Prevent "Failed to create..." warnings when session loading fails
authorGergő Tisza <tgr.huwiki@gmail.com>
Wed, 2 Mar 2016 23:36:02 +0000 (15:36 -0800)
committerGergő Tisza <tgr.huwiki@gmail.com>
Wed, 2 Mar 2016 23:36:02 +0000 (15:36 -0800)
If there is an existing session for a given ID but loading it fails,
there is no point in trying to create a new empty session with that
ID. Just fail silently (the reason for not loading the session
should be logged elsewhere), don't spam the logs and don't slow
down execution by throwing and catching an exception.

Change-Id: I8299872cc29c32cb245686ed0bca6b9a5902cdc1

includes/session/SessionManager.php

index 58f995f..81f8243 100644 (file)
@@ -202,6 +202,7 @@ final class SessionManager implements SessionManagerInterface {
                // of "no such ID"
                $key = wfMemcKey( 'MWSession', $id );
                if ( is_array( $this->store->get( $key ) ) ) {
+                       $create = false;
                        $info = new SessionInfo( SessionInfo::MIN_PRIORITY, [ 'id' => $id, 'idIsSafe' => true ] );
                        if ( $this->loadSessionInfoFromStore( $info, $request ) ) {
                                $session = $this->getSessionFromInfo( $info, $request );