39 $lastName = $this->
getOption(
'start',
'' );
42 $dbr = $repo->getReplicaDB();
43 $be = $repo->getBackend();
46 $mtime1 = $dbr->timestampOrNull( $this->
getOption(
'mtimeafter',
null ) );
47 $mtime2 = $dbr->timestampOrNull( $this->
getOption(
'mtimebefore',
null ) );
49 $queryBuilder = $dbr->newSelectQueryBuilder()
50 ->select( [
'name' =>
'img_name' ] )
52 ->where( $dbr->expr(
'img_name',
'>', $lastName ) )
55 ->limit( $batchSize );
57 if ( $mtime1 || $mtime2 ) {
58 $queryBuilder->join(
'page',
null,
'page_title = img_name' );
59 $queryBuilder->andWhere( [
'page_namespace' =>
NS_FILE ] );
61 $queryBuilder->join(
'logging',
null,
'log_page = page_id' );
62 $queryBuilder->andWhere( [
'log_type' => [
'upload',
'move',
'delete' ] ] );
64 $queryBuilder->andWhere( $dbr->expr(
'log_timestamp',
'>', $mtime1 ) );
67 $queryBuilder->andWhere( $dbr->expr(
'log_timestamp',
'<', $mtime2 ) );
72 $res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
76 foreach ( $res as $row ) {
77 $file = $repo->newFile( $row->name );
78 $pathsByName[$row->name] = $file->getPath();
79 $lastName = $row->name;
81 $be->preloadFileStat( [
'srcs' => $pathsByName ] );
82 foreach ( $pathsByName as
$path ) {
83 if ( $be->fileExists( [
'src' =>
$path ] ) ===
false ) {
84 $this->
output(
"$path\n" );
89 if ( count( $pathsByName ) ) {
90 $ores = $dbr->newSelectQueryBuilder()
91 ->select( [
'oi_name',
'oi_archive_name' ] )
93 ->where( [
'oi_name' => array_map(
'strval', array_keys( $pathsByName ) ) ] )
94 ->caller( __METHOD__ )->fetchResultSet();
97 foreach ( $ores as $row ) {
98 if ( $row->oi_archive_name ===
'' ) {
102 $file = $repo->newFromArchiveName( $row->oi_name, $row->oi_archive_name );
103 $checkPaths[] = $file->getPath();
106 foreach ( array_chunk( $checkPaths, $batchSize ) as $paths ) {
107 $be->preloadFileStat( [
'srcs' => $paths ] );
108 foreach ( $paths as
$path ) {
109 if ( $be->fileExists( [
'src' =>
$path ] ) ===
false ) {
110 $this->
output(
"$path\n" );
115 }
while ( $res->numRows() >= $batchSize );