Merge "Expand release notes for Iab02cbd4"
[lhc/web/wiklou.git] / includes / Wiki.php
index 48e56ab..50bba7b 100644 (file)
@@ -302,13 +302,6 @@ class MediaWiki {
                        $article = $this->initializeArticle();
                        if ( is_object( $article ) ) {
                                $pageView = true;
-                               /**
-                                * $wgArticle is deprecated, do not use it.
-                                * @deprecated since 1.18
-                                */
-                               global $wgArticle;
-                               $wgArticle = new DeprecatedGlobal( 'wgArticle', $article, '1.18' );
-
                                $this->performAction( $article, $requestTitle );
                        } elseif ( is_string( $article ) ) {
                                $output->redirect( $article );
@@ -511,9 +504,31 @@ class MediaWiki {
 
                $request = $this->context->getRequest();
 
+               // Send Ajax requests to the Ajax dispatcher.
+               if ( $wgUseAjax && $request->getVal( 'action', 'view' ) == 'ajax' ) {
+
+                       // Set a dummy title, because $wgTitle == null might break things
+                       $title = Title::makeTitle( NS_MAIN, 'AJAX' );
+                       $this->context->setTitle( $title );
+                       $wgTitle = $title;
+
+                       $dispatcher = new AjaxDispatcher();
+                       $dispatcher->performAction();
+                       wfProfileOut( __METHOD__ );
+                       return;
+               }
+
+               // Get title from request parameters,
+               // is set on the fly by parseTitle the first time.
+               $title = $this->getTitle();
+               $action = $this->getAction();
+               $wgTitle = $title;
+
                // If the user has forceHTTPS set to true, or if the user
                // is in a group requiring HTTPS, or if they have the HTTPS
                // preference set, redirect them to HTTPS.
+               // Note: Do this after $wgTitle is setup, otherwise the hooks run from
+               // isLoggedIn() will do all sorts of weird stuff.
                if (
                        (
                                $request->getCookie( 'forceHTTPS', '' ) ||
@@ -525,7 +540,7 @@ class MediaWiki {
                                        && $this->context->getUser()->requiresHTTPS()
                                )
                        ) &&
-                       $request->detectProtocol() == 'http'
+                       $request->getProtocol() == 'http'
                ) {
                        $oldUrl = $request->getFullRequestURL();
                        $redirUrl = str_replace( 'http://', 'https://', $oldUrl );
@@ -554,26 +569,6 @@ class MediaWiki {
                        return;
                }
 
-               // Send Ajax requests to the Ajax dispatcher.
-               if ( $wgUseAjax && $request->getVal( 'action', 'view' ) == 'ajax' ) {
-
-                       // Set a dummy title, because $wgTitle == null might break things
-                       $title = Title::makeTitle( NS_MAIN, 'AJAX' );
-                       $this->context->setTitle( $title );
-                       $wgTitle = $title;
-
-                       $dispatcher = new AjaxDispatcher();
-                       $dispatcher->performAction();
-                       wfProfileOut( __METHOD__ );
-                       return;
-               }
-
-               // Get title from request parameters,
-               // is set on the fly by parseTitle the first time.
-               $title = $this->getTitle();
-               $action = $this->getAction();
-               $wgTitle = $title;
-
                if ( $wgUseFileCache && $title->getNamespace() >= 0 ) {
                        wfProfileIn( 'main-try-filecache' );
                        if ( HTMLFileCache::useFileCache( $this->context ) ) {
@@ -586,6 +581,7 @@ class MediaWiki {
                                                $cache->loadFromFileCache( $this->context );
                                        }
                                        // Do any stats increment/watchlist stuff
+                                       // Assume we're viewing the latest revision (this should always be the case with file cache)
                                        $this->context->getWikiPage()->doViewUpdates( $this->context->getUser() );
                                        // Tell OutputPage that output is taken care of
                                        $this->context->getOutput()->disable();
@@ -685,7 +681,7 @@ class MediaWiki {
                                // We don't want exceptions thrown during job execution to
                                // be reported to the user since the output is already sent.
                                // Instead we just log them.
-                               wfDebugLog( 'exception', $e->getLogMessage() );
+                               MWExceptionHandler::logException( $e );
                        }
                }
        }