SECURITY: Escape internal error message
[lhc/web/wiklou.git] / maintenance / importImages.php
index 4a3d2d6..e733b9a 100644 (file)
@@ -185,9 +185,7 @@ class ImportImages extends Maintenance {
                # Batch "upload" operation
                $count = count( $files );
                if ( $count > 0 ) {
-
                        foreach ( $files as $file ) {
-
                                if ( $sleep && ( $processed > 0 ) ) {
                                        sleep( $sleep );
                                }
@@ -307,7 +305,9 @@ 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 );
                                        } else {
                                                $publishOptions['headers'] = [];
                                        }
@@ -334,7 +334,7 @@ class ImportImages extends Maintenance {
                                        $commentText,
                                        $props,
                                        $timestamp
-                               ) ) {
+                               )->isOK() ) {
                                        # We're done!
                                        $this->output( "done.\n" );
 
@@ -497,7 +497,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( '#<ii comment="([^"]*)" />#', $body, $matches ) == 0 ) {
                        return false;
@@ -508,7 +508,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( '#<ii user="([^"]*)" />#', $body, $matches ) == 0 ) {
                        return false;