r25479 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25478‎ | r25479 | r25480 >
Date:15:13, 4 September 2007
Author:tstarling
Status:old
Tags:
Comment:
Moved removeBadFile() to the base class
Modified paths:
  • /trunk/phase3/includes/media/Generic.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/media/Generic.php
@@ -232,6 +232,28 @@
233233 * Modify the parser object post-transform
234234 */
235235 function parserTransformHook( $parser, $file ) {}
 236+
 237+ /**
 238+ * Check for zero-sized thumbnails. These can be generated when
 239+ * no disk space is available or some other error occurs
 240+ *
 241+ * @param $dstPath The location of the suspect file
 242+ * @param $retval Return value of some shell process, file will be deleted if this is non-zero
 243+ * @return true if removed, false otherwise
 244+ */
 245+ function removeBadFile( $dstPath, $retval = 0 ) {
 246+ if( file_exists( $dstPath ) ) {
 247+ $thumbstat = stat( $dstPath );
 248+ if( $thumbstat['size'] == 0 || $retval != 0 ) {
 249+ wfDebugLog( 'thumbnail',
 250+ sprintf( 'Removing bad %d-byte thumbnail "%s"',
 251+ $thumbstat['size'], $dstPath ) );
 252+ unlink( $dstPath );
 253+ return true;
 254+ }
 255+ }
 256+ return false;
 257+ }
236258 }
237259
238260 /**
@@ -353,28 +375,6 @@
354376 return new ThumbnailImage( $image, $url, $params['width'], $params['height'], $page );
355377 }
356378
357 - /**
358 - * Check for zero-sized thumbnails. These can be generated when
359 - * no disk space is available or some other error occurs
360 - *
361 - * @param $dstPath The location of the suspect file
362 - * @param $retval Return value of some shell process, file will be deleted if this is non-zero
363 - * @return true if removed, false otherwise
364 - */
365 - function removeBadFile( $dstPath, $retval = 0 ) {
366 - if( file_exists( $dstPath ) ) {
367 - $thumbstat = stat( $dstPath );
368 - if( $thumbstat['size'] == 0 || $retval != 0 ) {
369 - wfDebugLog( 'thumbnail',
370 - sprintf( 'Removing bad %d-byte thumbnail "%s"',
371 - $thumbstat['size'], $dstPath ) );
372 - unlink( $dstPath );
373 - return true;
374 - }
375 - }
376 - return false;
377 - }
378 -
379379 function getImageSize( $image, $path ) {
380380 wfSuppressWarnings();
381381 $gis = getimagesize( $path );

Follow-up revisions

RevisionCommit summaryAuthorDate
r25530Merged revisions 25454-25529 via svnmerge from...david08:28, 5 September 2007

Status & tagging log