X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=maintenance%2FfindOrphanedFiles.php;h=765fbe4a0aa0f5265ba3f540c5b85c6297bc78fe;hp=23629575bcc1a8fcce94bdc2f218876888ef1ca6;hb=203cedd029e42bd3c55e50a9cff6f14373d8aa67;hpb=e2a7988178698b4369c7963d20610ee622db3ee7 diff --git a/maintenance/findOrphanedFiles.php b/maintenance/findOrphanedFiles.php index 23629575bc..765fbe4a0a 100644 --- a/maintenance/findOrphanedFiles.php +++ b/maintenance/findOrphanedFiles.php @@ -16,7 +16,6 @@ * http://www.gnu.org/copyleft/gpl.html * * @file - * @author Aaron Schulz */ require_once __DIR__ . '/Maintenance.php'; @@ -50,12 +49,12 @@ class FindOrphanedFiles extends Maintenance { $this->output( "Scanning files under $directory:\n" ); } - $list = $repo->getBackend()->getFileList( array( 'dir' => $directory ) ); + $list = $repo->getBackend()->getFileList( [ 'dir' => $directory ] ); if ( $list === null ) { $this->error( "Could not get file listing.", 1 ); } - $pathBatch = array(); + $pathBatch = []; foreach ( $list as $path ) { if ( preg_match( '#^(thumb|deleted)/#', $path ) ) { continue; // handle ugly nested containers on stock installs @@ -64,7 +63,7 @@ class FindOrphanedFiles extends Maintenance { $pathBatch[] = $path; if ( count( $pathBatch ) >= $this->mBatchSize ) { $this->checkFiles( $repo, $pathBatch, $verbose ); - $pathBatch = array(); + $pathBatch = []; } } $this->checkFiles( $repo, $pathBatch, $verbose ); @@ -75,12 +74,12 @@ class FindOrphanedFiles extends Maintenance { return; } - $dbr = $repo->getSlaveDB(); + $dbr = $repo->getReplicaDB(); - $curNames = array(); - $oldNames = array(); - $imgIN = array(); - $oiWheres = array(); + $curNames = []; + $oldNames = []; + $imgIN = []; + $oiWheres = []; foreach ( $paths as $path ) { $name = basename( $path ); if ( preg_match( '#^archive/#', $path ) ) { @@ -91,7 +90,7 @@ class FindOrphanedFiles extends Maintenance { $oldNames[] = $name; list( , $base ) = explode( '!', $name, 2 ); // ! $oiWheres[] = $dbr->makeList( - array( 'oi_name' => $base, 'oi_archive_name' => $name ), + [ 'oi_name' => $base, 'oi_archive_name' => $name ], LIST_AND ); } else { @@ -106,25 +105,25 @@ class FindOrphanedFiles extends Maintenance { $res = $dbr->query( $dbr->unionQueries( - array( + [ $dbr->selectSQLText( 'image', - array( 'name' => 'img_name', 'old' => 0 ), - $imgIN ? array( 'img_name' => $imgIN ) : '1=0' + [ 'name' => 'img_name', 'old' => 0 ], + $imgIN ? [ 'img_name' => $imgIN ] : '1=0' ), $dbr->selectSQLText( 'oldimage', - array( 'name' => 'oi_archive_name', 'old' => 1 ), + [ 'name' => 'oi_archive_name', 'old' => 1 ], $oiWheres ? $dbr->makeList( $oiWheres, LIST_OR ) : '1=0' ) - ), + ], true // UNION ALL (performance) ), __METHOD__ ); - $curNamesFound = array(); - $oldNamesFound = array(); + $curNamesFound = []; + $oldNamesFound = []; foreach ( $res as $row ) { if ( $row->old ) { $oldNamesFound[] = $row->name;