Add 'whatlinkshere-filters'
[lhc/web/wiklou.git] / maintenance / deleteImageMemcached.php
index 2de04ce..7ec9953 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// php deleteImageMemcached.php --until "2003-09-04 04:40:00" --wait 500
+// php deleteImageMemcached.php --until "2005-09-05 00:00:00" --sleep 0 --report 10
 $optionsWithArgs = array( 'until', 'sleep', 'report' );
 
 require_once 'commandLine.inc';
@@ -12,13 +12,15 @@ class DeleteImageCache {
                $this->sleep = $sleep;
                $this->report = $report;
        }
-       
+
        function main() {
-               global $wgMemc, $wgDBname;
+               global $wgMemc;
                $fname = 'DeleteImageCache::main';
-               
-               $dbr =& wfGetDB( DB_SLAVE );
-               
+
+               ini_set( 'display_errors', false );
+
+               $dbr = wfGetDB( DB_SLAVE );
+
                $res = $dbr->select( 'image',
                        array( 'img_name' ),
                        array( "img_timestamp < {$this->until}" ),
@@ -30,21 +32,21 @@ class DeleteImageCache {
 
                while ( $row = $dbr->fetchObject( $res ) ) {
                        if ($i % $this->report == 0)
-                               printf("%s: %13s done (%s)\n", $wgDBname, "$i/$total", wfPercent( $i / $total * 100 ));
+                               printf("%s: %13s done (%s)\n", wfWikiID(), "$i/$total", wfPercent( $i / $total * 100 ));
                        $md5 = md5( $row->img_name );
-                       $wgMemc->delete( "$wgDBname:Image:$md5" );
-                       
+                       $wgMemc->delete( wfMemcKey( 'Image', $md5 ) );
+
                        if ($this->sleep != 0)
                                usleep( $this->sleep );
 
                        ++$i;
                }
        }
-       
+
        function getImageCount() {
                $fname = 'DeleteImageCache::getImageCount';
 
-               $dbr =& wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_SLAVE );
                return $dbr->selectField( 'image', 'COUNT(*)', array(), $fname );
        }
 }
@@ -55,3 +57,4 @@ $report = (int)$options['report'];
 
 $dic = new DeleteImageCache( $until, $sleep, $report );
 $dic->main();
+