Merge "ResourceLoaderFileModule: Do not separately cache .less files"
[lhc/web/wiklou.git] / includes / page / Article.php
index c54c692..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;
                        }
                }
@@ -1624,7 +1638,20 @@ class Article implements Page {
 
                // If the page has a history, insert a warning
                if ( $hasHistory ) {
-                       $revisions = $this->mTitle->estimateRevisionCount();
+                       $title = $this->getTitle();
+
+                       // The following can use the real revision count as this is only being shown for users that can delete
+                       // this page.
+                       // This, as a side-effect, also makes sure that the following query isn't being run for pages with a
+                       // larger history, unless the user has the 'bigdelete' right (and is about to delete this page).
+                       $dbr = wfGetDB( DB_SLAVE );
+                       $revisions = $edits = (int)$dbr->selectField(
+                               'revision',
+                               'COUNT(rev_page)',
+                               array( 'rev_page' => $title->getArticleID() ),
+                               __METHOD__
+                       );
+
                        // @todo FIXME: i18n issue/patchwork message
                        $this->getContext()->getOutput()->addHTML( '<strong class="mw-delete-warning-revisions">' .
                                wfMessage( 'historywarning' )->numParams( $revisions )->parse() .
@@ -1635,7 +1662,7 @@ class Article implements Page {
                                '</strong>'
                        );
 
-                       if ( $this->mTitle->isBigDeletion() ) {
+                       if ( $title->isBigDeletion() ) {
                                global $wgDeleteRevisionsLimit;
                                $this->getContext()->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
                                        array(