summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/src/Synchronization/ManageGroupSynchronizationCacheActionApi.php')
-rw-r--r--MLEB/Translate/src/Synchronization/ManageGroupSynchronizationCacheActionApi.php25
1 files changed, 22 insertions, 3 deletions
diff --git a/MLEB/Translate/src/Synchronization/ManageGroupSynchronizationCacheActionApi.php b/MLEB/Translate/src/Synchronization/ManageGroupSynchronizationCacheActionApi.php
index 9c6127bf..903aa7e2 100644
--- a/MLEB/Translate/src/Synchronization/ManageGroupSynchronizationCacheActionApi.php
+++ b/MLEB/Translate/src/Synchronization/ManageGroupSynchronizationCacheActionApi.php
@@ -9,6 +9,7 @@ use Exception;
use FormatJson;
use MediaWiki\Logger\LoggerFactory;
use MessageGroups;
+use Psr\Log\LoggerInterface;
/**
* Api module for managing group synchronization cache
@@ -22,10 +23,13 @@ class ManageGroupSynchronizationCacheActionApi extends ApiBase {
private const VALID_OPS = [ 'resolveMessage', 'resolveGroup' ];
/** @var GroupSynchronizationCache */
private $groupSyncCache;
+ /** @var LoggerInterface */
+ private $groupSyncLog;
public function __construct( ApiMain $mainModule, $moduleName, GroupSynchronizationCache $groupSyncCache ) {
parent::__construct( $mainModule, $moduleName );
$this->groupSyncCache = $groupSyncCache;
+ $this->groupSyncLog = LoggerFactory::getInstance( 'Translate.GroupSynchronization' );
}
public function execute() {
@@ -38,13 +42,13 @@ class ManageGroupSynchronizationCacheActionApi extends ApiBase {
$group = MessageGroups::getGroup( $groupId );
if ( $group === null ) {
- return $this->dieWithError( 'apierror-translate-invalidgroup', 'invalidgroup' );
+ $this->dieWithError( 'apierror-translate-invalidgroup', 'invalidgroup' );
}
try {
if ( $operation === 'resolveMessage' ) {
if ( $titleStr === null ) {
- return $this->dieWithError( [ 'apierror-missingparam', 'title' ] );
+ $this->dieWithError( [ 'apierror-missingparam', 'title' ] );
}
$this->markAsResolved( $groupId, $titleStr );
} elseif ( $operation === 'resolveGroup' ) {
@@ -56,7 +60,7 @@ class ManageGroupSynchronizationCacheActionApi extends ApiBase {
'exceptionMessage' => $e->getMessage()
];
- LoggerFactory::getInstance( 'Translate.GroupSynchronization' )->error(
+ $this->groupSyncLog->error(
"Error while running: ManageGroupSynchronizationCacheActionApi::execute. Details: \n" .
FormatJson::encode( $data, true )
);
@@ -73,9 +77,24 @@ class ManageGroupSynchronizationCacheActionApi extends ApiBase {
private function markAsResolved( string $groupId, ?string $messageTitle = null ): void {
if ( $messageTitle === null ) {
$currentGroupStatus = $this->groupSyncCache->markGroupAsResolved( $groupId );
+ $this->groupSyncLog->info(
+ '{user} resolved group {groupId}.',
+ [
+ 'user' => $this->getUser()->getName(),
+ 'groupId' => $groupId
+ ]
+ );
} else {
$this->groupSyncCache->markMessageAsResolved( $groupId, $messageTitle );
$currentGroupStatus = $this->groupSyncCache->syncGroupErrors( $groupId );
+ $this->groupSyncLog->info(
+ '{user} resolved message {messageTitle} in group {groupId}.',
+ [
+ 'user' => $this->getUser()->getName(),
+ 'groupId' => $groupId,
+ 'messageTitle' => $messageTitle
+ ]
+ );
}
$this->getResult()->addValue( null, $this->getModuleName(), [