Follow up of r45960, adding English comment in Names.php
[lhc/web/wiklou.git] / maintenance / checkImages.php
1 <?php
2
3 require( 'commandLine.inc' );
4
5 $batchSize = 1000;
6 $start = '';
7 $dbr = wfGetDB( DB_SLAVE );
8 $localRepo = RepoGroup::singleton()->getLocalRepo();
9
10 $numImages = 0;
11 $numGood = 0;
12
13 do {
14 $res = $dbr->select( 'image', '*', array( 'img_name > ' . $dbr->addQuotes( $start ) ) );
15 foreach ( $res as $row ) {
16 $numImages++;
17 $start = $row->img_name;
18 $file = $localRepo->newFileFromRow( $row );
19 $path = $file->getPath();
20 if ( !$path ) {
21 echo "{$row->img_name}: not locally accessible\n";
22 continue;
23 }
24 $stat = @stat( $file->getPath() );
25 if ( !$stat ) {
26 echo "{$row->img_name}: missing\n";
27 continue;
28 }
29
30 if ( $stat['size'] == 0 && $row->img_size != 0 ) {
31 echo "{$row->img_name}: truncated, was {$row->img_size}\n";
32 continue;
33 }
34
35 if ( $stat['size'] != $row->img_size ) {
36 echo "{$row->img_name}: size mismatch DB={$row->img_size}, actual={$stat['size']}\n";
37 continue;
38 }
39
40 $numGood++;
41 }
42
43 } while ( $res->numRows() );
44
45 echo "Good images: $numGood/$numImages\n";