Merge "Strip excess newlines from formatting test"
[lhc/web/wiklou.git] / includes / Wiki.php
index 0683d7c..48e56ab 100644 (file)
@@ -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' );
                }
@@ -539,6 +546,8 @@ 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__ );