From dc3e0ceeb7afba5492159eb33427cc2dc67a5c45 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Thu, 3 Nov 2011 08:16:15 +0000 Subject: [PATCH] * Use WikiPage instead of Article and call doDeleteArticle() with a custom error message instead of calling doDelete() * Call Title::getUserPermissionsErrors() instead of User::isAllowed() to know whether the user can delete the page --- includes/specials/SpecialMovepage.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 38b25afd2e..bbf2dbe9df 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -363,24 +363,30 @@ class MovePageForm extends UnlistedSpecialPage { $nt = $this->newTitle; # Delete to make way if requested - if ( $user->isAllowed( 'delete' ) && $this->deleteAndMove ) { - $article = new Article( $nt ); + if ( !count( $nt->getUserPermissionsErrors( 'delete', $user ) ) && $this->deleteAndMove ) { + $page = WikiPage::factory( $nt ); # Disallow deletions of big articles - $bigHistory = $article->isBigDeletion(); + $bigHistory = $page->isBigDeletion(); if( $bigHistory && count( $nt->getUserPermissionsErrors( 'bigdelete', $user ) ) ) { - $this->showForm( array('delete-toobig', $this->getLang()->formatNum( $wgDeleteRevisionsLimit ) ) ); + $this->showForm( array( 'delete-toobig', $this->getLang()->formatNum( $wgDeleteRevisionsLimit ) ) ); return; } + $reason = wfMessage( 'delete_and_move_reason', $ot )->inContentLanguage()->text(); + // Delete an associated image if there is $file = wfLocalFile( $nt ); if( $file->exists() ) { - $file->delete( wfMessage( 'delete_and_move_reason', $ot )->inContentLanguage()->text(), false ); + $file->delete( $reason, false ); + } + + $error = ''; // passed by ref + if ( !$page->doDeleteArticle( $reason, false, 0, true, $error, $user ) ) { + $this->showForm( array( 'cannotdelete', wfEscapeWikiText( $nt->getPrefixedText() ) ) ); + return; } - // This may output an error message and exit - $article->doDelete(wfMessage( 'delete_and_move_reason', $ot )->inContentLanguage()->text() ); } # don't allow moving to pages with # in -- 2.20.1