}
public function execute() {
- global $wgRCMaxAge;
-
$this->initialize();
$startTS = new MWTimestamp( $this->getOption( "start" ) );
$endTS = new MWTimestamp( $this->getOption( "end" ) );
$now = new MWTimestamp();
+ $rcMaxAge = $this->getConfig()->get( 'RCMaxAge' );
- if ( $now->getTimestamp() - $startTS->getTimestamp() > $wgRCMaxAge ) {
- $this->error( "Start timestamp too old, maximum RC age is $wgRCMaxAge!" );
+ if ( $now->getTimestamp() - $startTS->getTimestamp() > $rcMaxAge ) {
+ $this->error( "Start timestamp too old, maximum RC age is $rcMaxAge!" );
}
- if ( $now->getTimestamp() - $endTS->getTimestamp() > $wgRCMaxAge ) {
- $this->error( "End timestamp too old, maximum RC age is $wgRCMaxAge!" );
+ if ( $now->getTimestamp() - $endTS->getTimestamp() > $rcMaxAge ) {
+ $this->error( "End timestamp too old, maximum RC age is $rcMaxAge!" );
}
$this->startTS = $startTS->getTimestamp();
}
private function loadThing( &$dependencies, $name, $extensions, $skins ) {
- global $wgExtensionDirectory, $wgStyleDirectory;
+ $extDir = $this->getConfig()->get( 'ExtensionDirectory' );
+ $styleDir = $this->getConfig()->get( 'StyleDirectory' );
$queue = [];
$missing = false;
foreach ( $extensions as $extension ) {
- $path = "$wgExtensionDirectory/$extension/extension.json";
+ $path = "$extDir/$extension/extension.json";
if ( file_exists( $path ) ) {
// 1 is ignored
$queue[$path] = 1;
}
foreach ( $skins as $skin ) {
- $path = "$wgStyleDirectory/$skin/skin.json";
+ $path = "$styleDir/$skin/skin.json";
if ( file_exists( $path ) ) {
$queue[$path] = 1;
$this->addToDependencies( $dependencies, [], [ $skin ], $name );
* all values are in that range. Drop ones that aren't.
*/
public function execute() {
- global $wgHiddenPrefs, $wgDefaultUserOptions;
-
$dbw = $this->getDB( DB_MASTER );
$hidden = $this->hasOption( 'hidden' );
$unknown = $this->hasOption( 'unknown' );
// Remove hidden prefs. Iterate over them to avoid the IN on a large table
if ( $hidden ) {
- if ( !$wgHiddenPrefs ) {
+ $hiddenPrefs = $this->getConfig()->get( 'HiddenPrefs' );
+ if ( !$hiddenPrefs ) {
$this->output( "No hidden preferences, skipping\n" );
}
- foreach ( $wgHiddenPrefs as $hiddenPref ) {
+ foreach ( $hiddenPrefs as $hiddenPref ) {
$this->deleteByWhere(
$dbw,
'Dropping hidden preferences',
// Remove unknown preferences. Special-case 'userjs-' as we can't control those names.
if ( $unknown ) {
+ $defaultUserOptions = $this->getConfig()->get( 'DefaultUserOptions' );
$where = [
'up_property NOT' . $dbw->buildLike( 'userjs-', $dbw->anyString() ),
- 'up_property NOT IN (' . $dbw->makeList( array_keys( $wgDefaultUserOptions ) ) . ')',
+ 'up_property NOT IN (' . $dbw->makeList( array_keys( $defaultUserOptions ) ) . ')',
];
// Allow extensions to add to the where clause to prevent deletion of their own prefs.
Hooks::run( 'DeleteUnknownPreferences', [ &$where, $dbw ] );
}
public function execute() {
- global $wgAllDBsAreLocalhost;
- if ( $wgAllDBsAreLocalhost ) {
+ if ( $this->getConfig()->get( 'AllDBsAreLocalhost' ) ) {
$host = 'localhost';
} elseif ( $this->hasOption( 'group' ) ) {
$db = $this->getDB( DB_REPLICA, $this->getOption( 'group' ) );
}
protected function doDBUpdates() {
- global $wgActorTableSchemaMigrationStage;
+ $actorTableSchemaMigrationStage = $this->getConfig()->get( 'ActorTableSchemaMigrationStage' );
- if ( !( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) ) {
+ if ( !( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) ) {
$this->output(
"...cannot update while \$wgActorTableSchemaMigrationStage lacks SCHEMA_COMPAT_WRITE_NEW\n"
);
}
protected function doDBUpdates() {
- global $wgDefaultExternalStore;
-
$replaceMissing = $this->hasOption( 'replace-missing' );
+ $defaultExternalStore = $this->getConfig()->get( 'DefaultExternalStore' );
$batchSize = $this->getBatchSize();
$dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
if ( $data !== false ) {
$flags = Revision::compressRevisionText( $data );
- if ( $wgDefaultExternalStore ) {
+ if ( $defaultExternalStore ) {
$data = ExternalStore::insertToDefault( $data );
if ( $flags ) {
$flags .= ',';
* @return bool
*/
private function checkAll( $options ) {
- global $wgNamespaceAliases, $wgCapitalLinks;
-
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
$spaces = [];
$spaces[$name] = $ns;
}
}
- foreach ( $wgNamespaceAliases as $name => $ns ) {
+ foreach ( $this->getConfig()->get( 'NamespaceAliases' ) as $name => $ns ) {
$spaces[$name] = $ns;
}
foreach ( $contLang->getNamespaceAliases() as $name => $ns ) {
// We'll need to check for lowercase keys as well,
// since we're doing case-sensitive searches in the db.
+ $capitalLinks = $this->getConfig()->get( 'CapitalLinks' );
foreach ( $spaces as $name => $ns ) {
$moreNames = [];
$moreNames[] = $contLang->uc( $name );
$moreNames[] = $contLang->ucwords( $contLang->lc( $name ) );
$moreNames[] = $contLang->ucwordbreaks( $name );
$moreNames[] = $contLang->ucwordbreaks( $contLang->lc( $name ) );
- if ( !$wgCapitalLinks ) {
+ if ( !$capitalLinks ) {
foreach ( $moreNames as $altName ) {
$moreNames[] = $contLang->lcfirst( $altName );
}
}
public function execute() {
- global $wgMultiContentRevisionSchemaMigrationStage;
+ $multiContentRevisionSchemaMigrationStage =
+ $this->getConfig()->get( 'MultiContentRevisionSchemaMigrationStage' );
$t0 = microtime( true );
- if ( ( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) === 0 ) {
+ if ( ( $multiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) === 0 ) {
$this->writeln(
'...cannot update while \$wgMultiContentRevisionSchemaMigrationStage '
. 'does not have the SCHEMA_COMPAT_WRITE_NEW bit set.'
// with the database write operation, because the writes are queued
// in the pipe buffer. This can improve performance by up to a
// factor of 2.
- global $wgDBuser, $wgDBserver, $wgDBpassword, $wgDBname;
- $cmd = 'mysql -u' . Shell::escape( $wgDBuser ) .
- ' -h' . Shell::escape( $wgDBserver ) .
- ' -p' . Shell::escape( $wgDBpassword, $wgDBname );
+ $config = $this->getConfig();
+ $cmd = 'mysql -u' . Shell::escape( $config->get( 'DBuser' ) ) .
+ ' -h' . Shell::escape( $config->get( 'DBserver' ) ) .
+ ' -p' . Shell::escape( $config->get( 'DBpassword' ), $config->get( 'DBname' ) );
$this->output( "Using pipe method\n" );
$pipe = popen( $cmd, 'w' );
}
* @return int Number of entries changed, or that would be changed
*/
private function doReassignEdits( &$from, &$to, $rc = false, $report = false ) {
- global $wgActorTableSchemaMigrationStage;
+ $actorTableSchemaMigrationStage = $this->getConfig()->get( 'ActorTableSchemaMigrationStage' );
$dbw = $this->getDB( DB_MASTER );
$this->beginTransaction( $dbw, __METHOD__ );
if ( $total ) {
# Reassign edits
$this->output( "\nReassigning current edits..." );
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
+ if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
$dbw->update(
'revision',
[
__METHOD__
);
}
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
+ if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
$dbw->update(
'revision_actor_temp',
[ 'revactor_actor' => $to->getActorId( $dbw ) ],
* @return array
*/
private function userSpecification( IDatabase $dbw, &$user, $idfield, $utfield, $acfield ) {
- global $wgActorTableSchemaMigrationStage;
+ $actorTableSchemaMigrationStage = $this->getConfig()->get( 'ActorTableSchemaMigrationStage' );
$ret = [];
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
+ if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
$ret += [
$idfield => $user->getId(),
$utfield => $user->getName(),
];
}
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
+ if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
$ret += [ $acfield => $user->getActorId( $dbw ) ];
}
return $ret;
}
public function execute() {
- global $wgActorTableSchemaMigrationStage;
+ $actorTableSchemaMigrationStage = $this->getConfig()->get( 'ActorTableSchemaMigrationStage' );
$this->output( "Remove unused accounts\n\n" );
$delUser = [];
$delActor = [];
$dbr = $this->getDB( DB_REPLICA );
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
+ if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
$res = $dbr->select(
[ 'user', 'actor' ],
[ 'user_id', 'user_name', 'user_touched', 'actor_id' ],
$this->output( "\nDeleting unused accounts..." );
$dbw = $this->getDB( DB_MASTER );
$dbw->delete( 'user', [ 'user_id' => $delUser ], __METHOD__ );
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
+ if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
# Keep actor rows referenced from ipblocks
$keep = $dbw->selectFieldValues(
'ipblocks', 'ipb_by_actor', [ 'ipb_by_actor' => $delActor ], __METHOD__
$dbw->delete( 'user_groups', [ 'ug_user' => $delUser ], __METHOD__ );
$dbw->delete( 'user_former_groups', [ 'ufg_user' => $delUser ], __METHOD__ );
$dbw->delete( 'user_properties', [ 'up_user' => $delUser ], __METHOD__ );
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
+ if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
$dbw->delete( 'logging', [ 'log_actor' => $delActor ], __METHOD__ );
$dbw->delete( 'recentchanges', [ 'rc_actor' => $delActor ], __METHOD__ );
}
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
+ if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
$dbw->delete( 'logging', [ 'log_user' => $delUser ], __METHOD__ );
$dbw->delete( 'recentchanges', [ 'rc_user' => $delUser ], __METHOD__ );
}
public function __construct() {
parent::__construct();
- global $wgCategoryCollation;
+ $categoryCollation = $this->getConfig()->get( 'CategoryCollation' );
$this->addDescription( <<<TEXT
This script will find all rows in the categorylinks table whose collation is
-out-of-date (cl_collation != '$wgCategoryCollation') and repopulate cl_sortkey
+out-of-date (cl_collation != '$categoryCollation') and repopulate cl_sortkey
using the page title and cl_sortkey_prefix. If all collations are
up-to-date, it will do nothing.
TEXT
}
public function execute() {
- global $wgCategoryCollation;
-
$dbw = $this->getDB( DB_MASTER );
$dbr = $this->getDB( DB_REPLICA );
$force = $this->getOption( 'force' );
$collationName = $this->getOption( 'target-collation' );
$collation = Collation::factory( $collationName );
} else {
- $collationName = $wgCategoryCollation;
+ $collationName = $this->getConfig()->get( 'CategoryCollation' );
$collation = Collation::singleton();
}