* Moved $wgUploadMaintenance check after permissions and read only, so that the user doesn't think the error is temporary if he both doesn't have the permission and $wgUploadMaintenance is true
* Show normal error page when $wgUploadMaintenance and added a message for the error title
* Moved watchlist updating to FileDeletForm::execute(), it has nothing to do in doDelete() (would also be executed for api requests, etc.)
* Added $user parameter to FileDeletForm::doDelete() to pass the user doing the action
* Use WikiPage instead of Article
$file: reference to the deleted file
$oldimage: in case of the deletion of an old image, the name of the old file
$article: in case all revisions of the file are deleted a reference to the
- article associated with the file.
+ WikiFilePage associated with the file.
$user: user who performed the deletion
$reason: reason
* pending authentication, confirmation, etc.
*/
public function execute() {
- global $wgOut, $wgRequest, $wgUser;
+ global $wgOut, $wgRequest, $wgUser, $wgUploadMaintenance;
$permissionErrors = $this->title->getUserPermissionsErrors( 'delete', $wgUser );
if ( count( $permissionErrors ) ) {
throw new ReadOnlyError;
}
+ if ( $wgUploadMaintenance ) {
+ throw new ErrorPageError( 'filedelete-maintenance-title', 'filedelete-maintenance' );
+ }
+
$this->setHeaders();
$this->oldimage = $wgRequest->getText( 'oldimage', false );
$reason = $deleteReasonList;
}
- $status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress );
+ $status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress, $wgUser );
if( !$status->isGood() ) {
$wgOut->addHTML( '<h2>' . $this->prepareMessage( 'filedeleteerror-short' ) . "</h2>\n" );
// Return to the main page if we just deleted all versions of the
// file, otherwise go back to the description page
$wgOut->addReturnTo( $this->oldimage ? $this->title : Title::newMainPage() );
+
+ if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
+ WatchAction::doWatch( $title, $wgUser );
+ } elseif ( $this->title->userIsWatching() ) {
+ WatchAction::doUnwatch( $title, $wgUser );
+ }
}
return;
}
* @param $oldimage String: archive name
* @param $reason String: reason of the deletion
* @param $suppress Boolean: whether to mark all deleted versions as restricted
+ * @param $user User object performing the request
*/
- public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress ) {
- global $wgUser;
- $article = null;
- $status = Status::newFatal( 'error' );
+ public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress, User $user = null ) {
+ if ( $user === null ) {
+ global $wgUser;
+ $user = $wgUser;
+ }
if( $oldimage ) {
+ $page = null;
$status = $file->deleteOld( $oldimage, $reason, $suppress );
if( $status->ok ) {
// Need to do a log item
$log->addEntry( 'delete', $title, $logComment );
}
} else {
+ $status = Status::newFatal( 'error' );
$id = $title->getArticleID( Title::GAID_FOR_UPDATE );
- $article = new Article( $title );
+ $page = WikiPage::factory( $title );
$dbw = wfGetDB( DB_MASTER );
try {
// delete the associated article first
- if( $article->doDeleteArticle( $reason, $suppress, $id, false ) ) {
- global $wgRequest;
- if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
- WatchAction::doWatch( $title, $wgUser );
- } elseif ( $title->userIsWatching() ) {
- WatchAction::doUnwatch( $title, $wgUser );
- }
+ $error = '';
+ if ( $page->doDeleteArticle( $reason, $suppress, $id, false, $error, $user ) ) {
$status = $file->delete( $reason, $suppress );
if( $status->ok ) {
$dbw->commit();
throw $e;
}
}
- if( $status->isGood() )
- wfRunHooks('FileDeleteComplete', array( &$file, &$oldimage, &$article, &$wgUser, &$reason));
+
+ if ( $status->isGood() ) {
+ wfRunHooks( 'FileDeleteComplete', array( &$file, &$oldimage, &$page, &$user, &$reason ) );
+ }
return $status;
}
*/
public function delete() {
global $wgUploadMaintenance;
- if ( $wgUploadMaintenance && $this->getTitle() && $this->getTitle()->getNamespace() == NS_FILE ) {
- global $wgOut;
- $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n", array( 'filedelete-maintenance' ) );
- return;
- }
- $this->loadFile();
- if ( !$this->mPage->getFile()->exists() || !$this->mPage->getFile()->isLocal() || $this->mPage->getFile()->getRedirected() ) {
+ $file = $this->mPage->getFile();
+ if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) {
// Standard article deletion
parent::delete();
return;
}
- $deleter = new FileDeleteForm( $this->mPage->getFile() );
+
+ $deleter = new FileDeleteForm( $file );
$deleter->execute();
}
'filerevert-badversion' => 'There is no previous local version of this file with the provided timestamp.',
# File deletion
-'filedelete' => 'Delete $1',
-'filedelete-legend' => 'Delete file',
-'filedelete-intro' => "You are about to delete the file '''[[Media:$1|$1]]''' along with all of its history.",
-'filedelete-intro-old' => "You are deleting the version of '''[[Media:$1|$1]]''' as of [$4 $3, $2].",
-'filedelete-comment' => 'Reason:',
-'filedelete-submit' => 'Delete',
-'filedelete-success' => "'''$1''' has been deleted.",
-'filedelete-success-old' => "The version of '''[[Media:$1|$1]]''' as of $3, $2 has been deleted.",
-'filedelete-nofile' => "'''$1''' does not exist.",
-'filedelete-nofile-old' => "There is no archived version of '''$1''' with the specified attributes.",
-'filedelete-otherreason' => 'Other/additional reason:',
-'filedelete-reason-otherlist' => 'Other reason',
-'filedelete-reason-dropdown' => '*Common delete reasons
+'filedelete' => 'Delete $1',
+'filedelete-legend' => 'Delete file',
+'filedelete-intro' => "You are about to delete the file '''[[Media:$1|$1]]''' along with all of its history.",
+'filedelete-intro-old' => "You are deleting the version of '''[[Media:$1|$1]]''' as of [$4 $3, $2].",
+'filedelete-comment' => 'Reason:',
+'filedelete-submit' => 'Delete',
+'filedelete-success' => "'''$1''' has been deleted.",
+'filedelete-success-old' => "The version of '''[[Media:$1|$1]]''' as of $3, $2 has been deleted.",
+'filedelete-nofile' => "'''$1''' does not exist.",
+'filedelete-nofile-old' => "There is no archived version of '''$1''' with the specified attributes.",
+'filedelete-otherreason' => 'Other/additional reason:',
+'filedelete-reason-otherlist' => 'Other reason',
+'filedelete-reason-dropdown' => '*Common delete reasons
** Copyright violation
** Duplicated file',
-'filedelete-edit-reasonlist' => 'Edit delete reasons',
-'filedelete-maintenance' => 'Deletion and restoration of files temporarily disabled during maintenance.',
+'filedelete-edit-reasonlist' => 'Edit delete reasons',
+'filedelete-maintenance' => 'Deletion and restoration of files temporarily disabled during maintenance.',
+'filedelete-maintenance-title' => 'Cannot delete file',
# MIME search
'mimesearch' => 'MIME search',
{{Identical|Revert}}',
# File deletion
-'filedelete-legend' => '{{Identical|Delete}}',
-'filedelete-intro-old' => 'Message displayed when you try to delete a version of a file.
+'filedelete-legend' => '{{Identical|Delete}}',
+'filedelete-intro-old' => 'Message displayed when you try to delete a version of a file.
* $1 is the name of the media
* $2 is a date
* $3 is a hour
* $4 is a URL and must follow square bracket: [$4',
-'filedelete-comment' => '{{Identical|Reason}}',
-'filedelete-submit' => 'Delete button when deleting a file for admins
+'filedelete-comment' => '{{Identical|Reason}}',
+'filedelete-submit' => 'Delete button when deleting a file for admins
{{Identical|Delete}}',
-'filedelete-success-old' => 'Message displayed when you succeed in deleting a version of a file.
+'filedelete-success-old' => 'Message displayed when you succeed in deleting a version of a file.
* $1 is the name of the media
* $2 is a date
* $3 is a hour',
-'filedelete-otherreason' => 'Message used when deleting a file. This is the description field for "Other/additional reason" for deletion.
+'filedelete-otherreason' => 'Message used when deleting a file. This is the description field for "Other/additional reason" for deletion.
{{Identical|Other/additional reason}}',
-'filedelete-reason-otherlist' => 'Message used as default in the dropdown menu in the form for deleting a file. Keeping this message selected assumes that a reason for deletion is specified in the field below.
+'filedelete-reason-otherlist' => 'Message used as default in the dropdown menu in the form for deleting a file. Keeping this message selected assumes that a reason for deletion is specified in the field below.
{{Identical|Other reason}}',
-'filedelete-reason-dropdown' => 'Predefined reasons for deleting a file that can be selected in a drop down list. Entries prefixed with one asterisk ("*") are group headers and cannot be selected. Entries prefixed with two asterisks can be selected as reason for deletion.',
-'filedelete-edit-reasonlist' => 'Shown beneath the file deletion form on the right side. It is a link to [[MediaWiki:Filedelete-reason-dropdown]].
+'filedelete-reason-dropdown' => 'Predefined reasons for deleting a file that can be selected in a drop down list. Entries prefixed with one asterisk ("*") are group headers and cannot be selected. Entries prefixed with two asterisks can be selected as reason for deletion.',
+'filedelete-edit-reasonlist' => 'Shown beneath the file deletion form on the right side. It is a link to [[MediaWiki:Filedelete-reason-dropdown]].
{{Identical|Edit delete reasons}}',
+'filedelete-maintenance' => 'Content of the error page when $wgUploadMaintenance is set to true.',
+'filedelete-maintenance-title' => 'Title of the error page when $wgUploadMaintenance is set to true.',
# MIME search
'mimesearch' => 'Title of [[Special:MIMESearch]].',
'filedelete-reason-dropdown',
'filedelete-edit-reasonlist',
'filedelete-maintenance',
+ 'filedelete-maintenance-title',
),
'mimesearch' => array(
'mimesearch',