* @author Mij <mij@bitchx.it>
*/
-$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;
# Initialise the user for this operation
$user = isset( $options['user'] )
? User::newFromName( $options['user'] )
- : User::newFromName( 'Maintenance script' );
+ : User::newSystemUser( 'Maintenance script', [ 'steal' => true ] );
if ( !$user instanceof User ) {
- $user = User::newFromName( 'Maintenance script' );
+ $user = User::newSystemUser( 'Maintenance script', [ 'steal' => true ] );
}
$wgUser = $user;
}
# Get --from
-wfSuppressWarnings();
+MediaWiki\suppressWarnings();
$from = $options['from'];
-wfRestoreWarnings();
+MediaWiki\restoreWarnings();
# Get sleep time.
-wfSuppressWarnings();
+MediaWiki\suppressWarnings();
$sleep = $options['sleep'];
-wfRestoreWarnings();
+MediaWiki\restoreWarnings();
if ( $sleep ) {
$sleep = (int)$sleep;
}
# Get limit number
-wfSuppressWarnings();
+MediaWiki\suppressWarnings();
$limit = $options['limit'];
-wfRestoreWarnings();
+MediaWiki\restoreWarnings();
if ( $limit ) {
$limit = (int)$limit;
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 );
} 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 "\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 {
# Print out some statistics
echo "\n";
foreach (
- array(
+ [
'count' => 'Found',
'limit' => 'Limit',
'ignored' => 'Ignored',
'skipped' => 'Skipped',
'overwritten' => 'Overwritten',
'failed' => 'Failed'
- ) as $var => $desc
+ ] as $var => $desc
) {
if ( $$var > 0 ) {
echo "{$desc}: {$$var}\n";