Actually declare $wgOut ;)
[lhc/web/wiklou.git] / maintenance / checkImages.php
index 2102bcf..5dcaac2 100644 (file)
@@ -1,18 +1,35 @@
 <?php
 /**
  * Check images to see if they exist, are readable, etc etc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @ingroup Maintenance
  */
-require_once( "Maintenance.php" );
+require_once( dirname(__FILE__) . '/Maintenance.php' );
 
 class CheckImages extends Maintenance {
 
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Check images to see if they exist, are readable, etc";
+               $this->setBatchSize( 1000 );
        }
        
        public function execute() {
-               $batchSize = 1000;
                $start = '';
                $dbr = wfGetDB( DB_SLAVE );
 
@@ -21,14 +38,14 @@ class CheckImages extends Maintenance {
        
                do {
                        $res = $dbr->select( 'image', '*', array( 'img_name > ' . $dbr->addQuotes( $start ) ), 
-                               __METHOD__, array( 'LIMIT' => $batchSize ) );
+                               __METHOD__, array( 'LIMIT' => $this->mBatchSize ) );
                        foreach ( $res as $row ) {
                                $numImages++;
                                $start = $row->img_name;
                                $file = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row );
                                $path = $file->getPath();
                                if ( !$path ) {
-                                       $this->output( "{$row->img_name}: not locally accessible\n";
+                                       $this->output( "{$row->img_name}: not locally accessible\n" );
                                        continue;
                                }
                                $stat = @stat( $file->getPath() );
@@ -61,3 +78,5 @@ class CheckImages extends Maintenance {
        }
 }
 
+$maintClass = "CheckImages";
+require_once( DO_MAINTENANCE );