r35684 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35683‎ | r35684 | r35685 >
Date:19:34, 1 June 2008
Author:btongminh
Status:old
Tags:
Comment:
Fix deletion of images
Modified paths:
  • /trunk/extensions/Nuke/SpecialNuke_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Nuke/SpecialNuke_body.php
@@ -94,6 +94,9 @@
9595 $sk =& $wgUser->getSkin();
9696 foreach( $pages as $info ) {
9797 list( $title, $edits ) = $info;
 98+ $image = $title->getNamespace() == NS_IMAGE ? wfLocalFile( $title ) : false;
 99+ $thumb = $image ? $image->getThumbnail( 120, 120 ) : false;
 100+
98101 $wgOut->addHTML( '<li>' .
99102 Xml::element( 'input', array(
100103 'type' => 'checkbox',
@@ -101,6 +104,7 @@
102105 'value' => $title->getPrefixedDbKey(),
103106 'checked' => 'checked' ) ) .
104107 '&nbsp;' .
 108+ ( $thumb ? $thumb->toHtml( array( 'desc-link' => true ) ) : '' ) .
105109 $sk->makeKnownLinkObj( $title ) .
106110 '&nbsp;(' .
107111 $sk->makeKnownLinkObj( $title, wfMsgExt( 'nchanges', array( 'parsemag' ), $wgLang->formatNum( $edits ) ), 'action=history' ) .
@@ -133,8 +137,14 @@
134138 function doDelete( $pages, $reason ) {
135139 foreach( $pages as $page ) {
136140 $title = Title::newFromUrl( $page );
137 - $article = new Article( $title );
138 - $article->doDelete( $reason );
 141+ $file = $title->getNamespace() == NS_IMAGE ? wfLocalFile( $title ) : false;
 142+ if ( $file ) {
 143+ $oldimage = null; // Must be passed by reference
 144+ FileDeleteForm::doDelete( $title, $file, $oldimage, $reason, false );
 145+ } else {
 146+ $article = new Article( $title );
 147+ $article->doDelete( $reason );
 148+ }
139149 }
140150 }
141151 }

Status & tagging log