X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=maintenance%2FcheckImages.php;h=484217d972f254397fccc15dc7f72ccee9b778bb;hb=fc7532449dfa54077c1698e0f34a2738fa336c26;hp=5dcaac28497a9e8397e5bcc19a3bc4d5ebf3ad5e;hpb=567f244e3611c9e020bc69446a77a10c21257f84;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/checkImages.php b/maintenance/checkImages.php index 5dcaac2849..484217d972 100644 --- a/maintenance/checkImages.php +++ b/maintenance/checkImages.php @@ -17,9 +17,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * + * @file * @ingroup Maintenance */ -require_once( dirname(__FILE__) . '/Maintenance.php' ); +require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class CheckImages extends Maintenance { @@ -28,16 +29,16 @@ class CheckImages extends Maintenance { $this->mDescription = "Check images to see if they exist, are readable, etc"; $this->setBatchSize( 1000 ); } - + public function execute() { $start = ''; $dbr = wfGetDB( DB_SLAVE ); $numImages = 0; $numGood = 0; - + do { - $res = $dbr->select( 'image', '*', array( 'img_name > ' . $dbr->addQuotes( $start ) ), + $res = $dbr->select( 'image', '*', array( 'img_name > ' . $dbr->addQuotes( $start ) ), __METHOD__, array( 'LIMIT' => $this->mBatchSize ) ); foreach ( $res as $row ) { $numImages++; @@ -48,35 +49,37 @@ class CheckImages extends Maintenance { $this->output( "{$row->img_name}: not locally accessible\n" ); continue; } - $stat = @stat( $file->getPath() ); + wfSuppressWarnings(); + $stat = stat( $file->getPath() ); + wfRestoreWarnings(); if ( !$stat ) { $this->output( "{$row->img_name}: missing\n" ); continue; } - + if ( $stat['mode'] & 040000 ) { $this->output( "{$row->img_name}: is a directory\n" ); continue; } - + if ( $stat['size'] == 0 && $row->img_size != 0 ) { $this->output( "{$row->img_name}: truncated, was {$row->img_size}\n" ); continue; } - + if ( $stat['size'] != $row->img_size ) { $this->output( "{$row->img_name}: size mismatch DB={$row->img_size}, actual={$stat['size']}\n" ); continue; } - + $numGood++; } - + } while ( $res->numRows() ); - + $this->output( "Good images: $numGood/$numImages\n" ); } } $maintClass = "CheckImages"; -require_once( DO_MAINTENANCE ); +require_once( RUN_MAINTENANCE_IF_MAIN );