X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FimportImages.php;h=ac700ef010be3b3b55057c0ba1faaa2a3a7ba524;hb=937e602c2c56f068272f635c5867d69f00f9ef49;hp=701af6291327d97f4932d2bcb0280563bb8f9e74;hpb=a0e11fff0c12b73aa2d9083b32a066f61e55399e;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 701af62913..ac700ef010 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -32,10 +32,16 @@ * @author Mij */ -$optionsWithArgs = array( +$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; @@ -70,9 +76,9 @@ $files = findFiles( $dir, $extensions, isset( $options['search-recursively'] ) ) # Initialise the user for this operation $user = isset( $options['user'] ) ? User::newFromName( $options['user'] ) - : User::newSystemUser( 'Maintenance script', array( 'steal' => true ) ); + : User::newSystemUser( 'Maintenance script', [ 'steal' => true ] ); if ( !$user instanceof User ) { - $user = User::newSystemUser( 'Maintenance script', array( 'steal' => true ) ); + $user = User::newSystemUser( 'Maintenance script', [ 'steal' => true ] ); } $wgUser = $user; @@ -241,17 +247,17 @@ if ( $count > 0 ) { } else { $props = FSFile::getPropsFromPath( $file ); $flags = 0; - $publishOptions = array(); + $publishOptions = []; $handler = MediaHandler::getHandler( $props['mime'] ); if ( $handler ) { $publishOptions['headers'] = $handler->getStreamHeaders( $props['metadata'] ); } else { - $publishOptions['headers'] = array(); + $publishOptions['headers'] = []; } $archive = $image->publish( $file, $flags, $publishOptions ); if ( !$archive->isGood() ) { echo "failed. (" . - $archive->getWikiText() . + $archive->getWikiText( false, false, 'en' ) . ")\n"; $failed++; continue; @@ -291,21 +297,21 @@ 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(); echo "\nSetting image restrictions ... "; $cascade = false; - $restrictions = array(); + $restrictions = []; foreach ( $title->getRestrictionTypes() as $type ) { $restrictions[$type] = $protectLevel; } $page = WikiPage::factory( $title ); - $status = $page->doUpdateRestrictions( $restrictions, array(), $cascade, '', $user ); + $status = $page->doUpdateRestrictions( $restrictions, [], $cascade, '', $user ); echo ( $status->isOK() ? 'done' : 'failed' ) . "\n"; } } else { @@ -328,7 +334,7 @@ if ( $count > 0 ) { # Print out some statistics echo "\n"; foreach ( - array( + [ 'count' => 'Found', 'limit' => 'Limit', 'ignored' => 'Ignored', @@ -336,7 +342,7 @@ if ( $count > 0 ) { 'skipped' => 'Skipped', 'overwritten' => 'Overwritten', 'failed' => 'Failed' - ) as $var => $desc + ] as $var => $desc ) { if ( $$var > 0 ) { echo "{$desc}: {$$var}\n";