* using the web-based interface.
*
* "Smart import" additions:
- * - aim: preserve the essential metadata (user, description) when importing medias from an existing wiki
+ * - aim: preserve the essential metadata (user, description) when importing media
+ * files from an existing wiki.
* - process:
* - interface with the source wiki, don't use bare files only (see --source-wiki-url).
* - fetch metadata from source wiki for each file to import.
}
# Get --from
-$from = @$options['from'];
+wfSuppressWarnings();
+$from = $options['from'];
+wfRestoreWarnings();
# Get sleep time.
-$sleep = @$options['sleep'];
+wfSuppressWarnings();
+$sleep = $options['sleep'];
+wfRestoreWarnings();
+
if ( $sleep ) {
$sleep = (int)$sleep;
}
# Get limit number
-$limit = @$options['limit'];
+wfSuppressWarnings();
+$limit = $options['limit'];
+wfRestoreWarnings();
+
if ( $limit ) {
$limit = (int)$limit;
}
} else {
if ( isset( $options['skip-dupes'] ) ) {
$repo = $image->getRepo();
- $sha1 = File::sha1Base36( $file ); # XXX: we end up calculating this again when actually uploading. that sucks.
+ # XXX: we end up calculating this again when actually uploading. that sucks.
+ $sha1 = File::sha1Base36( $file );
$dupes = $repo->findBySha1( $sha1 );
if ( $commentExt ) {
$f = findAuxFile( $file, $commentExt );
if ( !$f ) {
- echo " No comment file with extension {$commentExt} found for {$file}, using default comment. ";
+ echo " No comment file with extension {$commentExt} found "
+ . "for {$file}, using default comment. ";
} else {
$commentText = file_get_contents( $f );
if ( !$commentText ) {
if ( isset( $options['dry'] ) ) {
echo "done.\n";
- } elseif ( $image->recordUpload2( $archive->value, $summary, $commentText, $props, $timestamp ) ) {
+ } elseif ( $image->recordUpload2(
+ $archive->value,
+ $summary,
+ $commentText,
+ $props,
+ $timestamp
+ ) ) {
# We're done!
echo "done.\n";
<dir> : Path to the directory containing images to be imported
Options:
---extensions=<exts> Comma-separated list of allowable extensions, defaults to \$wgFileExtensions
---overwrite Overwrite existing images with the same name (default is to skip them)
---limit=<num> Limit the number of images to process. Ignored or skipped images are not counted.
---from=<name> Ignore all files until the one with the given name. Useful for resuming
- aborted imports. <name> should be the file's canonical database form.
---skip-dupes Skip images that were already uploaded under a different name (check SHA1)
---search-recursively Search recursively for files in subdirectories
+--extensions=<exts> Comma-separated list of allowable extensions, defaults
+ to \$wgFileExtensions.
+--overwrite Overwrite existing images with the same name (default
+ is to skip them).
+--limit=<num> Limit the number of images to process. Ignored or
+ skipped images are not counted.
+--from=<name> Ignore all files until the one with the given name.
+ Useful for resuming aborted imports. <name> should be
+ the file's canonical database form.
+--skip-dupes Skip images that were already uploaded under a different
+ name (check SHA1).
+--search-recursively Search recursively for files in subdirectories.
--sleep=<sec> Sleep between files. Useful mostly for debugging.
---user=<username> Set username of uploader, default 'Maintenance script'
+--user=<username> Set username of uploader, default 'Maintenance script'.
--check-userblock Check if the user got blocked during import.
--comment=<text> Set file description, default 'Importing file'.
--comment-file=<file> Set description to the content of <file>.
---comment-ext=<ext> Causes the description for each file to be loaded from a file with the same name
- but the extension <ext>. If a global description is also given, it is appended.
---license=<code> Use an optional license template
---dry Dry run, don't import anything
---protect=<protect> Specify the protect value (autoconfirmed,sysop)
---summary=<summary> Upload summary, description will be used if not provided
---timestamp=<timestamp> Override upload time/date, all MediaWiki timestamp formats are accepted
---unprotect Unprotects all uploaded images
---source-wiki-url If specified, take User and Comment data for each imported file from this URL.
- For example, --source-wiki-url="http://en.wikipedia.org/"
+--comment-ext=<ext> Causes the description for each file to be loaded from a
+ file with the same name, but the extension <ext>. If a
+ global description is also given, it is appended.
+--license=<code> Use an optional license template.
+--dry Dry run, don't import anything.
+--protect=<protect> Specify the protect value (autoconfirmed,sysop).
+--summary=<summary> Upload summary, description will be used if not
+ provided.
+--timestamp=<timestamp> Override upload time/date, all MediaWiki timestamp
+ formats are accepted.
+--unprotect Unprotects all uploaded images.
+--source-wiki-url If specified, take User and Comment data for each
+ imported file from this URL. For example,
+ --source-wiki-url="http://en.wikipedia.org/."
TEXT;
exit( 1 );
public function __construct() {
parent::__construct();
$this->mDescription = "Re-initialise the site statistics tables";
- $this->addOption( 'update', 'Update the existing statistics (preserves the ss_total_views field)' );
+ $this->addOption(
+ 'update',
+ 'Update the existing statistics (preserves the ss_total_views field)'
+ );
$this->addOption( 'noviews', "Don't update the page view counter" );
$this->addOption( 'active', 'Also update active users count' );
$this->addOption( 'use-master', 'Count using the master database' );
$this->addArg( 'admin', 'The username of the wiki administrator (WikiSysop)', true );
$this->addOption( 'pass', 'The password for the wiki administrator.', false, true );
- $this->addOption( 'passfile', 'An alternative way to provide pass option, as the contents of this file', false, true );
+ $this->addOption(
+ 'passfile',
+ 'An alternative way to provide pass option, as the contents of this file',
+ false,
+ true
+ );
/* $this->addOption( 'email', 'The email for the wiki administrator', false, true ); */
- $this->addOption( 'scriptpath', 'The relative path of the wiki in the web server (/wiki)', false, true );
+ $this->addOption(
+ 'scriptpath',
+ 'The relative path of the wiki in the web server (/wiki)',
+ false,
+ true
+ );
$this->addOption( 'lang', 'The language to use (en)', false, true );
/* $this->addOption( 'cont-lang', 'The content language (en)', false, true ); */
$this->addOption( 'installdbpass', 'The pasword for the DB user to install as.', false, true );
$this->addOption( 'dbuser', 'The user to use for normal operations (wikiuser)', false, true );
$this->addOption( 'dbpass', 'The pasword for the DB user for normal operations', false, true );
- $this->addOption( 'dbpassfile', 'An alternative way to provide dbpass option, as the contents of this file', false, true );
+ $this->addOption(
+ 'dbpassfile',
+ 'An alternative way to provide dbpass option, as the contents of this file',
+ false,
+ true
+ );
$this->addOption( 'confpath', "Path to write LocalSettings.php to, default $IP", false, true );
- /* $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */
- /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */
+ /*
+ $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true );
+ $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true );
+ */
$this->addOption( 'env-checks', "Run environment checks only, don't change anything" );
}
function execute() {
global $IP;
- $siteName = isset( $this->mArgs[0] ) ? $this->mArgs[0] : "Don't care"; // Will not be set if used with --env-checks
+
+ // Will not be set if used with --env-checks
+ $siteName = isset( $this->mArgs[0] ) ? $this->mArgs[0] : "Don't care";
$adminName = isset( $this->mArgs[1] ) ? $this->mArgs[1] : null;
$dbpassfile = $this->getOption( 'dbpassfile', false );
if ( $dbpassfile !== false ) {
if ( $this->getOption( 'dbpass', false ) !== false ) {
- $this->error( 'WARNING: You provide the options "dbpass" and "dbpassfile". The content of "dbpassfile" overwrites "dbpass".' );
+ $this->error( 'WARNING: You provide the options "dbpass" and "dbpassfile". '
+ . 'The content of "dbpassfile" overwrites "dbpass".' );
}
wfSuppressWarnings();
$dbpass = file_get_contents( $dbpassfile );
$passfile = $this->getOption( 'passfile', false );
if ( $passfile !== false ) {
if ( $this->getOption( 'pass', false ) !== false ) {
- $this->error( 'WARNING: You provide the options "pass" and "passfile". The content of "passfile" overwrites "pass".' );
+ $this->error( 'WARNING: You provide the options "pass" and "passfile". '
+ . 'The content of "passfile" overwrites "pass".' );
}
wfSuppressWarnings();
$pass = file_get_contents( $passfile );
if ( $this->hasOption( 'r' ) ) {
$lb = wfGetLB();
echo 'time ';
- for ( $i = 1; $i < $lb->getServerCount(); $i++ ) {
+
+ $serverCount = $lb->getServerCount();
+ for ( $i = 1; $i < $serverCount; $i++ ) {
$hostname = $lb->getServerName( $i );
printf( "%-12s ", $hostname );
}
function __construct() {
parent::__construct();
- $this->addOption( 'list-file', 'A file containing a list of extension setup files, one per line.', false, true );
+ $this->addOption(
+ 'list-file',
+ 'A file containing a list of extension setup files, one per line.',
+ false,
+ true
+ );
$this->addOption( 'extensions-dir', 'Path where extensions can be found.', false, true );
$this->addOption( 'output', 'Send output to this file (omit for stdout)', false, true );
$this->mDescription = 'Merge $wgExtensionMessagesFiles and $wgMessagesDirs from ' .
}
public function execute() {
- global $mmfl, $wgExtensionEntryPointListFiles;
+ // @codingStandardsIgnoreStart Ignore error: Global variable "$mmfl" is lacking 'wg' prefix
+ global $mmfl;
+ // @codingStandardsIgnoreEnd
+ global $wgExtensionEntryPointListFiles;
if ( !count( $wgExtensionEntryPointListFiles )
&& !$this->hasOption( 'list-file' )
# Setup complete, now start
$dbw = wfGetDB( DB_MASTER );
+ // @codingStandardsIgnoreStart Ignore avoid function calls in a FOR loop test part warning
for ( $linenum = 1; !feof( $file ); $linenum++ ) {
+ // @codingStandardsIgnoreEnd
$line = fgets( $file );
if ( $line === false ) {
break;
$this->lockTables( $dbw );
}
- $this->output( "Checking for orphan revision table entries... (this may take a while on a large wiki)\n" );
+ $this->output( "Checking for orphan revision table entries... "
+ . "(this may take a while on a large wiki)\n" );
$result = $dbw->query( "
SELECT *
FROM $revision LEFT OUTER JOIN $page ON rev_page=page_id
$orphans = $result->numRows();
if ( $orphans > 0 ) {
global $wgContLang;
+
$this->output( "$orphans orphan revisions...\n" );
- $this->output( sprintf( "%10s %10s %14s %20s %s\n", 'rev_id', 'rev_page', 'rev_timestamp', 'rev_user_text', 'rev_comment' ) );
+ $this->output( sprintf(
+ "%10s %10s %14s %20s %s\n",
+ 'rev_id', 'rev_page', 'rev_timestamp', 'rev_user_text', 'rev_comment'
+ ) );
+
foreach ( $result as $row ) {
$comment = ( $row->rev_comment == '' )
? ''
$this->lockTables( $dbw );
}
- $this->output( "\nChecking for childless page table entries... (this may take a while on a large wiki)\n" );
+ $this->output( "\nChecking for childless page table entries... "
+ . "(this may take a while on a large wiki)\n" );
$result = $dbw->query( "
SELECT *
FROM $page LEFT OUTER JOIN $revision ON page_latest=rev_id
$this->lockTables( $dbw, array( 'user', 'text' ) );
}
- $this->output( "\nChecking for pages whose page_latest links are incorrect... (this may take a while on a large wiki)\n" );
+ $this->output( "\nChecking for pages whose page_latest links are incorrect... "
+ . "(this may take a while on a large wiki)\n" );
$result = $dbw->query( "
SELECT *
FROM $page LEFT OUTER JOIN $revision ON page_latest=rev_id
public function __construct() {
parent::__construct();
$this->mDescription = "Parse a given wikitext";
- $this->addOption( 'title', 'Title name for the given wikitext (Default: \'CLIParser\')', false, true );
+ $this->addOption(
+ 'title',
+ 'Title name for the given wikitext (Default: \'CLIParser\')',
+ false,
+ true
+ );
$this->addArg( 'file', 'File containing wikitext (Default: stdin)', false );
}
if ( $input_file === $php_stdin ) {
$ctrl = wfIsWindows() ? 'CTRL+Z' : 'CTRL+D';
- $this->error( basename( __FILE__ ) . ": warning: reading wikitext from STDIN. Press $ctrl to parse.\n" );
+ $this->error( basename( __FILE__ )
+ . ": warning: reading wikitext from STDIN. Press $ctrl to parse.\n" );
}
return file_get_contents( $input_file );
public function __construct() {
parent::__construct();
$this->mDescription = "Run an SQL file into the DB, replacing prefix and charset vars";
- $this->addArg( 'patch-name', 'Name of the patch file, either full path or in maintenance/archives' );
+ $this->addArg(
+ 'patch-name',
+ 'Name of the patch file, either full path or in maintenance/archives'
+ );
}
public function getDbType() {
will not run again without the --force option.
TEXT;
# '
- $this->addOption( 'begin', 'Only do categories whose names are alphabetically after the provided name', false, true );
- $this->addOption( 'max-slave-lag', 'If slave lag exceeds this many seconds, wait until it drops before continuing. Default: 10', false, true );
- $this->addOption( 'throttle', 'Wait this many milliseconds after each category. Default: 0', false, true );
+ $this->addOption(
+ 'begin',
+ 'Only do categories whose names are alphabetically after the provided name',
+ false,
+ true
+ );
+ $this->addOption(
+ 'max-slave-lag',
+ 'If slave lag exceeds this many seconds, wait until it drops before continuing. Default: 10',
+ false,
+ true
+ );
+ $this->addOption(
+ 'throttle',
+ 'Wait this many milliseconds after each category. Default: 0',
+ false,
+ true
+ );
$this->addOption( 'force', 'Run regardless of whether the database says it\'s been run already' );
}