X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FimportImages.php;h=f0c6569acef95708e522f6b75fd9b9f4dfa345bb;hb=427798373755e245d666fb956c0a9eb8bd81a762;hp=a0402483acbb586f9b3321e86746812e7dc2a034;hpb=91d69e12e1d2e00953cae3c153e37f3d36e5903c;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importImages.php b/maintenance/importImages.php index a0402483ac..f0c6569ace 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -32,10 +32,10 @@ * @author Mij */ -$optionsWithArgs = array( +$optionsWithArgs = [ 'extensions', 'comment', 'comment-file', 'comment-ext', 'summary', 'user', 'license', 'sleep', 'limit', 'from', 'source-wiki-url', 'timestamp', -); +]; require_once __DIR__ . '/commandLine.inc'; require_once __DIR__ . '/importImages.inc'; $processed = $added = $ignored = $skipped = $overwritten = $failed = 0; @@ -70,9 +70,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; @@ -136,7 +136,7 @@ $count = count( $files ); if ( $count > 0 ) { foreach ( $files as $file ) { - $base = wfBaseName( $file ); + $base = UtfNormal\Validator::cleanUp( wfBaseName( $file ) ); # Validate a title $title = Title::makeTitleSafe( NS_FILE, $base ); @@ -241,12 +241,12 @@ 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() ) { @@ -299,13 +299,13 @@ if ( $count > 0 ) { 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 +328,7 @@ if ( $count > 0 ) { # Print out some statistics echo "\n"; foreach ( - array( + [ 'count' => 'Found', 'limit' => 'Limit', 'ignored' => 'Ignored', @@ -336,7 +336,7 @@ if ( $count > 0 ) { 'skipped' => 'Skipped', 'overwritten' => 'Overwritten', 'failed' => 'Failed' - ) as $var => $desc + ] as $var => $desc ) { if ( $$var > 0 ) { echo "{$desc}: {$$var}\n";