X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FfindMissingFiles.php;h=5818ee25c4e7d8a8c755ff423994d740bd09680b;hb=c734d538602e26b097a97523894f0d3fdd8e052b;hp=67864c54e3db1b1c3a2323c6b53e8df9d526c7bd;hpb=5cc72b7c9400f67dd70a56c26c0fcc655d3a5284;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/findMissingFiles.php b/maintenance/findMissingFiles.php index 67864c54e3..5818ee25c4 100644 --- a/maintenance/findMissingFiles.php +++ b/maintenance/findMissingFiles.php @@ -26,7 +26,7 @@ class FindMissingFiles extends Maintenance { parent::__construct(); $this->mDescription = 'Find registered files with no corresponding file.'; - $this->addOption( 'start', 'Starting file name', false, true ); + $this->addOption( 'start', 'Start after this file name', false, true ); $this->addOption( 'mtimeafter', 'Only include files changed since this time', false, true ); $this->addOption( 'mtimebefore', 'Only includes files changed before this time', false, true ); $this->setBatchSize( 300 ); @@ -42,9 +42,12 @@ class FindMissingFiles extends Maintenance { $mtime1 = $dbr->timestampOrNull( $this->getOption( 'mtimeafter', null ) ); $mtime2 = $dbr->timestampOrNull( $this->getOption( 'mtimebefore', null ) ); - $joinTables = array( 'image' ); - $joinConds = array( 'image' => array( 'INNER JOIN', 'img_name = page_title' ) ); + $joinTables = array(); + $joinConds = array(); if ( $mtime1 || $mtime2 ) { + $joinTables[] = 'page'; + $joinConds['page'] = array( 'INNER JOIN', + array( 'page_title = img_name', 'page_namespace' => NS_FILE ) ); $joinTables[] = 'logging'; $on = array( 'log_page = page_id', 'log_type' => array( 'upload', 'move', 'delete' ) ); if ( $mtime1 ) { @@ -58,12 +61,13 @@ class FindMissingFiles extends Maintenance { do { $res = $dbr->select( - array_merge( array( 'page' ), $joinTables ), - array( 'name' => 'DISTINCT(page_title)' ), - array( 'page_namespace' => NS_FILE, - "page_title >= " . $dbr->addQuotes( $lastName ) ), + array_merge( array( 'image' ), $joinTables ), + array( 'name' => 'img_name' ), + array( "img_name > " . $dbr->addQuotes( $lastName ) ), __METHOD__, - array( 'ORDER BY' => 'page_title', 'LIMIT' => $this->mBatchSize ), + // DISTINCT causes a pointless filesort + array( 'ORDER BY' => 'name', 'GROUP BY' => 'name', + 'LIMIT' => $this->mBatchSize ), $joinConds );