<?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();
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 );
$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;
}
$maintClass = "DeleteImageCache";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );