Merge "Ensure users are able to edit the page after changing the content model"
[lhc/web/wiklou.git] / maintenance / importImages.php
index f0c6569..5a4ab39 100644 (file)
@@ -36,6 +36,12 @@ $optionsWithArgs = [
        'extensions', 'comment', 'comment-file', 'comment-ext', 'summary', 'user',
        'license', 'sleep', 'limit', 'from', 'source-wiki-url', 'timestamp',
 ];
+
+$optionsWithoutArgs = [
+       'protect', 'unprotect', 'search-recursively', 'check-userblock', 'overwrite',
+       'skip-dupes', 'dry'
+];
+
 require_once __DIR__ . '/commandLine.inc';
 require_once __DIR__ . '/importImages.inc';
 $processed = $added = $ignored = $skipped = $overwritten = $failed = 0;
@@ -239,7 +245,8 @@ if ( $count > 0 ) {
                if ( isset( $options['dry'] ) ) {
                        echo " publishing {$file} by '" . $wgUser->getName() . "', comment '$commentText'... ";
                } else {
-                       $props = FSFile::getPropsFromPath( $file );
+                       $mwProps = new MWFileProps( MimeMagic::singleton() );
+                       $props = $mwProps->getPropsFromPath( $file, true );
                        $flags = 0;
                        $publishOptions = [];
                        $handler = MediaHandler::getHandler( $props['mime'] );
@@ -251,7 +258,7 @@ if ( $count > 0 ) {
                        $archive = $image->publish( $file, $flags, $publishOptions );
                        if ( !$archive->isGood() ) {
                                echo "failed. (" .
-                                       $archive->getWikiText() .
+                                       $archive->getWikiText( false, false, 'en' ) .
                                        ")\n";
                                $failed++;
                                continue;
@@ -291,8 +298,8 @@ if ( $count > 0 ) {
 
                        if ( $doProtect ) {
                                # Protect the file
-                               echo "\nWaiting for slaves...\n";
-                               // Wait for slaves.
+                               echo "\nWaiting for replica DBs...\n";
+                               // Wait for replica DBs.
                                sleep( 2.0 ); # Why this sleep?
                                wfWaitForSlaves();