class DeleteArchivedFiles extends Maintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Deletes all archived images.";
+ $this->addDescription( 'Deletes all archived images.' );
$this->addOption( 'delete', 'Perform the deletion' );
$this->addOption( 'force', 'Force deletion of rows from filearchive' );
}
# Data should come off the master, wrapped in a transaction
$dbw = $this->getDB( DB_MASTER );
- $dbw->begin( __METHOD__ );
+ $this->beginTransaction( $dbw, __METHOD__ );
$repo = RepoGroup::singleton()->getLocalRepo();
# Get "active" revisions from the filearchive table
$this->output( "Searching for and deleting archived files...\n" );
$res = $dbw->select(
'filearchive',
- array( 'fa_id', 'fa_storage_group', 'fa_storage_key', 'fa_sha1' ),
+ [ 'fa_id', 'fa_storage_group', 'fa_storage_key', 'fa_sha1' ],
'',
__METHOD__
);
$inuse = $dbw->selectField(
'oldimage',
'1',
- array(
+ [
'oi_sha1' => $sha1,
$dbw->bitAnd( 'oi_deleted', File::DELETED_FILE ) => File::DELETED_FILE
- ),
+ ],
__METHOD__,
- array( 'FOR UPDATE' )
+ [ 'FOR UPDATE' ]
);
$needForce = true;
}
$count++;
- $dbw->delete( 'filearchive', array( 'fa_id' => $id ), __METHOD__ );
+ $dbw->delete( 'filearchive', [ 'fa_id' => $id ], __METHOD__ );
}
- $dbw->commit( __METHOD__ );
+ $this->commitTransaction( $dbw, __METHOD__ );
$this->output( "Done! [$count file(s)]\n" );
}
}