Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
GroupSynchronizationCache.php
1<?php
2declare( strict_types = 1 );
3
5
6use DateTime;
7use InvalidArgumentException;
8use LogicException;
12use MediaWiki\Logger\LoggerFactory;
13use Psr\Log\LoggerInterface;
14use RuntimeException;
15
38
40 private const GROUP_LIST_TAG = 'gsc_%group_in_sync%';
42 private const GROUP_ERROR_TAG = 'gsc_%group_with_error%';
44 private const GROUP_IN_REVIEW_TAG = 'gsc_%group_in_review%';
45 private LoggerInterface $logger;
46
47 public function __construct(
48 private readonly PersistentCache $cache,
49 private readonly int $initialTimeoutSeconds = 2400,
50 private readonly int $incrementalTimeoutSeconds = 600,
51
52 ) {
53 // The timeout is set to 40 minutes initially, and then incremented by 10 minutes
54 // each time a message is marked as processed if group is about to expire.
55 $this->logger = LoggerFactory::getInstance( LogNames::GROUP_SYNCHRONIZATION );
56 }
57
62 public function getGroupsInSync(): array {
63 $groupsInSyncEntries = $this->cache->getByTag( self::GROUP_LIST_TAG );
64 $groups = [];
65 foreach ( $groupsInSyncEntries as $entry ) {
66 $groups[] = $entry->value();
67 }
68
69 return $groups;
70 }
71
73 public function markGroupForSync( string $groupId ): void {
74 $expTime = $this->getExpireTime( $this->initialTimeoutSeconds );
75 $this->cache->set(
77 $this->getGroupKey( $groupId ),
78 $groupId,
79 $expTime,
80 self::GROUP_LIST_TAG
81 )
82 );
83 $this->logger->debug( 'Started sync for group {groupId}', [ 'groupId' => $groupId ] );
84 }
85
86 public function getSyncEndTime( string $groupId ): ?int {
87 $cacheEntry = $this->cache->get( $this->getGroupKey( $groupId ) );
88 return $cacheEntry ? $cacheEntry[0]->exptime() : null;
89 }
90
92 public function endSync( string $groupId ): void {
93 if ( $this->cache->hasEntryWithTag( $this->getGroupTag( $groupId ) ) ) {
94 throw new InvalidArgumentException(
95 'Cannot end synchronization for a group that still has messages to be processed.'
96 );
97 }
98
99 $groupKey = $this->getGroupKey( $groupId );
100 $this->cache->delete( $groupKey );
101 $this->logger->debug( 'Ended sync for group {groupId}', [ 'groupId' => $groupId ] );
102 }
103
105 public function forceEndSync( string $groupId ): void {
106 $this->cache->deleteEntriesWithTag( $this->getGroupTag( $groupId ) );
107 $this->endSync( $groupId );
108 }
109
111 public function addMessages( string $groupId, MessageUpdateParameter ...$messageParams ): void {
112 $messagesToAdd = [];
113 $groupTag = $this->getGroupTag( $groupId );
114 foreach ( $messageParams as $messageParam ) {
115 $titleKey = $this->getMessageKeys( $groupId, $messageParam->getPageName() )[0];
116 $messagesToAdd[] = new PersistentCacheEntry(
117 $titleKey,
118 $messageParam,
119 null,
120 $groupTag
121 );
122 }
123
124 $this->cache->set( ...$messagesToAdd );
125 }
126
128 public function isGroupBeingProcessed( string $groupId ): bool {
129 $groupEntry = $this->cache->get( $this->getGroupKey( $groupId ) );
130 return $groupEntry !== [];
131 }
132
139 public function getGroupMessages( string $groupId ): array {
140 $messageEntries = $this->cache->getByTag( $this->getGroupTag( $groupId ) );
141
142 $allMessageParams = [];
143 foreach ( $messageEntries as $entry ) {
144 $message = $entry->value();
145 if ( $message instanceof MessageUpdateParameter ) {
146 $allMessageParams[$message->getPageName()] = $message;
147 } else {
148 // Should not happen, but handle primarily to keep phan happy.
149 throw $this->invalidArgument( $message, MessageUpdateParameter::class );
150 }
151 }
152
153 return $allMessageParams;
154 }
155
157 public function isMessageBeingProcessed( string $groupId, string $messageKey ): bool {
158 $messageCacheKey = $this->getMessageKeys( $groupId, $messageKey );
159 return $this->cache->has( $messageCacheKey[0] );
160 }
161
163 public function getSynchronizationStatus( string $groupId ): GroupSynchronizationResponse {
164 if ( !$this->isGroupBeingProcessed( $groupId ) ) {
165 // Group is currently not being processed.
166 throw new LogicException(
167 'Sync requested for a group currently not being processed. Check if ' .
168 'group is being processed by calling isGroupBeingProcessed() first'
169 );
170 }
171
172 $remainingMessages = $this->getGroupMessages( $groupId );
173
174 // No messages are present
175 if ( !$remainingMessages ) {
176 return new GroupSynchronizationResponse( $groupId, [], false );
177 }
178
179 $syncExpTime = $this->getSyncEndTime( $groupId );
180 if ( $syncExpTime === null ) {
181 // This should not happen
182 throw new RuntimeException(
183 "Unexpected condition. Group: $groupId; Messages present, but group key not found."
184 );
185 }
186
187 $hasTimedOut = $this->hasGroupTimedOut( $syncExpTime );
188
189 return new GroupSynchronizationResponse(
190 $groupId,
191 $remainingMessages,
192 $hasTimedOut
193 );
194 }
195
197 public function removeMessages( string $groupId, string ...$messageKeys ): void {
198 $messageCacheKeys = $this->getMessageKeys( $groupId, ...$messageKeys );
199
200 $this->cache->delete( ...$messageCacheKeys );
201 }
202
203 public function addGroupErrors( GroupSynchronizationResponse $response ): void {
204 $groupId = $response->getGroupId();
205 $remainingMessages = $response->getRemainingMessages();
206
207 if ( !$remainingMessages ) {
208 throw new LogicException( 'Cannot add a group without any remaining messages to the errors list' );
209 }
210
211 $groupMessageErrorTag = $this->getGroupMessageErrorTag( $groupId );
212
213 $entriesToSave = [];
214 foreach ( $remainingMessages as $messageParam ) {
215 $titleErrorKey = $this->getMessageErrorKey( $groupId, $messageParam->getPageName() )[0];
216 $entriesToSave[] = new PersistentCacheEntry(
217 $titleErrorKey,
218 $messageParam,
219 null,
220 $groupMessageErrorTag
221 );
222 }
223
224 $this->cache->set( ...$entriesToSave );
225
226 $groupErrorKey = $this->getGroupErrorKey( $groupId );
227
228 // Check if the group already has errors
229 $groupInfo = $this->cache->get( $groupErrorKey );
230 if ( $groupInfo ) {
231 return;
232 }
233
234 // Group did not have an error previously, add it now. When adding,
235 // remove the remaining messages from the GroupSynchronizationResponse to
236 // avoid the value in the cache becoming too big. The remaining messages
237 // are stored as separate items in the cache.
238 $trimmedGroupSyncResponse = new GroupSynchronizationResponse(
239 $groupId,
240 [],
241 $response->hasTimedOut()
242 );
243
244 $entriesToSave[] = new PersistentCacheEntry(
245 $groupErrorKey,
246 $trimmedGroupSyncResponse,
247 null,
248 self::GROUP_ERROR_TAG
249 );
250
251 $this->cache->set( ...$entriesToSave );
252 }
253
258 public function getGroupsWithErrors(): array {
259 $groupsInSyncEntries = $this->cache->getByTag( self::GROUP_ERROR_TAG );
260 $groupIds = [];
261 foreach ( $groupsInSyncEntries as $entry ) {
262 $groupResponse = $entry->value();
263 if ( $groupResponse instanceof GroupSynchronizationResponse ) {
264 $groupIds[] = $groupResponse->getGroupId();
265 } else {
266 // Should not happen, but handle primarily to keep phan happy.
267 throw $this->invalidArgument( $groupResponse, GroupSynchronizationResponse::class );
268 }
269 }
270
271 return $groupIds;
272 }
273
275 public function getGroupErrorInfo( string $groupId ): GroupSynchronizationResponse {
276 $groupMessageErrorTag = $this->getGroupMessageErrorTag( $groupId );
277 $groupMessageEntries = $this->cache->getByTag( $groupMessageErrorTag );
278
279 $groupErrorKey = $this->getGroupErrorKey( $groupId );
280 $groupResponseEntry = $this->cache->get( $groupErrorKey );
281 $groupResponse = $groupResponseEntry[0] ? $groupResponseEntry[0]->value() : null;
282 if ( $groupResponse ) {
283 if ( !$groupResponse instanceof GroupSynchronizationResponse ) {
284 // Should not happen, but handle primarily to keep phan happy.
285 throw $this->invalidArgument( $groupResponse, GroupSynchronizationResponse::class );
286 }
287 } else {
288 throw new LogicException( 'Requested to fetch errors for a group that has no errors.' );
289 }
290
291 $messageParams = [];
292 foreach ( $groupMessageEntries as $messageEntries ) {
293 $messageParam = $messageEntries->value();
294 if ( $messageParam instanceof MessageUpdateParameter ) {
295 $messageParams[] = $messageParam;
296 } else {
297 // Should not happen, but handle primarily to keep phan happy.
298 throw $this->invalidArgument( $messageParam, MessageUpdateParameter::class );
299 }
300 }
301
302 return new GroupSynchronizationResponse(
303 $groupId,
304 $messageParams,
305 $groupResponse->hasTimedOut()
306 );
307 }
308
310 public function markGroupAsResolved( string $groupId ): GroupSynchronizationResponse {
311 $groupSyncResponse = $this->getGroupErrorInfo( $groupId );
312 $errorMessages = $groupSyncResponse->getRemainingMessages();
313
314 $errorMessageKeys = [];
315 foreach ( $errorMessages as $message ) {
316 $errorMessageKeys[] = $this->getMessageErrorKey( $groupId, $message->getPageName() )[0];
317 }
318
319 $this->cache->delete( ...$errorMessageKeys );
320 return $this->syncGroupErrors( $groupId );
321 }
322
324 public function markMessageAsResolved( string $groupId, string $messagePageName ): void {
325 $messageErrorKey = $this->getMessageErrorKey( $groupId, $messagePageName )[0];
326 $messageInCache = $this->cache->get( $messageErrorKey );
327 if ( !$messageInCache ) {
328 throw new InvalidArgumentException(
329 'Message does not appear to have synchronization errors'
330 );
331 }
332
333 $this->cache->delete( $messageErrorKey );
334 }
335
337 public function groupHasErrors( string $groupId ): bool {
338 $groupErrorKey = $this->getGroupErrorKey( $groupId );
339 return $this->cache->has( $groupErrorKey );
340 }
341
343 public function syncGroupErrors( string $groupId ): GroupSynchronizationResponse {
344 $groupSyncResponse = $this->getGroupErrorInfo( $groupId );
345 if ( $groupSyncResponse->getRemainingMessages() ) {
346 return $groupSyncResponse;
347 }
348
349 // No remaining messages left, remove group from errors list.
350 $groupErrorKey = $this->getGroupErrorKey( $groupId );
351 $this->cache->delete( $groupErrorKey );
352
353 return $groupSyncResponse;
354 }
355
360 public function getGroupsInReview(): array {
361 $groupsInReviewEntries = $this->cache->getByTag( self::GROUP_IN_REVIEW_TAG );
362 $groups = [];
363 foreach ( $groupsInReviewEntries as $entry ) {
364 $groups[] = $entry->value();
365 }
366
367 return $groups;
368 }
369
370 public function markGroupAsInReview( string $groupId ): void {
371 $groupReviewKey = $this->getGroupReviewKey( $groupId );
372 $this->cache->set(
373 new PersistentCacheEntry(
374 $groupReviewKey,
375 $groupId,
376 null,
377 self::GROUP_IN_REVIEW_TAG
378 )
379 );
380 $this->logger->debug( 'Group {groupId} marked for review', [ 'groupId' => $groupId ] );
381 }
382
383 public function markGroupAsReviewed( string $groupId ): void {
384 $groupReviewKey = $this->getGroupReviewKey( $groupId );
385 $this->cache->delete( $groupReviewKey );
386 $this->logger->debug( 'Group {groupId} removed from review', [ 'groupId' => $groupId ] );
387 }
388
389 public function isGroupInReview( string $groupId ): bool {
390 return $this->cache->has( $this->getGroupReviewKey( $groupId ) );
391 }
392
393 public function extendGroupExpiryTime( string $groupId ): void {
394 $groupKey = $this->getGroupKey( $groupId );
395 $groupEntry = $this->cache->get( $groupKey );
396
397 if ( $groupEntry === [] ) {
398 // Group is currently not being processed.
399 throw new LogicException(
400 'Requested extension of expiry time for a group that is not being processed. ' .
401 'Check if group is being processed by calling isGroupBeingProcessed() first'
402 );
403 }
404
405 if ( $groupEntry[0]->hasExpired() ) {
406 throw new InvalidArgumentException(
407 'Cannot extend expiry time for a group that has already expired.'
408 );
409 }
410
411 $newExpiryTime = $this->getExpireTime( $this->incrementalTimeoutSeconds );
412
413 // We start with the initial timeout minutes, we only change the timeout if the group
414 // is actually about to expire.
415 if ( $newExpiryTime < $groupEntry[0]->exptime() ) {
416 return;
417 }
418
419 $this->cache->setExpiry( $groupKey, $newExpiryTime );
420 }
421
423 public function getGroupExpiryTime( string $groupId ): int {
424 $groupKey = $this->getGroupKey( $groupId );
425 $groupEntry = $this->cache->get( $groupKey );
426 if ( $groupEntry === [] ) {
427 throw new InvalidArgumentException( "$groupId currently not in processing!" );
428 }
429
430 return $groupEntry[0]->exptime();
431 }
432
433 private function hasGroupTimedOut( int $syncExpTime ): bool {
434 return ( new DateTime() )->getTimestamp() > $syncExpTime;
435 }
436
437 private function getExpireTime( int $timeoutSeconds ): int {
438 $currentTime = ( new DateTime() )->getTimestamp();
439 return ( new DateTime() )
440 ->setTimestamp( $currentTime + $timeoutSeconds )
441 ->getTimestamp();
442 }
443
448 private function invalidArgument( $value, string $expectedType ): RuntimeException {
449 $valueType = get_debug_type( $value );
450 return new RuntimeException( "Expected $expectedType, got $valueType" );
451 }
452
453 // Cache keys / tag related functions start here.
454
455 private function getGroupTag( string $groupId ): string {
456 return 'gsc_' . $groupId;
457 }
458
459 private function getGroupKey( string $groupId ): string {
460 $hash = substr( hash( 'sha256', $groupId ), 0, 40 );
461 return substr( "{$hash}_$groupId", 0, 255 );
462 }
463
465 private function getMessageKeys( string $groupId, string ...$messages ): array {
466 $messageKeys = [];
467 foreach ( $messages as $message ) {
468 $key = $groupId . '_' . $message;
469 $hash = substr( hash( 'sha256', $key ), 0, 40 );
470 $finalKey = substr( $hash . '_' . $key, 0, 255 );
471 $messageKeys[] = $finalKey;
472 }
473
474 return $messageKeys;
475 }
476
477 private function getGroupErrorKey( string $groupId ): string {
478 $hash = substr( hash( 'sha256', $groupId ), 0, 40 );
479 return substr( "{$hash}_gsc_error_$groupId", 0, 255 );
480 }
481
483 private function getMessageErrorKey( string $groupId, string ...$messages ): array {
484 $messageKeys = [];
485 foreach ( $messages as $message ) {
486 $key = $groupId . '_' . $message;
487 $hash = substr( hash( 'sha256', $key ), 0, 40 );
488 $finalKey = substr( $hash . '_gsc_error_' . $key, 0, 255 );
489 $messageKeys[] = $finalKey;
490 }
491
492 return $messageKeys;
493 }
494
495 private function getGroupMessageErrorTag( string $groupId ): string {
496 return "gsc_%error%_$groupId";
497 }
498
499 private function getGroupReviewKey( string $groupId ): string {
500 $hash = substr( hash( 'sha256', $groupId ), 0, 40 );
501 return substr( "{$hash}_gsc_%review%_$groupId", 0, 255 );
502 }
503}
return[ 'Translate:AggregateGroupManager'=> static function(MediaWikiServices $services):AggregateGroupManager { return new AggregateGroupManager($services->getTitleFactory(), $services->get( 'Translate:MessageGroupMetadata'));}, 'Translate:AggregateGroupMessageGroupFactory'=> static function(MediaWikiServices $services):AggregateGroupMessageGroupFactory { return new AggregateGroupMessageGroupFactory($services->get( 'Translate:MessageGroupMetadata'), $services->get( 'Translate:MessageGroupFactory'),);}, 'Translate:ConfigHelper'=> static function():ConfigHelper { return new ConfigHelper();}, 'Translate:CsvTranslationImporter'=> static function(MediaWikiServices $services):CsvTranslationImporter { return new CsvTranslationImporter( $services->getWikiPageFactory());}, 'Translate:EntitySearch'=> static function(MediaWikiServices $services):EntitySearch { return new EntitySearch($services->getMainWANObjectCache(), $services->getCollationFactory() ->makeCollation( 'uca-default-u-kn'), MessageGroups::singleton(), $services->getNamespaceInfo(), $services->get( 'Translate:MessageIndex'), $services->getTitleParser(), $services->getTitleFormatter());}, 'Translate:ExternalMessageSourceStateComparator'=> static function(MediaWikiServices $services):ExternalMessageSourceStateComparator { return new ExternalMessageSourceStateComparator(new SimpleStringComparator(), $services->getRevisionLookup(), $services->getPageStore());}, 'Translate:ExternalMessageSourceStateImporter'=> static function(MediaWikiServices $services):ExternalMessageSourceStateImporter { return new ExternalMessageSourceStateImporter($services->get( 'Translate:GroupSynchronizationCache'), $services->getJobQueueGroup(), LoggerFactory::getInstance(LogNames::GROUP_SYNCHRONIZATION), $services->get( 'Translate:MessageIndex'), $services->getTitleFactory(), $services->get( 'Translate:MessageGroupSubscription'), new ServiceOptions(ExternalMessageSourceStateImporter::CONSTRUCTOR_OPTIONS, $services->getMainConfig()));}, 'Translate:FileBasedMessageGroupFactory'=> static function(MediaWikiServices $services):FileBasedMessageGroupFactory { return new FileBasedMessageGroupFactory(new MessageGroupConfigurationParser(), $services->get( 'Translate:MessageGroupFactory'), $services->getContentLanguageCode() ->toString(), new ServiceOptions(FileBasedMessageGroupFactory::SERVICE_OPTIONS, $services->getMainConfig()),);}, 'Translate:FileFormatFactory'=> static function(MediaWikiServices $services):FileFormatFactory { return new FileFormatFactory( $services->getObjectFactory());}, 'Translate:GroupSynchronizationCache'=> static function(MediaWikiServices $services):GroupSynchronizationCache { return new GroupSynchronizationCache( $services->get( 'Translate:PersistentCache'));}, 'Translate:HookDefinedMessageGroupFactory'=> static function(MediaWikiServices $services):HookDefinedMessageGroupFactory { return new HookDefinedMessageGroupFactory( $services->get( 'Translate:HookRunner'));}, 'Translate:HookRunner'=> static function(MediaWikiServices $services):HookRunner { return new HookRunner( $services->getHookContainer());}, 'Translate:MessageBundleDependencyPurger'=> static function(MediaWikiServices $services):MessageBundleDependencyPurger { return new MessageBundleDependencyPurger( $services->get( 'Translate:TranslatableBundleFactory'));}, 'Translate:MessageBundleMessageGroupFactory'=> static function(MediaWikiServices $services):MessageBundleMessageGroupFactory { return new MessageBundleMessageGroupFactory($services->get( 'Translate:MessageGroupMetadata'), new ServiceOptions(MessageBundleMessageGroupFactory::SERVICE_OPTIONS, $services->getMainConfig()),);}, 'Translate:MessageBundleStore'=> static function(MediaWikiServices $services):MessageBundleStore { return new MessageBundleStore($services->get( 'Translate:RevTagStore'), $services->getJobQueueGroup(), $services->getLanguageNameUtils(), $services->get( 'Translate:MessageIndex'), $services->get( 'Translate:MessageGroupMetadata'));}, 'Translate:MessageBundleTranslationLoader'=> static function(MediaWikiServices $services):MessageBundleTranslationLoader { return new MessageBundleTranslationLoader( $services->getLanguageFallback());}, 'Translate:MessageGroupFactory'=> static function(MediaWikiServices $services):MessageGroupFactory { return new MessageGroupFactory($services->get( 'Translate:MessageGroupTypeRegistry'));}, 'Translate:MessageGroupMetadata'=> static function(MediaWikiServices $services):MessageGroupMetadata { return new MessageGroupMetadata( $services->getConnectionProvider());}, 'Translate:MessageGroupReviewStore'=> static function(MediaWikiServices $services):MessageGroupReviewStore { return new MessageGroupReviewStore($services->getConnectionProvider(), $services->get( 'Translate:HookRunner'));}, 'Translate:MessageGroupStatsTableFactory'=> static function(MediaWikiServices $services):MessageGroupStatsTableFactory { return new MessageGroupStatsTableFactory($services->get( 'Translate:ProgressStatsTableFactory'), $services->getLinkRenderer(), $services->get( 'Translate:MessageGroupReviewStore'), $services->get( 'Translate:MessageGroupMetadata'), $services->getMainConfig() ->get( 'TranslateWorkflowStates') !==false);}, 'Translate:MessageGroupSubscription'=> static function(MediaWikiServices $services):MessageGroupSubscription { return new MessageGroupSubscription($services->get( 'Translate:MessageGroupSubscriptionStore'), $services->getJobQueueGroup(), $services->getUserIdentityLookup(), $services->getNotificationService(), LoggerFactory::getInstance(LogNames::GROUP_SUBSCRIPTION), new ServiceOptions(MessageGroupSubscription::CONSTRUCTOR_OPTIONS, $services->getMainConfig()));}, 'Translate:MessageGroupSubscriptionHookHandler'=> static function(MediaWikiServices $services):?MessageGroupSubscriptionHookHandler { if(! $services->getExtensionRegistry() ->isLoaded( 'Echo')) { return null;} return new MessageGroupSubscriptionHookHandler();}, 'Translate:MessageGroupSubscriptionStore'=> static function(MediaWikiServices $services):MessageGroupSubscriptionStore { return new MessageGroupSubscriptionStore( $services->getConnectionProvider());}, 'Translate:MessageGroupTypeRegistry'=> static function():MessageGroupTypeRegistry { return new MessageGroupTypeRegistry();}, 'Translate:MessageIndex'=> static function(MediaWikiServices $services):MessageIndex { $params=(array) $services->getMainConfig() ->get( 'TranslateMessageIndex');$class=array_shift( $params);$implementationMap=['HashMessageIndex'=> HashMessageIndex::class, 'CDBMessageIndex'=> CDBMessageIndex::class, 'DatabaseMessageIndex'=> DatabaseMessageIndex::class, 'hash'=> HashMessageIndex::class, 'cdb'=> CDBMessageIndex::class, 'database'=> DatabaseMessageIndex::class,];$messageIndexStoreClass=$implementationMap[$class] ?? $implementationMap['database'];return new MessageIndex(new $messageIndexStoreClass, $services->getMainWANObjectCache(), $services->getJobQueueGroup(), $services->get( 'Translate:HookRunner'), LoggerFactory::getInstance(LogNames::MAIN), $services->getMainObjectStash(), $services->getConnectionProvider(), new ServiceOptions(MessageIndex::SERVICE_OPTIONS, $services->getMainConfig()),);}, 'Translate:MessagePrefixStats'=> static function(MediaWikiServices $services):MessagePrefixStats { return new MessagePrefixStats( $services->getTitleParser());}, 'Translate:ParsingPlaceholderFactory'=> static function():ParsingPlaceholderFactory { return new ParsingPlaceholderFactory();}, 'Translate:PersistentCache'=> static function(MediaWikiServices $services):PersistentCache { return new PersistentDatabaseCache($services->getConnectionProvider(), $services->getJsonCodec());}, 'Translate:ProgressStatsTableFactory'=> static function(MediaWikiServices $services):ProgressStatsTableFactory { return new ProgressStatsTableFactory($services->getLinkRenderer(), $services->get( 'Translate:ConfigHelper'), $services->get( 'Translate:MessageGroupMetadata'));}, 'Translate:RevTagStore'=> static function(MediaWikiServices $services):RevTagStore { return new RevTagStore( $services->getConnectionProvider());}, 'Translate:SubpageListBuilder'=> static function(MediaWikiServices $services):SubpageListBuilder { return new SubpageListBuilder($services->get( 'Translate:TranslatableBundleFactory'), $services->getLinkBatchFactory());}, 'Translate:TranslatableBundleDeleter'=> static function(MediaWikiServices $services):TranslatableBundleDeleter { return new TranslatableBundleDeleter($services->getMainObjectStash(), $services->getJobQueueGroup(), $services->get( 'Translate:SubpageListBuilder'), $services->get( 'Translate:TranslatableBundleFactory'));}, 'Translate:TranslatableBundleExporter'=> static function(MediaWikiServices $services):TranslatableBundleExporter { return new TranslatableBundleExporter($services->get( 'Translate:SubpageListBuilder'), $services->getWikiExporterFactory(), $services->getConnectionProvider());}, 'Translate:TranslatableBundleFactory'=> static function(MediaWikiServices $services):TranslatableBundleFactory { return new TranslatableBundleFactory($services->get( 'Translate:TranslatablePageStore'), $services->get( 'Translate:MessageBundleStore'));}, 'Translate:TranslatableBundleImporter'=> static function(MediaWikiServices $services):TranslatableBundleImporter { return new TranslatableBundleImporter($services->getWikiImporterFactory(), $services->get( 'Translate:TranslatablePageParser'), $services->getRevisionLookup(), $services->getNamespaceInfo(), $services->getTitleFactory(), $services->getFormatterFactory());}, 'Translate:TranslatableBundleMover'=> static function(MediaWikiServices $services):TranslatableBundleMover { return new TranslatableBundleMover($services->getMovePageFactory(), $services->getJobQueueGroup(), $services->getLinkBatchFactory(), $services->get( 'Translate:TranslatableBundleFactory'), $services->get( 'Translate:SubpageListBuilder'), $services->getConnectionProvider(), $services->getObjectCacheFactory(), $services->getMainConfig() ->get( 'TranslatePageMoveLimit'));}, 'Translate:TranslatableBundleStatusStore'=> static function(MediaWikiServices $services):TranslatableBundleStatusStore { return new TranslatableBundleStatusStore($services->getConnectionProvider() ->getPrimaryDatabase(), $services->getCollationFactory() ->makeCollation( 'uca-default-u-kn'), $services->getDBLoadBalancer() ->getMaintenanceConnectionRef(DB_PRIMARY));}, 'Translate:TranslatablePageMarker'=> static function(MediaWikiServices $services):TranslatablePageMarker { return new TranslatablePageMarker($services->getConnectionProvider(), $services->getJobQueueGroup(), $services->getLinkRenderer(), MessageGroups::singleton(), $services->get( 'Translate:MessageIndex'), $services->getTitleFormatter(), $services->getTitleParser(), $services->get( 'Translate:TranslatablePageParser'), $services->get( 'Translate:TranslatablePageStore'), $services->get( 'Translate:TranslatablePageStateStore'), $services->get( 'Translate:TranslationUnitStoreFactory'), $services->get( 'Translate:MessageGroupMetadata'), $services->getWikiPageFactory(), $services->get( 'Translate:TranslatablePageView'), $services->get( 'Translate:MessageGroupSubscription'), $services->getFormatterFactory(), $services->get( 'Translate:HookRunner'),);}, 'Translate:TranslatablePageMessageGroupFactory'=> static function(MediaWikiServices $services):TranslatablePageMessageGroupFactory { return new TranslatablePageMessageGroupFactory(new ServiceOptions(TranslatablePageMessageGroupFactory::SERVICE_OPTIONS, $services->getMainConfig()),);}, 'Translate:TranslatablePageParser'=> static function(MediaWikiServices $services):TranslatablePageParser { return new TranslatablePageParser($services->get( 'Translate:ParsingPlaceholderFactory'));}, 'Translate:TranslatablePageStateStore'=> static function(MediaWikiServices $services):TranslatablePageStateStore { return new TranslatablePageStateStore($services->get( 'Translate:PersistentCache'), $services->getPageStore());}, 'Translate:TranslatablePageStore'=> static function(MediaWikiServices $services):TranslatablePageStore { return new TranslatablePageStore($services->get( 'Translate:MessageIndex'), $services->getJobQueueGroup(), $services->get( 'Translate:RevTagStore'), $services->getConnectionProvider(), $services->get( 'Translate:TranslatableBundleStatusStore'), $services->get( 'Translate:TranslatablePageParser'), $services->get( 'Translate:MessageGroupMetadata'));}, 'Translate:TranslatablePageView'=> static function(MediaWikiServices $services):TranslatablePageView { return new TranslatablePageView($services->getConnectionProvider(), $services->get( 'Translate:TranslatablePageStateStore'), new ServiceOptions(TranslatablePageView::SERVICE_OPTIONS, $services->getMainConfig()));}, 'Translate:TranslateSandbox'=> static function(MediaWikiServices $services):TranslateSandbox { return new TranslateSandbox($services->getUserFactory(), $services->getConnectionProvider(), $services->getPermissionManager(), $services->getAuthManager(), $services->getUserGroupManager(), $services->getActorStore(), $services->getUserOptionsManager(), $services->getJobQueueGroup(), $services->get( 'Translate:HookRunner'), new ServiceOptions(TranslateSandbox::CONSTRUCTOR_OPTIONS, $services->getMainConfig()));}, 'Translate:TranslationStashReader'=> static function(MediaWikiServices $services):TranslationStashReader { return new TranslationStashStorage( $services->getConnectionProvider() ->getPrimaryDatabase());}, 'Translate:TranslationStatsDataProvider'=> static function(MediaWikiServices $services):TranslationStatsDataProvider { return new TranslationStatsDataProvider(new ServiceOptions(TranslationStatsDataProvider::CONSTRUCTOR_OPTIONS, $services->getMainConfig()), $services->getObjectFactory(), $services->getConnectionProvider());}, 'Translate:TranslationUnitStoreFactory'=> static function(MediaWikiServices $services):TranslationUnitStoreFactory { return new TranslationUnitStoreFactory( $services->getDBLoadBalancer());}, 'Translate:TranslatorActivity'=> static function(MediaWikiServices $services):TranslatorActivity { $query=new TranslatorActivityQuery($services->getMainConfig(), $services->getConnectionProvider());return new TranslatorActivity($services->getMainObjectStash(), $query, $services->getJobQueueGroup());}, 'Translate:TtmServerFactory'=> static function(MediaWikiServices $services):TtmServerFactory { $config=$services->getMainConfig();$default=$config->get( 'TranslateTranslationDefaultService');if( $default===false) { $default=null;} return new TtmServerFactory( $config->get( 'TranslateTranslationServices'), $default);}, 'Translate:WorkflowStatesMessageGroupLoader'=> static function(MediaWikiServices $services):WorkflowStatesMessageGroupLoader { return new WorkflowStatesMessageGroupLoader(new ServiceOptions(WorkflowStatesMessageGroupLoader::CONSTRUCTOR_OPTIONS, $services->getMainConfig()),);},]
@phpcs-require-sorted-array
Represents a single result from the persistent cache.
Constants for log channel names used in this extension.
Definition LogNames.php:13
const GROUP_SYNCHRONIZATION
Channel for message group synchronization.
Definition LogNames.php:18
removeMessages(string $groupId, string ... $messageKeys)
Remove messages from the cache.
isGroupBeingProcessed(string $groupId)
Check if the group is in synchronization.
addMessages(string $groupId, MessageUpdateParameter ... $messageParams)
Add messages for a group to the cache.
isMessageBeingProcessed(string $groupId, string $messageKey)
Check if a message is being processed.
getGroupErrorInfo(string $groupId)
Fetch information about a particular group that has errors including messages that failed.
markMessageAsResolved(string $groupId, string $messagePageName)
Marks errors for a message as resolved.
markGroupForSync(string $groupId)
Start synchronization process for a group and starts the expiry time.
syncGroupErrors(string $groupId)
Checks if group has unresolved error messages.
markGroupAsResolved(string $groupId)
Marks all messages in a group and the group itself as resolved.
getSynchronizationStatus(string $groupId)
Get the current synchronization status of the group.
Class encapsulating the response returned by the GroupSynchronizationCache when requested for an upda...
Defines what method should be provided by a class implementing a persistent cache.
Finds external changes for file based message groups.