17 public function __construct() {
18 parent::__construct();
19 $this->addDescription(
'Clear the contents of the group synchronization cache for a single or all groups' );
23 '(optional) Group Id being cleared',
29 '(optional) Clear all groups'
32 $this->requireExtension(
'Translate' );
35 public function execute() {
36 $config = MediaWikiServices::getInstance()->getMainConfig();
38 if ( !$config->get(
'TranslateGroupSynchronizationCache' ) ) {
39 $this->fatalError(
'GroupSynchronizationCache is not enabled' );
42 $this->validateParamsAndArgs();
43 $groupId = $this->getOption(
'group' );
44 $all = $this->hasOption(
'all' );
45 $groupSyncCache = Services::getInstance()->getGroupSynchronizationCache();
48 $this->clearGroupFromSync( $groupSyncCache, $groupId );
49 $this->output(
"Ended synchronization for group: $groupId\n" );
52 $groupsInSync = $groupSyncCache->getGroupsInSync();
53 $this->output(
'Found ' . count( $groupsInSync ) .
" groups in sync.\n" );
54 foreach ( $groupsInSync as $groupId ) {
55 $this->clearGroupFromSync( $groupSyncCache, $groupId );
56 $this->output(
"Ended synchronization for group: $groupId\n" );
61 public function validateParamsAndArgs() {
62 parent::validateParamsAndArgs();
64 $group = $this->getOption(
'group' );
65 $all = $this->hasOption(
'all' );
67 if ( $all && $group !==
null ) {
68 $this->fatalError(
'The "all" and "group" options cannot be used together.' );
71 if ( !$all && $group ===
null ) {
72 $this->fatalError(
'One of "all" OR "group" options must be specified.' );
78 $this->fatalError(
"$groupId is currently not being processed" );