X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=maintenance%2FfindMissingFiles.php;h=4ce7ca68ae60d70323d57d04e90d3695cd8f8a9a;hp=2fad7ce75cd44887a9d955cdabbc98ac5480714d;hb=5049af1048c77b1ea6ab3193688d23a48ddf8df0;hpb=74174fca253b9a759d7402f09b7fc37d5de0e9be diff --git a/maintenance/findMissingFiles.php b/maintenance/findMissingFiles.php index 2fad7ce75c..4ce7ca68ae 100644 --- a/maintenance/findMissingFiles.php +++ b/maintenance/findMissingFiles.php @@ -16,7 +16,6 @@ * http://www.gnu.org/copyleft/gpl.html * * @file - * @author Aaron Schulz */ require_once __DIR__ . '/Maintenance.php'; @@ -36,51 +35,51 @@ class FindMissingFiles extends Maintenance { $lastName = $this->getOption( 'start', '' ); $repo = RepoGroup::singleton()->getLocalRepo(); - $dbr = $repo->getSlaveDB(); + $dbr = $repo->getReplicaDB(); $be = $repo->getBackend(); $mtime1 = $dbr->timestampOrNull( $this->getOption( 'mtimeafter', null ) ); $mtime2 = $dbr->timestampOrNull( $this->getOption( 'mtimebefore', null ) ); - $joinTables = array(); - $joinConds = array(); + $joinTables = []; + $joinConds = []; if ( $mtime1 || $mtime2 ) { $joinTables[] = 'page'; - $joinConds['page'] = array( 'INNER JOIN', - array( 'page_title = img_name', 'page_namespace' => NS_FILE ) ); + $joinConds['page'] = [ 'INNER JOIN', + [ 'page_title = img_name', 'page_namespace' => NS_FILE ] ]; $joinTables[] = 'logging'; - $on = array( 'log_page = page_id', 'log_type' => array( 'upload', 'move', 'delete' ) ); + $on = [ 'log_page = page_id', 'log_type' => [ 'upload', 'move', 'delete' ] ]; if ( $mtime1 ) { $on[] = "log_timestamp > {$dbr->addQuotes($mtime1)}"; } if ( $mtime2 ) { $on[] = "log_timestamp < {$dbr->addQuotes($mtime2)}"; } - $joinConds['logging'] = array( 'INNER JOIN', $on ); + $joinConds['logging'] = [ 'INNER JOIN', $on ]; } do { $res = $dbr->select( - array_merge( array( 'image' ), $joinTables ), - array( 'name' => 'img_name' ), - array( "img_name > " . $dbr->addQuotes( $lastName ) ), + array_merge( [ 'image' ], $joinTables ), + [ 'name' => 'img_name' ], + [ "img_name > " . $dbr->addQuotes( $lastName ) ], __METHOD__, // DISTINCT causes a pointless filesort - array( 'ORDER BY' => 'name', 'GROUP BY' => 'name', - 'LIMIT' => $this->mBatchSize ), + [ 'ORDER BY' => 'name', 'GROUP BY' => 'name', + 'LIMIT' => $this->mBatchSize ], $joinConds ); // Check if any of these files are missing... - $pathsByName = array(); + $pathsByName = []; foreach ( $res as $row ) { $file = $repo->newFile( $row->name ); $pathsByName[$row->name] = $file->getPath(); $lastName = $row->name; } - $be->preloadFileStat( array( 'srcs' => $pathsByName ) ); + $be->preloadFileStat( [ 'srcs' => $pathsByName ] ); foreach ( $pathsByName as $path ) { - if ( $be->fileExists( array( 'src' => $path ) ) === false ) { + if ( $be->fileExists( [ 'src' => $path ] ) === false ) { $this->output( "$path\n" ); } } @@ -88,12 +87,12 @@ class FindMissingFiles extends Maintenance { // Find all missing old versions of any of the files in this batch... if ( count( $pathsByName ) ) { $ores = $dbr->select( 'oldimage', - array( 'oi_name', 'oi_archive_name' ), - array( 'oi_name' => array_keys( $pathsByName ) ), + [ 'oi_name', 'oi_archive_name' ], + [ 'oi_name' => array_keys( $pathsByName ) ], __METHOD__ ); - $checkPaths = array(); + $checkPaths = []; foreach ( $ores as $row ) { if ( !strlen( $row->oi_archive_name ) ) { continue; // broken row @@ -103,9 +102,9 @@ class FindMissingFiles extends Maintenance { } foreach ( array_chunk( $checkPaths, $this->mBatchSize ) as $paths ) { - $be->preloadFileStat( array( 'srcs' => $paths ) ); + $be->preloadFileStat( [ 'srcs' => $paths ] ); foreach ( $paths as $path ) { - if ( $be->fileExists( array( 'src' => $path ) ) === false ) { + if ( $be->fileExists( [ 'src' => $path ] ) === false ) { $this->output( "$path\n" ); } }