class EraseArchivedFile extends Maintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Erases traces of deleted files.";
+ $this->addDescription( 'Erases traces of deleted files.' );
$this->addOption( 'delete', 'Perform the deletion' );
$this->addOption( 'filename', 'File name', false, true );
$this->addOption( 'filekey', 'File storage key (with extension) or "*"', true, true );
}
$afile = false;
} else { // specified version
- $dbw = wfGetDB( DB_MASTER );
+ $dbw = $this->getDB( DB_MASTER );
$row = $dbw->selectRow( 'filearchive', '*',
- array( 'fa_storage_group' => 'deleted', 'fa_storage_key' => $filekey ),
+ [ 'fa_storage_group' => 'deleted', 'fa_storage_key' => $filekey ],
__METHOD__ );
if ( !$row ) {
$this->error( "No deleted file exists with key '$filekey'.", 1 );
}
protected function scrubAllVersions( $name ) {
- $dbw = wfGetDB( DB_MASTER );
+ $dbw = $this->getDB( DB_MASTER );
$res = $dbw->select( 'filearchive', '*',
- array( 'fa_name' => $name, 'fa_storage_group' => 'deleted' ),
+ [ 'fa_name' => $name, 'fa_storage_group' => 'deleted' ],
__METHOD__ );
foreach ( $res as $row ) {
$this->scrubVersion( ArchivedFile::newFromRow( $row ) );
$repo = RepoGroup::singleton()->getLocalRepo();
$path = $repo->getZonePath( 'deleted' ) . '/' . $repo->getDeletedHashPath( $key ) . $key;
if ( $this->hasOption( 'delete' ) ) {
- $status = $repo->getBackend()->delete( array( 'src' => $path ) );
+ $status = $repo->getBackend()->delete( [ 'src' => $path ] );
if ( $status->isOK() ) {
$this->output( "Deleted version '$key' ($ts) of file '$name'\n" );
} else {