27 $lastName = $this->
getOption(
'start',
'' );
30 $dbr = $repo->getReplicaDB();
31 $be = $repo->getBackend();
34 $mtime1 = $dbr->timestampOrNull( $this->
getOption(
'mtimeafter',
null ) );
35 $mtime2 = $dbr->timestampOrNull( $this->
getOption(
'mtimebefore',
null ) );
38 MainConfigNames::FileSchemaMigrationStage
42 $queryBuilder = FileSelectQueryBuilder::newForFile( $dbr )
43 ->groupBy( $nameField )
44 ->orderBy( $nameField )
45 ->limit( $batchSize );
47 if ( $mtime1 || $mtime2 ) {
48 $queryBuilder->join(
'page',
null,
'page_title = ' . $nameField );
49 $queryBuilder->andWhere( [
'page_namespace' =>
NS_FILE ] );
51 $queryBuilder->join(
'logging',
null,
'log_page = page_id' );
52 $queryBuilder->andWhere( [
'log_type' => [
'upload',
'move',
'delete' ] ] );
54 $queryBuilder->andWhere( $dbr->expr(
'log_timestamp',
'>', $mtime1 ) );
57 $queryBuilder->andWhere( $dbr->expr(
'log_timestamp',
'<', $mtime2 ) );
62 $res = ( clone $queryBuilder )
63 ->where( $dbr->expr( $nameField,
'>', $lastName ) )
64 ->caller( __METHOD__ )->fetchResultSet();
68 foreach ( $res as $row ) {
69 $file = $repo->newFile( $row->img_name );
70 $pathsByName[$row->img_name] = $file->getPath();
71 $lastName = $row->img_name;
73 $be->preloadFileStat( [
'srcs' => $pathsByName ] );
74 foreach ( $pathsByName as
$path ) {
75 if ( $be->fileExists( [
'src' =>
$path ] ) === false ) {
76 $this->
output(
"$path\n" );
81 if ( count( $pathsByName ) ) {
82 $ores = FileSelectQueryBuilder::newForOldFile( $dbr )
83 ->where( [
'oi_name' => array_map(
'strval', array_keys( $pathsByName ) ) ] )
84 ->caller( __METHOD__ )->fetchResultSet();
87 foreach ( $ores as $row ) {
88 if ( $row->oi_archive_name ===
'' ) {
92 $file = $repo->newFromArchiveName( $row->oi_name, $row->oi_archive_name );
93 $checkPaths[] = $file->getPath();
96 foreach ( array_chunk( $checkPaths, $batchSize ) as $paths ) {
97 $be->preloadFileStat( [
'srcs' => $paths ] );
98 foreach ( $paths as
$path ) {
99 if ( $be->fileExists( [
'src' =>
$path ] ) ===
false ) {
100 $this->
output(
"$path\n" );
105 }
while ( $res->numRows() >= $batchSize );