maintenance: rebuildLocalisationCache should be DB_NONE if possible
This change should allow `rebuildLocalisationCache` to be run in a truly offline environment as long as `LCStoreDB` is not being used. Renames the `--no-clear-message-blob-store` option to `--offline` to signal that no database dependent action will be performed. Implements `getDbType()` which returns `DB_NONE` when `--offline` is passed. This will avoid maintenance setup that tries to initialize a DB load balancer. Passing `--offline` when the store class is configured as `LCStoreDB` will result in a fatal error. Bug: T260827 Bug: T237148 Change-Id: I3e69b1ffad81a8c48f11a94973e7697461bb08ff
This commit is contained in:
parent
c4895c1579
commit
d91c6627a9
1 changed files with 24 additions and 2 deletions
|
|
@ -57,7 +57,10 @@ class RebuildLocalisationCache extends Maintenance {
|
|||
true
|
||||
);
|
||||
$this->addOption(
|
||||
'no-clear-message-blob-store', "Don't clear the MessageBlobStore global cache" );
|
||||
'offline',
|
||||
'Do not perform database dependent tasks such as clearing of the MessageBlogStore ' .
|
||||
'cache. This option may not be used with the LCStoreDB store class.'
|
||||
);
|
||||
}
|
||||
|
||||
public function finalSetup() {
|
||||
|
|
@ -98,6 +101,12 @@ class RebuildLocalisationCache extends Maintenance {
|
|||
if ( $this->hasOption( 'store-class' ) ) {
|
||||
$conf['storeClass'] = $this->getOption( 'store-class' );
|
||||
}
|
||||
|
||||
// Use of LCStoreDB prohibits us from functioning offline
|
||||
if ( $conf['storeClass'] == 'LCStoreDB' && $this->hasOption( 'offline' ) ) {
|
||||
$this->fatalError( 'LCStoreDB cannot function in offline mode.' );
|
||||
}
|
||||
|
||||
// XXX Copy-pasted from ServiceWiring.php. Do we need a factory for this one caller?
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$lc = new LocalisationCacheBulkLoad(
|
||||
|
|
@ -108,7 +117,7 @@ class RebuildLocalisationCache extends Maintenance {
|
|||
),
|
||||
LocalisationCache::getStoreFromConf( $conf, $wgCacheDirectory ),
|
||||
LoggerFactory::getInstance( 'localisation' ),
|
||||
$this->hasOption( 'no-clear-message-blob-store' ) ? [] :
|
||||
$this->hasOption( 'offline' ) ? [] :
|
||||
[ static function () use ( $services ) {
|
||||
MessageBlobStore::clearGlobalCacheEntry( $services->getMainWANObjectCache() );
|
||||
} ],
|
||||
|
|
@ -209,6 +218,19 @@ class RebuildLocalisationCache extends Maintenance {
|
|||
return $numRebuilt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database access is not required if the 'offline' option is passed.
|
||||
*
|
||||
* @return int DB constant
|
||||
*/
|
||||
public function getDbType() {
|
||||
if ( $this->hasOption( 'offline' ) ) {
|
||||
return Maintenance::DB_NONE;
|
||||
}
|
||||
|
||||
return parent::getDbType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether a run of this maintenance script has the force parameter set
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue