This script relied on numerous outdated or unofficial methods that
are no longer supported.
* Global variable $messageMemc holding a BagOStuff based on
MessageCacheType. This logic is now in ServiceWiring
for the MessageCache service.
* String "{$db}:messages", should have been using BagOStuff::makeKey()
and may've fallen out of sync.
* Deleting keys outright instead of touching check keys as
MessageCache does, since it's been using WANObjectCache for
several years.
All of this should be done via MessageCache::clear(), but that
can't be easily constructed across wikis on a wiki farm. That
requires instantiating the script for other wikis separately.
Remove support for that, recommending instead that site admins
run it in a loop for each wiki as needed.
Realistically though, that should never be needed. The script has
virtually no known use case, except (as documented in maintenance/README)
"after changing a wiki's content language" - which applies to one
wiki, not all a once.
Change-Id: I9f45d65f5cef93d6e332baf26d955d3f7a7c19d2
- * Purge all languages from the message cache.
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* @ingroup Maintenance
*/
* @ingroup Maintenance
*/
+use MediaWiki\MediaWikiServices;
+
require_once __DIR__ . '/Maintenance.php';
/**
require_once __DIR__ . '/Maintenance.php';
/**
- * Maintenance script that purges all languages from the message cache.
+ * Maintenance script that purges cache used by MessageCache.
*
* @ingroup Maintenance
*/
class RebuildMessages extends Maintenance {
public function __construct() {
parent::__construct();
*
* @ingroup Maintenance
*/
class RebuildMessages extends Maintenance {
public function __construct() {
parent::__construct();
- $this->addDescription( 'Purge all language messages from the cache' );
+ $this->addDescription( 'Purge the MessageCache for all interface languages.' );
}
public function execute() {
}
public function execute() {
- global $wgLocalDatabases, $wgDBname, $wgEnableSidebarCache, $messageMemc;
- if ( $wgLocalDatabases ) {
- $databases = $wgLocalDatabases;
- } else {
- $databases = [ $wgDBname ];
- }
-
- foreach ( $databases as $db ) {
- $this->output( "Deleting message cache for {$db}... " );
- $messageMemc->delete( "{$db}:messages" );
- if ( $wgEnableSidebarCache ) {
- $messageMemc->delete( "{$db}:sidebar" );
- }
- $this->output( "Deleted\n" );
- }
+ $this->output( "Purging message cache for all languages on this wiki... " );
+ $messageCache = MediaWikiServices::getInstance()->getMessageCache();
+ $messageCache->clear();
+ $this->output( "Done\n" );