r3468 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r3467‎ | r3468 | r3469 >
Date:00:15, 4 May 2004
Author:timstarling
Status:old
Tags:
Comment:
wpForce parameter to delete() for cleaning up corrupted image table
Modified paths:
  • /branches/REL1_2/phase3/includes/ImagePage.php (modified) (history)

Diff [purge]

Index: branches/REL1_2/phase3/includes/ImagePage.php
@@ -117,7 +117,7 @@
118118 function delete()
119119 {
120120 global $wgUser, $wgOut;
121 - global $wpConfirm, $wpReason, $image, $oldimage;
 121+ global $wpConfirm, $wpReason, $image, $oldimage, $wpForce;
122122
123123 # Anybody can delete old revisions of images; only sysops
124124 # can delete articles and current images
@@ -134,7 +134,7 @@
135135 # Better double-check that it hasn't been deleted yet!
136136 $wgOut->setPagetitle( wfMsg( "confirmdelete" ) );
137137 if ( $image ) {
138 - if ( "" == trim( $image ) ) {
 138+ if ( "" == trim( $image ) && !$wpForce ) {
139139 $wgOut->fatalError( wfMsg( "cannotdelete" ) );
140140 return;
141141 }
@@ -157,14 +157,14 @@
158158 function doDelete()
159159 {
160160 global $wgOut, $wgUser, $wgLang;
161 - global $image, $oldimage, $wpReason;
 161+ global $image, $oldimage, $wpReason, $wpForce;
162162 global $wgUseSquid, $wgInternalServer, $wgDeferredUpdateList;
163163 $fname = "Article::doDelete";
164164
165165 if ( $image ) {
166166 $dest = wfImageDir( $image );
167167 $archive = wfImageDir( $image );
168 - if ( ! unlink( "{$dest}/{$image}" ) ) {
 168+ if ( ! unlink( "{$dest}/{$image}" ) && !$wpForce ) {
169169 $wgOut->fileDeleteError( "{$dest}/{$image}" );
170170 return;
171171 }
@@ -243,11 +243,11 @@
244244
245245 function doDeleteOldImage( $oldimage )
246246 {
247 - global $wgOut;
 247+ global $wgOut, $wpForce;
248248
249249 $name = substr( $oldimage, 15 );
250250 $archive = wfImageArchiveDir( $name );
251 - if ( ! unlink( "{$archive}/{$oldimage}" ) ) {
 251+ if ( ! unlink( "{$archive}/{$oldimage}" ) && !$wpForce ) {
252252 $wgOut->fileDeleteError( "{$archive}/{$oldimage}" );
253253 }
254254 }

Status & tagging log