2102bcf60c155b1e83a98c005033e41e379c8e51
3 * Check images to see if they exist, are readable, etc etc
5 require_once( "Maintenance.php" );
7 class CheckImages
extends Maintenance
{
9 public function __construct() {
10 parent
::__construct();
11 $this->mDescription
= "Check images to see if they exist, are readable, etc";
14 public function execute() {
17 $dbr = wfGetDB( DB_SLAVE
);
23 $res = $dbr->select( 'image', '*', array( 'img_name > ' . $dbr->addQuotes( $start ) ),
24 __METHOD__
, array( 'LIMIT' => $batchSize ) );
25 foreach ( $res as $row ) {
27 $start = $row->img_name
;
28 $file = RepoGroup
::singleton()->getLocalRepo()->newFileFromRow( $row );
29 $path = $file->getPath();
31 $this->output( "{$row->img_name}: not locally accessible\n";
34 $stat = @stat
( $file->getPath() );
36 $this->output( "{$row->img_name}: missing\n" );
40 if ( $stat['mode'] & 040000 ) {
41 $this->output( "{$row->img_name}: is a directory\n" );
45 if ( $stat['size'] == 0 && $row->img_size
!= 0 ) {
46 $this->output( "{$row->img_name}: truncated, was {$row->img_size}\n" );
50 if ( $stat['size'] != $row->img_size
) {
51 $this->output( "{$row->img_name}: size mismatch DB={$row->img_size}, actual={$stat['size']}\n" );
58 } while ( $res->numRows() );
60 $this->output( "Good images: $numGood/$numImages\n" );