Merge "Move DatabaseBase to a class alias for type-hints"
[lhc/web/wiklou.git] / maintenance / importImages.inc
index ae93287..fc9428d 100644 (file)
@@ -35,7 +35,7 @@ function findFiles( $dir, $exts, $recurse = false ) {
        if ( is_dir( $dir ) ) {
                $dhl = opendir( $dir );
                if ( $dhl ) {
-                       $files = array();
+                       $files = [];
                        while ( ( $file = readdir( $dhl ) ) !== false ) {
                                if ( is_file( $dir . '/' . $file ) ) {
                                        list( /* $name */, $ext ) = splitFilename( $dir . '/' . $file );
@@ -46,12 +46,13 @@ function findFiles( $dir, $exts, $recurse = false ) {
                                        $files = array_merge( $files, findFiles( $dir . '/' . $file, $exts, true ) );
                                }
                        }
+
                        return $files;
                } else {
-                       return array();
+                       return [];
                }
        } else {
-               return array();
+               return [];
        }
 }
 
@@ -63,10 +64,11 @@ function findFiles( $dir, $exts, $recurse = false ) {
  */
 function splitFilename( $filename ) {
        $parts = explode( '.', $filename );
-       $ext = $parts[ count( $parts ) - 1 ];
-       unset( $parts[ count( $parts ) - 1 ] );
+       $ext = $parts[count( $parts ) - 1];
+       unset( $parts[count( $parts ) - 1] );
        $fname = implode( '.', $parts );
-       return array( $fname, $ext );
+
+       return [ $fname, $ext ];
 }
 
 /**
@@ -110,10 +112,12 @@ function findAuxFile( $file, $auxExtension, $maxStrip = 1 ) {
        return false;
 }
 
-# FIXME: Access the api in a saner way and performing just one query (preferably batching files too).
+# @todo FIXME: Access the api in a saner way and performing just one query
+# (preferably batching files too).
 function getFileCommentFromSourceWiki( $wiki_host, $file ) {
-       $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=comment';
-       $body = Http::get( $url );
+       $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:'
+               . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=comment';
+       $body = Http::get( $url, [], __METHOD__ );
        if ( preg_match( '#<ii comment="([^"]*)" />#', $body, $matches ) == 0 ) {
                return false;
        }
@@ -122,12 +126,12 @@ function getFileCommentFromSourceWiki( $wiki_host, $file ) {
 }
 
 function getFileUserFromSourceWiki( $wiki_host, $file ) {
-       $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user';
-       $body = Http::get( $url );
+       $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:'
+               . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user';
+       $body = Http::get( $url, [], __METHOD__ );
        if ( preg_match( '#<ii user="([^"]*)" />#', $body, $matches ) == 0 ) {
                return false;
        }
 
        return html_entity_decode( $matches[1] );
 }
-