Index: trunk/phase3/includes/media/Generic.php |
— | — | @@ -232,6 +232,28 @@ |
233 | 233 | * Modify the parser object post-transform |
234 | 234 | */ |
235 | 235 | 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 | + } |
236 | 258 | } |
237 | 259 | |
238 | 260 | /** |
— | — | @@ -353,28 +375,6 @@ |
354 | 376 | return new ThumbnailImage( $image, $url, $params['width'], $params['height'], $page ); |
355 | 377 | } |
356 | 378 | |
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 | | - |
379 | 379 | function getImageSize( $image, $path ) { |
380 | 380 | wfSuppressWarnings(); |
381 | 381 | $gis = getimagesize( $path ); |