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 private PersistentCache $cache;
39 private int $initialTimeoutSeconds;
40 private int $incrementalTimeoutSeconds;
42 private const GROUP_LIST_TAG = 'gsc_%group_in_sync%';
44 private const GROUP_ERROR_TAG = 'gsc_%group_with_error%';
46 private const GROUP_IN_REVIEW_TAG = 'gsc_%group_in_review%';
47 private LoggerInterface $logger;
48
49 public function __construct(
50 PersistentCache $cache,
51 int $initialTimeoutSeconds = 2400,
52 int $incrementalTimeoutSeconds = 600
53
54 ) {
55 $this->cache = $cache;
56 // The timeout is set to 40 minutes initially, and then incremented by 10 minutes
57 // each time a message is marked as processed if group is about to expire.
58 $this->initialTimeoutSeconds = $initialTimeoutSeconds;
59 $this->incrementalTimeoutSeconds = $incrementalTimeoutSeconds;
60 $this->logger = LoggerFactory::getInstance( LogNames::GROUP_SYNCHRONIZATION );
61 }
62
67 public function getGroupsInSync(): array {
68 $groupsInSyncEntries = $this->cache->getByTag( self::GROUP_LIST_TAG );
69 $groups = [];
70 foreach ( $groupsInSyncEntries as $entry ) {
71 $groups[] = $entry->value();
72 }
73
74 return $groups;
75 }
76
78 public function markGroupForSync( string $groupId ): void {
79 $expTime = $this->getExpireTime( $this->initialTimeoutSeconds );
80 $this->cache->set(
82 $this->getGroupKey( $groupId ),
83 $groupId,
84 $expTime,
85 self::GROUP_LIST_TAG
86 )
87 );
88 $this->logger->debug( 'Started sync for group {groupId}', [ 'groupId' => $groupId ] );
89 }
90
91 public function getSyncEndTime( string $groupId ): ?int {
92 $cacheEntry = $this->cache->get( $this->getGroupKey( $groupId ) );
93 return $cacheEntry ? $cacheEntry[0]->exptime() : null;
94 }
95
97 public function endSync( string $groupId ): void {
98 if ( $this->cache->hasEntryWithTag( $this->getGroupTag( $groupId ) ) ) {
99 throw new InvalidArgumentException(
100 'Cannot end synchronization for a group that still has messages to be processed.'
101 );
102 }
103
104 $groupKey = $this->getGroupKey( $groupId );
105 $this->cache->delete( $groupKey );
106 $this->logger->debug( 'Ended sync for group {groupId}', [ 'groupId' => $groupId ] );
107 }
108
110 public function forceEndSync( string $groupId ): void {
111 $this->cache->deleteEntriesWithTag( $this->getGroupTag( $groupId ) );
112 $this->endSync( $groupId );
113 }
114
116 public function addMessages( string $groupId, MessageUpdateParameter ...$messageParams ): void {
117 $messagesToAdd = [];
118 $groupTag = $this->getGroupTag( $groupId );
119 foreach ( $messageParams as $messageParam ) {
120 $titleKey = $this->getMessageKeys( $groupId, $messageParam->getPageName() )[0];
121 $messagesToAdd[] = new PersistentCacheEntry(
122 $titleKey,
123 $messageParam,
124 null,
125 $groupTag
126 );
127 }
128
129 $this->cache->set( ...$messagesToAdd );
130 }
131
133 public function isGroupBeingProcessed( string $groupId ): bool {
134 $groupEntry = $this->cache->get( $this->getGroupKey( $groupId ) );
135 return $groupEntry !== [];
136 }
137
144 public function getGroupMessages( string $groupId ): array {
145 $messageEntries = $this->cache->getByTag( $this->getGroupTag( $groupId ) );
146
147 $allMessageParams = [];
148 foreach ( $messageEntries as $entry ) {
149 $message = $entry->value();
150 if ( $message instanceof MessageUpdateParameter ) {
151 $allMessageParams[$message->getPageName()] = $message;
152 } else {
153 // Should not happen, but handle primarily to keep phan happy.
154 throw $this->invalidArgument( $message, MessageUpdateParameter::class );
155 }
156 }
157
158 return $allMessageParams;
159 }
160
162 public function isMessageBeingProcessed( string $groupId, string $messageKey ): bool {
163 $messageCacheKey = $this->getMessageKeys( $groupId, $messageKey );
164 return $this->cache->has( $messageCacheKey[0] );
165 }
166
168 public function getSynchronizationStatus( string $groupId ): GroupSynchronizationResponse {
169 if ( !$this->isGroupBeingProcessed( $groupId ) ) {
170 // Group is currently not being processed.
171 throw new LogicException(
172 'Sync requested for a group currently not being processed. Check if ' .
173 'group is being processed by calling isGroupBeingProcessed() first'
174 );
175 }
176
177 $remainingMessages = $this->getGroupMessages( $groupId );
178
179 // No messages are present
180 if ( !$remainingMessages ) {
181 return new GroupSynchronizationResponse( $groupId, [], false );
182 }
183
184 $syncExpTime = $this->getSyncEndTime( $groupId );
185 if ( $syncExpTime === null ) {
186 // This should not happen
187 throw new RuntimeException(
188 "Unexpected condition. Group: $groupId; Messages present, but group key not found."
189 );
190 }
191
192 $hasTimedOut = $this->hasGroupTimedOut( $syncExpTime );
193
194 return new GroupSynchronizationResponse(
195 $groupId,
196 $remainingMessages,
197 $hasTimedOut
198 );
199 }
200
202 public function removeMessages( string $groupId, string ...$messageKeys ): void {
203 $messageCacheKeys = $this->getMessageKeys( $groupId, ...$messageKeys );
204
205 $this->cache->delete( ...$messageCacheKeys );
206 }
207
208 public function addGroupErrors( GroupSynchronizationResponse $response ): void {
209 $groupId = $response->getGroupId();
210 $remainingMessages = $response->getRemainingMessages();
211
212 if ( !$remainingMessages ) {
213 throw new LogicException( 'Cannot add a group without any remaining messages to the errors list' );
214 }
215
216 $groupMessageErrorTag = $this->getGroupMessageErrorTag( $groupId );
217
218 $entriesToSave = [];
219 foreach ( $remainingMessages as $messageParam ) {
220 $titleErrorKey = $this->getMessageErrorKey( $groupId, $messageParam->getPageName() )[0];
221 $entriesToSave[] = new PersistentCacheEntry(
222 $titleErrorKey,
223 $messageParam,
224 null,
225 $groupMessageErrorTag
226 );
227 }
228
229 $this->cache->set( ...$entriesToSave );
230
231 $groupErrorKey = $this->getGroupErrorKey( $groupId );
232
233 // Check if the group already has errors
234 $groupInfo = $this->cache->get( $groupErrorKey );
235 if ( $groupInfo ) {
236 return;
237 }
238
239 // Group did not have an error previously, add it now. When adding,
240 // remove the remaining messages from the GroupSynchronizationResponse to
241 // avoid the value in the cache becoming too big. The remaining messages
242 // are stored as separate items in the cache.
243 $trimmedGroupSyncResponse = new GroupSynchronizationResponse(
244 $groupId,
245 [],
246 $response->hasTimedOut()
247 );
248
249 $entriesToSave[] = new PersistentCacheEntry(
250 $groupErrorKey,
251 $trimmedGroupSyncResponse,
252 null,
253 self::GROUP_ERROR_TAG
254 );
255
256 $this->cache->set( ...$entriesToSave );
257 }
258
263 public function getGroupsWithErrors(): array {
264 $groupsInSyncEntries = $this->cache->getByTag( self::GROUP_ERROR_TAG );
265 $groupIds = [];
266 foreach ( $groupsInSyncEntries as $entry ) {
267 $groupResponse = $entry->value();
268 if ( $groupResponse instanceof GroupSynchronizationResponse ) {
269 $groupIds[] = $groupResponse->getGroupId();
270 } else {
271 // Should not happen, but handle primarily to keep phan happy.
272 throw $this->invalidArgument( $groupResponse, GroupSynchronizationResponse::class );
273 }
274 }
275
276 return $groupIds;
277 }
278
280 public function getGroupErrorInfo( string $groupId ): GroupSynchronizationResponse {
281 $groupMessageErrorTag = $this->getGroupMessageErrorTag( $groupId );
282 $groupMessageEntries = $this->cache->getByTag( $groupMessageErrorTag );
283
284 $groupErrorKey = $this->getGroupErrorKey( $groupId );
285 $groupResponseEntry = $this->cache->get( $groupErrorKey );
286 $groupResponse = $groupResponseEntry[0] ? $groupResponseEntry[0]->value() : null;
287 if ( $groupResponse ) {
288 if ( !$groupResponse instanceof GroupSynchronizationResponse ) {
289 // Should not happen, but handle primarily to keep phan happy.
290 throw $this->invalidArgument( $groupResponse, GroupSynchronizationResponse::class );
291 }
292 } else {
293 throw new LogicException( 'Requested to fetch errors for a group that has no errors.' );
294 }
295
296 $messageParams = [];
297 foreach ( $groupMessageEntries as $messageEntries ) {
298 $messageParam = $messageEntries->value();
299 if ( $messageParam instanceof MessageUpdateParameter ) {
300 $messageParams[] = $messageParam;
301 } else {
302 // Should not happen, but handle primarily to keep phan happy.
303 throw $this->invalidArgument( $messageParam, MessageUpdateParameter::class );
304 }
305 }
306
307 return new GroupSynchronizationResponse(
308 $groupId,
309 $messageParams,
310 $groupResponse->hasTimedOut()
311 );
312 }
313
315 public function markGroupAsResolved( string $groupId ): GroupSynchronizationResponse {
316 $groupSyncResponse = $this->getGroupErrorInfo( $groupId );
317 $errorMessages = $groupSyncResponse->getRemainingMessages();
318
319 $errorMessageKeys = [];
320 foreach ( $errorMessages as $message ) {
321 $errorMessageKeys[] = $this->getMessageErrorKey( $groupId, $message->getPageName() )[0];
322 }
323
324 $this->cache->delete( ...$errorMessageKeys );
325 return $this->syncGroupErrors( $groupId );
326 }
327
329 public function markMessageAsResolved( string $groupId, string $messagePageName ): void {
330 $messageErrorKey = $this->getMessageErrorKey( $groupId, $messagePageName )[0];
331 $messageInCache = $this->cache->get( $messageErrorKey );
332 if ( !$messageInCache ) {
333 throw new InvalidArgumentException(
334 'Message does not appear to have synchronization errors'
335 );
336 }
337
338 $this->cache->delete( $messageErrorKey );
339 }
340
342 public function groupHasErrors( string $groupId ): bool {
343 $groupErrorKey = $this->getGroupErrorKey( $groupId );
344 return $this->cache->has( $groupErrorKey );
345 }
346
348 public function syncGroupErrors( string $groupId ): GroupSynchronizationResponse {
349 $groupSyncResponse = $this->getGroupErrorInfo( $groupId );
350 if ( $groupSyncResponse->getRemainingMessages() ) {
351 return $groupSyncResponse;
352 }
353
354 // No remaining messages left, remove group from errors list.
355 $groupErrorKey = $this->getGroupErrorKey( $groupId );
356 $this->cache->delete( $groupErrorKey );
357
358 return $groupSyncResponse;
359 }
360
365 public function getGroupsInReview(): array {
366 $groupsInReviewEntries = $this->cache->getByTag( self::GROUP_IN_REVIEW_TAG );
367 $groups = [];
368 foreach ( $groupsInReviewEntries as $entry ) {
369 $groups[] = $entry->value();
370 }
371
372 return $groups;
373 }
374
375 public function markGroupAsInReview( string $groupId ): void {
376 $groupReviewKey = $this->getGroupReviewKey( $groupId );
377 $this->cache->set(
378 new PersistentCacheEntry(
379 $groupReviewKey,
380 $groupId,
381 null,
382 self::GROUP_IN_REVIEW_TAG
383 )
384 );
385 $this->logger->debug( 'Group {groupId} marked for review', [ 'groupId' => $groupId ] );
386 }
387
388 public function markGroupAsReviewed( string $groupId ): void {
389 $groupReviewKey = $this->getGroupReviewKey( $groupId );
390 $this->cache->delete( $groupReviewKey );
391 $this->logger->debug( 'Group {groupId} removed from review', [ 'groupId' => $groupId ] );
392 }
393
394 public function isGroupInReview( string $groupId ): bool {
395 return $this->cache->has( $this->getGroupReviewKey( $groupId ) );
396 }
397
398 public function extendGroupExpiryTime( string $groupId ): void {
399 $groupKey = $this->getGroupKey( $groupId );
400 $groupEntry = $this->cache->get( $groupKey );
401
402 if ( $groupEntry === [] ) {
403 // Group is currently not being processed.
404 throw new LogicException(
405 'Requested extension of expiry time for a group that is not being processed. ' .
406 'Check if group is being processed by calling isGroupBeingProcessed() first'
407 );
408 }
409
410 if ( $groupEntry[0]->hasExpired() ) {
411 throw new InvalidArgumentException(
412 'Cannot extend expiry time for a group that has already expired.'
413 );
414 }
415
416 $newExpiryTime = $this->getExpireTime( $this->incrementalTimeoutSeconds );
417
418 // We start with the initial timeout minutes, we only change the timeout if the group
419 // is actually about to expire.
420 if ( $newExpiryTime < $groupEntry[0]->exptime() ) {
421 return;
422 }
423
424 $this->cache->setExpiry( $groupKey, $newExpiryTime );
425 }
426
428 public function getGroupExpiryTime( string $groupId ): int {
429 $groupKey = $this->getGroupKey( $groupId );
430 $groupEntry = $this->cache->get( $groupKey );
431 if ( $groupEntry === [] ) {
432 throw new InvalidArgumentException( "$groupId currently not in processing!" );
433 }
434
435 return $groupEntry[0]->exptime();
436 }
437
438 private function hasGroupTimedOut( int $syncExpTime ): bool {
439 return ( new DateTime() )->getTimestamp() > $syncExpTime;
440 }
441
442 private function getExpireTime( int $timeoutSeconds ): int {
443 $currentTime = ( new DateTime() )->getTimestamp();
444 return ( new DateTime() )
445 ->setTimestamp( $currentTime + $timeoutSeconds )
446 ->getTimestamp();
447 }
448
449 private function invalidArgument( $value, string $expectedType ): RuntimeException {
450 $valueType = get_debug_type( $value );
451 return new RuntimeException( "Expected $expectedType, got $valueType" );
452 }
453
454 // Cache keys / tag related functions start here.
455
456 private function getGroupTag( string $groupId ): string {
457 return 'gsc_' . $groupId;
458 }
459
460 private function getGroupKey( string $groupId ): string {
461 $hash = substr( hash( 'sha256', $groupId ), 0, 40 );
462 return substr( "{$hash}_$groupId", 0, 255 );
463 }
464
466 private function getMessageKeys( string $groupId, string ...$messages ): array {
467 $messageKeys = [];
468 foreach ( $messages as $message ) {
469 $key = $groupId . '_' . $message;
470 $hash = substr( hash( 'sha256', $key ), 0, 40 );
471 $finalKey = substr( $hash . '_' . $key, 0, 255 );
472 $messageKeys[] = $finalKey;
473 }
474
475 return $messageKeys;
476 }
477
478 private function getGroupErrorKey( string $groupId ): string {
479 $hash = substr( hash( 'sha256', $groupId ), 0, 40 );
480 return substr( "{$hash}_gsc_error_$groupId", 0, 255 );
481 }
482
484 private function getMessageErrorKey( string $groupId, string ...$messages ): array {
485 $messageKeys = [];
486 foreach ( $messages as $message ) {
487 $key = $groupId . '_' . $message;
488 $hash = substr( hash( 'sha256', $key ), 0, 40 );
489 $finalKey = substr( $hash . '_gsc_error_' . $key, 0, 255 );
490 $messageKeys[] = $finalKey;
491 }
492
493 return $messageKeys;
494 }
495
496 private function getGroupMessageErrorTag( string $groupId ): string {
497 return "gsc_%error%_$groupId";
498 }
499
500 private function getGroupReviewKey( string $groupId ): string {
501 $hash = substr( hash( 'sha256', $groupId ), 0, 40 );
502 return substr( "{$hash}_gsc_%review%_$groupId", 0, 255 );
503 }
504}
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'));}, '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(), 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: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(), LoggerFactory::getInstance(LogNames::GROUP_SUBSCRIPTION), new ServiceOptions(MessageGroupSubscription::CONSTRUCTOR_OPTIONS, $services->getMainConfig()));}, 'Translate:MessageGroupSubscriptionHookHandler'=> static function(MediaWikiServices $services):MessageGroupSubscriptionHookHandler { return new MessageGroupSubscriptionHookHandler($services->get( 'Translate:MessageGroupSubscription'), $services->getUserFactory());}, 'Translate:MessageGroupSubscriptionStore'=> static function(MediaWikiServices $services):MessageGroupSubscriptionStore { return new MessageGroupSubscriptionStore( $services->getConnectionProvider());}, '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());}, '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->getDBLoadBalancer());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);}]
@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.