59 $start = str_replace(
' ',
'_', $this->
getOption(
'start',
'' ) );
60 $end = str_replace(
' ',
'_', $this->
getOption(
'end',
'' ) );
62 $media_type = str_replace(
' ',
'_', $this->
getOption(
'media_type',
'' ) );
64 $major_mime = str_replace(
' ',
'_', $this->
getOption(
'major_mime',
'' ) );
66 $minor_mime = str_replace(
' ',
'_', $this->
getOption(
'minor_mime',
'' ) );
72 $queryBuilder = FileSelectQueryBuilder::newForFile( $dbr );
74 $queryBuilder->where( $dbr->expr(
'img_name',
'>', $start ) );
75 if ( strlen( $end ) ) {
76 $queryBuilder->andWhere( $dbr->expr(
'img_name',
'<=', $end ) );
79 if ( strlen( $media_type ) ) {
80 $queryBuilder->andWhere( [
'img_media_type' => $media_type ] );
83 if ( strlen( $major_mime ) ) {
84 $queryBuilder->andWhere( [
'img_major_mime' => $major_mime ] );
87 if ( strlen( $minor_mime ) ) {
88 $queryBuilder->andWhere( [
'img_minor_mime' => $minor_mime ] );
92 ->orderBy(
'img_name', SelectQueryBuilder::SORT_ASC )
94 ->caller( __METHOD__ )->fetchResultSet();
96 if ( $res->numRows() > 0 ) {
97 $row1 = $res->current();
98 $this->
output(
"Processing next {$res->numRows()} row(s) starting with {$row1->img_name}.\n" );
102 $backendOperations = [];
104 foreach ( $res as $row ) {
105 $file = $repo->newFileFromRow( $row );
106 $headers = $file->getContentHeaders();
107 if ( $this->
getOption(
'refreshContentType',
false ) ) {
108 $headers[
'Content-Type'] = $row->img_major_mime .
'/' . $row->img_minor_mime;
111 if ( count( $headers ) ) {
112 $backendOperations[] = [
113 'op' =>
'describe',
'src' => $file->getPath(),
'headers' => $headers
118 foreach ( $file->getHistory() as $oldFile ) {
119 $headers = $oldFile->getContentHeaders();
120 if ( count( $headers ) ) {
121 $backendOperations[] = [
122 'op' =>
'describe',
'src' => $oldFile->getPath(),
'headers' => $headers
128 $this->
output(
"Queued headers update for file '{$row->img_name}'.\n" );
131 $start = $row->img_name;
134 $backendOperationsCount = count( $backendOperations );
135 $count += $backendOperationsCount;
137 $this->
output(
"Updating headers for {$backendOperationsCount} file(s).\n" );
139 }
while ( $res->numRows() === $this->getBatchSize() );
141 $this->
output(
"Done. Updated headers for $count file(s).\n" );