Merge "Fix sessionfailure i18n message during authentication"
[lhc/web/wiklou.git] / maintenance / eraseArchivedFile.php
index 2fcdd14..ef6d3d8 100644 (file)
@@ -19,7 +19,6 @@
  *
  * @file
  * @ingroup Maintenance
- * @author Aaron Schulz
  */
 
 require_once __DIR__ . '/Maintenance.php';
@@ -51,16 +50,17 @@ class EraseArchivedFile extends Maintenance {
 
                if ( $filekey === '*' ) { // all versions by name
                        if ( !strlen( $filename ) ) {
-                               $this->error( "Missing --filename parameter.", 1 );
+                               $this->fatalError( "Missing --filename parameter." );
                        }
                        $afile = false;
                } else { // specified version
                        $dbw = $this->getDB( DB_MASTER );
-                       $row = $dbw->selectRow( 'filearchive', '*',
-                               array( 'fa_storage_group' => 'deleted', 'fa_storage_key' => $filekey ),
-                               __METHOD__ );
+                       $fileQuery = ArchivedFile::getQueryInfo();
+                       $row = $dbw->selectRow( $fileQuery['tables'], $fileQuery['fields'],
+                               [ 'fa_storage_group' => 'deleted', 'fa_storage_key' => $filekey ],
+                               __METHOD__, [], $fileQuery['joins'] );
                        if ( !$row ) {
-                               $this->error( "No deleted file exists with key '$filekey'.", 1 );
+                               $this->fatalError( "No deleted file exists with key '$filekey'." );
                        }
                        $filename = $row->fa_name;
                        $afile = ArchivedFile::newFromRow( $row );
@@ -68,7 +68,7 @@ class EraseArchivedFile extends Maintenance {
 
                $file = wfLocalFile( $filename );
                if ( $file->exists() ) {
-                       $this->error( "File '$filename' is still a public file, use the delete form.\n", 1 );
+                       $this->fatalError( "File '$filename' is still a public file, use the delete form.\n" );
                }
 
                $this->output( "Purging all thumbnails for file '$filename'..." );
@@ -86,9 +86,10 @@ class EraseArchivedFile extends Maintenance {
 
        protected function scrubAllVersions( $name ) {
                $dbw = $this->getDB( DB_MASTER );
-               $res = $dbw->select( 'filearchive', '*',
-                       array( 'fa_name' => $name, 'fa_storage_group' => 'deleted' ),
-                       __METHOD__ );
+               $fileQuery = ArchivedFile::getQueryInfo();
+               $res = $dbw->select( $fileQuery['tables'], $fileQuery['fields'],
+                       [ 'fa_name' => $name, 'fa_storage_group' => 'deleted' ],
+                       __METHOD__, [], $fileQuery['joins'] );
                foreach ( $res as $row ) {
                        $this->scrubVersion( ArchivedFile::newFromRow( $row ) );
                }
@@ -101,7 +102,7 @@ class EraseArchivedFile extends Maintenance {
                $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 {
@@ -114,5 +115,5 @@ class EraseArchivedFile extends Maintenance {
        }
 }
 
-$maintClass = "EraseArchivedFile";
+$maintClass = EraseArchivedFile::class;
 require_once RUN_MAINTENANCE_IF_MAIN;