*
* @ingroup Maintenance
*/
-class UploadStashCleanup extends Maintenance {
+class CleanupUploadStash extends Maintenance {
public function __construct() {
parent::__construct();
$repo = RepoGroup::singleton()->getLocalRepo();
$tempRepo = $repo->getTempRepo();
- $dbr = $repo->getSlaveDB();
+ $dbr = $repo->getReplicaDB();
// how far back should this look for files to delete?
$cutoff = time() - $wgUploadStashMaxAge;
// this could be done some other, more direct/efficient way, but using
// UploadStash's own methods means it's less likely to fall accidentally
// out-of-date someday
- $stash = new UploadStash( $repo, new User() );
+ $stash = new UploadStash( $repo );
$i = 0;
foreach ( $keys as $key ) {
foreach ( $iterator as $file ) {
if ( wfTimestamp( TS_UNIX, $tempRepo->getFileTimestamp( "$dir/$file" ) ) < $cutoff ) {
$batch[] = [ 'op' => 'delete', 'src' => "$dir/$file" ];
- if ( count( $batch ) >= $this->mBatchSize ) {
+ if ( count( $batch ) >= $this->getBatchSize() ) {
$this->doOperations( $tempRepo, $batch );
$i += count( $batch );
$batch = [];
$iterator = $tempRepo->getBackend()->getFileList( [ 'dir' => $dir, 'adviseStat' => 1 ] );
$this->output( "Deleting orphaned temp files...\n" );
if ( strpos( $dir, '/local-temp' ) === false ) { // sanity check
- $this->error( "Temp repo is not using the temp container.", 1 ); // die
+ $this->fatalError( "Temp repo is not using the temp container." );
}
$i = 0;
$batch = []; // operation batch
foreach ( $iterator as $file ) {
if ( wfTimestamp( TS_UNIX, $tempRepo->getFileTimestamp( "$dir/$file" ) ) < $cutoff ) {
$batch[] = [ 'op' => 'delete', 'src' => "$dir/$file" ];
- if ( count( $batch ) >= $this->mBatchSize ) {
+ if ( count( $batch ) >= $this->getBatchSize() ) {
$this->doOperations( $tempRepo, $batch );
$i += count( $batch );
$batch = [];
}
}
-$maintClass = "UploadStashCleanup";
+$maintClass = CleanupUploadStash::class;
require_once RUN_MAINTENANCE_IF_MAIN;