X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=blobdiff_plain;f=maintenance%2FimportImages.php;h=d3967037c62149a6628ad27fd597940922534ba0;hb=d5bd85c5d18f7e0488a1b9dbc4f4baea7b660969;hp=7f2a9e1de0eeccb1f9cd7729af3260c455a8b4ba;hpb=12846c08cb7f721011952da0aebb95657d7d030c;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 7f2a9e1de0..d3967037c6 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -187,6 +187,11 @@ class ImportImages extends Maintenance { if ( $count > 0 ) { foreach ( $files as $file ) { + + if ( $sleep && ( $processed > 0 ) ) { + sleep( $sleep ); + } + $base = UtfNormal\Validator::cleanUp( wfBaseName( $file ) ); # Validate a title @@ -302,7 +307,11 @@ class ImportImages extends Maintenance { $publishOptions = []; $handler = MediaHandler::getHandler( $props['mime'] ); if ( $handler ) { - $publishOptions['headers'] = $handler->getStreamHeaders( $props['metadata'] ); + $metadata = MediaWiki\quietCall( 'unserialize', $props['metadata'] ); + + $publishOptions['headers'] = $handler->getContentHeaders( + $metadata, $props['width'], $props['height'] + ); } else { $publishOptions['headers'] = []; } @@ -375,10 +384,6 @@ class ImportImages extends Maintenance { if ( $limit && $processed >= $limit ) { break; } - - if ( $sleep ) { - sleep( $sleep ); - } } # Print out some statistics @@ -496,7 +501,7 @@ class ImportImages extends Maintenance { # (preferably batching files too). private function getFileCommentFromSourceWiki( $wiki_host, $file ) { $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' - . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=comment'; + . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=comment'; $body = Http::get( $url, [], __METHOD__ ); if ( preg_match( '##', $body, $matches ) == 0 ) { return false; @@ -507,7 +512,7 @@ class ImportImages extends Maintenance { private function getFileUserFromSourceWiki( $wiki_host, $file ) { $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' - . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user'; + . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user'; $body = Http::get( $url, [], __METHOD__ ); if ( preg_match( '##', $body, $matches ) == 0 ) { return false;