X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2FWiki.php;h=50bba7b9fc02d2d6cb484d021f064c4fcce0bec2;hb=6d4f5d142f28ade566dd6cd97af129c582e6f27b;hp=0683d7c9f9a03c90004cb5a1a2b9cbb57bae39c3;hpb=a14bcc6ebe8afcd06de20f10f6fdce65ce648712;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Wiki.php b/includes/Wiki.php index 0683d7c9f9..50bba7b9fc 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -85,8 +85,6 @@ class MediaWiki { } elseif ( $curid ) { // URLs like this are generated by RC, because rc_title isn't always accurate $ret = Title::newFromID( $curid ); - } elseif ( $title == '' && $action != 'delete' ) { - $ret = Title::newMainPage(); } else { $ret = Title::newFromURL( $title ); // Alias NS_MEDIA page URLs to NS_FILE...we only use NS_MEDIA @@ -102,8 +100,12 @@ class MediaWiki { $wgContLang->findVariantLink( $title, $ret ); } } - // For non-special titles, check for implicit titles - if ( is_null( $ret ) || !$ret->isSpecialPage() ) { + + // If title is not provided, always allow oldid and diff to set the title. + // If title is provided, allow oldid and diff to override the title, unless + // we are talking about a special page which might use these parameters for + // other purposes. + if ( $ret === null || !$ret->isSpecialPage() ) { // We can have urls with just ?diff=,?oldid= or even just ?diff= $oldid = $request->getInt( 'oldid' ); $oldid = $oldid ? $oldid : $request->getInt( 'diff' ); @@ -114,6 +116,11 @@ class MediaWiki { } } + // Use the main page as default title if nothing else has been provided + if ( $ret === null && strval( $title ) === '' && $action !== 'delete' ) { + $ret = Title::newMainPage(); + } + if ( $ret === null || ( $ret->getDBkey() == '' && $ret->getInterwiki() == '' ) ) { $ret = SpecialPage::getTitleFor( 'Badtitle' ); } @@ -295,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 ); @@ -504,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', '' ) || @@ -518,7 +540,7 @@ class MediaWiki { && $this->context->getUser()->requiresHTTPS() ) ) && - $request->detectProtocol() == 'http' + $request->getProtocol() == 'http' ) { $oldUrl = $request->getFullRequestURL(); $redirUrl = str_replace( 'http://', 'https://', $oldUrl ); @@ -539,32 +561,14 @@ class MediaWiki { $title = Title::newFromText( NS_MAIN, 'REDIR' ); $this->context->setTitle( $title ); $output = $this->context->getOutput(); + // Since we only do this redir to change proto, always send a vary header + $output->addVaryHeader( 'X-Forwarded-Proto' ); $output->redirect( $redirUrl ); $output->output(); wfProfileOut( __METHOD__ ); 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 ) ) { @@ -577,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(); @@ -676,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 ); } } }