r32776 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32775‎ | r32776 | r32777 >
Date:12:16, 4 April 2008
Author:btongminh
Status:old
Tags:
Comment:
Moved file deletion code to a more abstract FileDeleteForm::doDelete
Modified paths:
  • /trunk/phase3/includes/FileDeleteForm.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/FileDeleteForm.php
@@ -75,32 +75,9 @@
7676 } elseif ( $reason == 'other' ) {
7777 $reason = $this->DeleteReason;
7878 }
79 -
80 - $article = null;
81 - if( $this->oldimage ) {
82 - $status = $this->file->deleteOld( $this->oldimage, $reason, $suppress );
83 - if( $status->ok ) {
84 - // Need to do a log item
85 - $log = new LogPage( 'delete' );
86 - $logComment = wfMsgForContent( 'deletedrevision', $this->oldimage );
87 - if( trim( $reason ) != '' )
88 - $logComment .= ": {$reason}";
89 - $log->addEntry( 'delete', $this->title, $logComment );
90 - }
91 - } else {
92 - $status = $this->file->delete( $reason, $suppress );
93 - if( $status->ok ) {
94 - // Need to delete the associated article
95 - $article = new Article( $this->title );
96 - if( wfRunHooks('ArticleDelete', array(&$article, &$wgUser, &$reason)) ){
97 - if( $article->doDeleteArticle( $reason, $suppress ) )
98 - wfRunHooks('ArticleDeleteComplete', array(&$article, &$wgUser, $reason));
99 - }
100 - }
101 - }
102 - if( $status->isGood() ) wfRunHooks('FileDeleteComplete', array(
103 - &$this->file, &$this->oldimage, &$article, &$wgUser, &$reason));
10479
 80+ $status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress );
 81+
10582 if( !$status->isGood() )
10683 $wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) );
10784 if( $status->ok ) {
@@ -116,6 +93,35 @@
11794 $this->showForm();
11895 $this->showLogEntries();
11996 }
 97+
 98+ public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress ) {
 99+ $article = null;
 100+ if( $oldimage ) {
 101+ $status = $file->deleteOld( $oldimage, $reason, $suppress );
 102+ if( $status->ok ) {
 103+ // Need to do a log item
 104+ $log = new LogPage( 'delete' );
 105+ $logComment = wfMsgForContent( 'deletedrevision', $oldimage );
 106+ if( trim( $reason ) != '' )
 107+ $logComment .= ": {$reason}";
 108+ $log->addEntry( 'delete', $title, $logComment );
 109+ }
 110+ } else {
 111+ $status = $file->delete( $reason, $suppress );
 112+ if( $status->ok ) {
 113+ // Need to delete the associated article
 114+ $article = new Article( $title );
 115+ if( wfRunHooks('ArticleDelete', array(&$article, &$wgUser, &$reason)) ) {
 116+ if( $article->doDeleteArticle( $reason, $suppress ) )
 117+ wfRunHooks('ArticleDeleteComplete', array(&$article, &$wgUser, $reason));
 118+ }
 119+ }
 120+ }
 121+ if( $status->isGood() ) wfRunHooks('FileDeleteComplete', array(
 122+ &$file, &$oldimage, &$article, &$wgUser, &$reason));
 123+
 124+ return $status;
 125+ }
120126
121127 /**
122128 * Show the confirmation form

Follow-up revisions

RevisionCommit summaryAuthorDate
r71896Follow up r32776....platonides19:11, 29 August 2010

Status & tagging log