From 0adbbacb0ad94ca14c8bf96df2fdcd0f153e8f6e Mon Sep 17 00:00:00 2001 From: csteipp Date: Mon, 7 Oct 2013 12:47:43 -0700 Subject: [PATCH] Move forceHTTPS check until after wgTitle is setup Since the forceHTTPS logic checks if the user is logged in, which calls all sorts of hooks, some that assume that $wgTitle is setup (like AbuseFilter for preventing autocreation of usernames), move the logic down a few lines. Bug: 55435 Bug: 53498 Change-Id: I53c82921595a9014b555e4ec468e5ba10454cd3a --- includes/Wiki.php | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/includes/Wiki.php b/includes/Wiki.php index 48e56abe7b..edfbba2d28 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -511,9 +511,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', '' ) || @@ -554,26 +576,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 ) ) { -- 2.20.1