Message documentation update for DifferenceEngine
[lhc/web/wiklou.git] / maintenance / deleteImageMemcached.php
index 73712d1..3c8c5fd 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * This script delete image information from the cache.
+ * Delete image information from the object cache.
  *
  * Usage example:
  * php deleteImageMemcached.php --until "2005-09-05 00:00:00" --sleep 0
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
+ * @file
  * @ingroup Maintenance
  */
 
-require_once( "Maintenance.php" );
+require_once( __DIR__ . '/Maintenance.php' );
 
+/**
+ * Maintenance script that deletes image information from the object cache.
+ *
+ * @ingroup Maintenance
+ */
 class DeleteImageCache extends Maintenance {
        public function __construct() {
                parent::__construct();
@@ -36,8 +42,8 @@ class DeleteImageCache extends Maintenance {
        public function execute() {
                global $wgMemc;
 
-               $until = preg_replace( "/[^\d]/", '', $this->getOption('until') );
-               $sleep = (int)$this->getOption('sleep') * 1000; // milliseconds
+               $until = preg_replace( "/[^\d]/", '', $this->getOption( 'until' ) );
+               $sleep = (int)$this->getOption( 'sleep' ) * 1000; // milliseconds
 
                ini_set( 'display_errors', false );
 
@@ -52,13 +58,13 @@ class DeleteImageCache extends Maintenance {
                $i = 0;
                $total = $this->getImageCount();
 
-               while ( $row = $dbr->fetchObject( $res ) ) {
-                       if ($i % $this->report == 0)
-                               $this->output( sprintf("%s: %13s done (%s)\n", wfWikiID(), "$i/$total", wfPercent( $i / $total * 100 ) ) );
+               foreach ( $res as $row ) {
+                       if ( $i % $this->report == 0 )
+                               $this->output( sprintf( "%s: %13s done (%s)\n", wfWikiID(), "$i/$total", wfPercent( $i / $total * 100 ) ) );
                        $md5 = md5( $row->img_name );
                        $wgMemc->delete( wfMemcKey( 'Image', $md5 ) );
 
-                       if ($sleep != 0)
+                       if ( $sleep != 0 )
                                usleep( $sleep );
 
                        ++$i;
@@ -72,4 +78,4 @@ class DeleteImageCache extends Maintenance {
 }
 
 $maintClass = "DeleteImageCache";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );