Merge "ResourceLoaderFileModule: Do not separately cache .less files"
[lhc/web/wiklou.git] / includes / page / Article.php
index da88a69..984b01d 100644 (file)
@@ -975,7 +975,14 @@ class Article implements Page {
                global $wgRedirectSources;
                $outputPage = $this->getContext()->getOutput();
 
-               $rdfrom = $this->getContext()->getRequest()->getVal( 'rdfrom' );
+               $request = $this->getContext()->getRequest();
+               $rdfrom = $request->getVal( 'rdfrom' );
+
+               // Construct a URL for the current page view, but with the target title
+               $query = $request->getValues();
+               unset( $query['rdfrom'] );
+               unset( $query['title'] );
+               $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
 
                if ( isset( $this->mRedirectedFrom ) ) {
                        // This is an internally redirected page view.
@@ -990,11 +997,12 @@ class Article implements Page {
 
                                $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
 
-                               // Set the fragment if one was specified in the redirect
-                               if ( $this->getTitle()->hasFragment() ) {
-                                       $outputPage->addJsConfigVars( 'wgRedirectToFragment', $this->getTitle()->getFragmentForURL() );
-                                       $outputPage->addModules( 'mediawiki.action.view.redirectToFragment' );
-                               }
+                               // Add the script to update the displayed URL and
+                               // set the fragment if one was specified in the redirect
+                               $outputPage->addJsConfigVars( array(
+                                       'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
+                               ) );
+                               $outputPage->addModules( 'mediawiki.action.view.redirect' );
 
                                // Add a <link rel="canonical"> tag
                                $outputPage->setCanonicalUrl( $this->getTitle()->getLocalURL() );
@@ -1011,6 +1019,12 @@ class Article implements Page {
                                $redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
                                $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
 
+                               // Add the script to update the displayed URL
+                               $outputPage->addJsConfigVars( array(
+                                       'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
+                               ) );
+                               $outputPage->addModules( 'mediawiki.action.view.redirect' );
+
                                return true;
                        }
                }