diff options
Diffstat (limited to 'MLEB/Translate/api/ApiAggregateGroups.php')
-rw-r--r-- | MLEB/Translate/api/ApiAggregateGroups.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/MLEB/Translate/api/ApiAggregateGroups.php b/MLEB/Translate/api/ApiAggregateGroups.php index 7e403d84..581fb70c 100644 --- a/MLEB/Translate/api/ApiAggregateGroups.php +++ b/MLEB/Translate/api/ApiAggregateGroups.php @@ -8,6 +8,8 @@ * @license GPL-2.0-or-later */ +use MediaWiki\Logger\LoggerFactory; + /** * API module for managing aggregate message groups * Only supports aggregate message groups defined inside the wiki. @@ -39,8 +41,6 @@ class ApiAggregateGroups extends ApiBase { // means the group does not exist or something has gone wrong. $this->dieWithError( 'apierror-translate-invalidaggregategroup', 'invalidaggregategroup' ); - // For static analysers - $subgroups = []; } $subgroupId = $params['group']; @@ -89,9 +89,21 @@ class ApiAggregateGroups extends ApiBase { if ( !isset( $params['aggregategroup'] ) ) { $this->dieWithError( [ 'apierror-missingparam', 'aggregategroup' ] ); } - TranslateMetadata::deleteGroup( $params['aggregategroup'] ); - // @todo Logging + $aggregateGroupId = $params['aggregategroup']; + $group = MessageGroups::getGroup( $aggregateGroupId ); + if ( !$group || !( $group instanceof AggregateMessageGroup ) ) { + $this->dieWithError( + 'apierror-translate-invalidaggregategroupname', 'invalidaggregategroupname' + ); + } + + TranslateMetadata::deleteGroup( $params['aggregategroup'] ); + $logger = LoggerFactory::getInstance( 'Translate' ); + $logger->info( + 'Aggregate group {groupId} has been deleted.', + [ 'groupId' => $aggregateGroupId ] + ); } elseif ( $action === 'add' ) { if ( !isset( $params['groupname'] ) ) { $this->dieWithError( [ 'apierror-missingparam', 'groupname' ] ); |