X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=maintenance%2FfindOrphanedFiles.php;h=abd170b30446b14bb1a2a87a58b895c9013160c8;hb=bbd518baff8140a7ac3342cf176af542da4ad58b;hp=41650bd0e6774529aa67c945e9d1db06f757f5e3;hpb=97349a198fadbd9e3ca6d43b3ab0b58b478629f3;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/findOrphanedFiles.php b/maintenance/findOrphanedFiles.php index 41650bd0e6..abd170b304 100644 --- a/maintenance/findOrphanedFiles.php +++ b/maintenance/findOrphanedFiles.php @@ -25,7 +25,7 @@ class FindOrphanedFiles extends Maintenance { function __construct() { parent::__construct(); - $this->mDescription = "Find unregistered files in the 'public' repo zone."; + $this->addDescription( "Find unregistered files in the 'public' repo zone." ); $this->addOption( 'subdir', 'Only scan files in this subdirectory (e.g. "a/a0")', false, true ); $this->addOption( 'verbose', "Mention file paths checked" ); @@ -50,12 +50,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 +64,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 ); @@ -77,10 +77,10 @@ class FindOrphanedFiles extends Maintenance { $dbr = $repo->getSlaveDB(); - $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 +91,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 +106,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;