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.
$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() );
$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;
}
}
$user = $this->getContext()->getUser();
# Check permissions
- $permission_errors = $title->getUserPermissionsErrors( 'delete', $user );
- if ( count( $permission_errors ) ) {
- throw new PermissionsError( 'delete', $permission_errors );
+ $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
+ if ( count( $permissionErrors ) ) {
+ throw new PermissionsError( 'delete', $permissionErrors );
}
# Read-only check...
// 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() .
'</strong>'
);
- if ( $this->mTitle->isBigDeletion() ) {
+ if ( $title->isBigDeletion() ) {
global $wgDeleteRevisionsLimit;
$this->getContext()->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
array(