X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcleanupUploadStash.php;h=cd7a8420f9c5daeb1907b8cf40c9aa84a363920c;hb=bae9c5aca69c62ff8ae32956a082c0787cb06b73;hp=480059d25cfc96687fa634f625d035ccced7ddf7;hpb=ca2c2c0f4fdd633779ce1d48d09645275b0e5827;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cleanupUploadStash.php b/maintenance/cleanupUploadStash.php index 480059d25c..cd7a8420f9 100644 --- a/maintenance/cleanupUploadStash.php +++ b/maintenance/cleanupUploadStash.php @@ -47,7 +47,7 @@ class UploadStashCleanup extends Maintenance { $repo = RepoGroup::singleton()->getLocalRepo(); $tempRepo = $repo->getTempRepo(); - $dbr = $repo->getSlaveDb(); + $dbr = $repo->getSlaveDB(); // how far back should this look for files to delete? $cutoff = time() - $wgUploadStashMaxAge; @@ -65,7 +65,7 @@ class UploadStashCleanup extends Maintenance { $this->output( "No stashed files to cleanup according to the DB.\n" ); } else { // finish the read before starting writes. - $keys = array(); + $keys = []; foreach ( $res as $row ) { array_push( $keys, $row->us_key ); } @@ -96,17 +96,17 @@ class UploadStashCleanup extends Maintenance { // Delete all the corresponding thumbnails... $dir = $tempRepo->getZonePath( 'thumb' ); - $iterator = $tempRepo->getBackend()->getFileList( array( 'dir' => $dir, 'adviseStat' => 1 ) ); + $iterator = $tempRepo->getBackend()->getFileList( [ 'dir' => $dir, 'adviseStat' => 1 ] ); $this->output( "Deleting old thumbnails...\n" ); $i = 0; - $batch = array(); // operation batch + $batch = []; // operation batch foreach ( $iterator as $file ) { if ( wfTimestamp( TS_UNIX, $tempRepo->getFileTimestamp( "$dir/$file" ) ) < $cutoff ) { - $batch[] = array( 'op' => 'delete', 'src' => "$dir/$file" ); + $batch[] = [ 'op' => 'delete', 'src' => "$dir/$file" ]; if ( count( $batch ) >= $this->mBatchSize ) { $this->doOperations( $tempRepo, $batch ); $i += count( $batch ); - $batch = array(); + $batch = []; $this->output( "$i\n" ); } } @@ -119,20 +119,20 @@ class UploadStashCleanup extends Maintenance { // Apparently lots of stash files are not registered in the DB... $dir = $tempRepo->getZonePath( 'public' ); - $iterator = $tempRepo->getBackend()->getFileList( array( 'dir' => $dir, 'adviseStat' => 1 ) ); + $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 } $i = 0; - $batch = array(); // operation batch + $batch = []; // operation batch foreach ( $iterator as $file ) { if ( wfTimestamp( TS_UNIX, $tempRepo->getFileTimestamp( "$dir/$file" ) ) < $cutoff ) { - $batch[] = array( 'op' => 'delete', 'src' => "$dir/$file" ); + $batch[] = [ 'op' => 'delete', 'src' => "$dir/$file" ]; if ( count( $batch ) >= $this->mBatchSize ) { $this->doOperations( $tempRepo, $batch ); $i += count( $batch ); - $batch = array(); + $batch = []; $this->output( "$i\n" ); } }