MediaWiki master
MessageCacheUpdate.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Deferred;
24
26use Wikimedia\Assert\Assert;
27
36 private $replacements = [];
37
43 public function __construct( $code, $title, $msg ) {
44 $this->replacements[$code][] = [ $title, $msg ];
45 }
46
47 public function merge( MergeableUpdate $update ) {
49 Assert::parameterType( __CLASS__, $update, '$update' );
50 '@phan-var self $update';
51
52 foreach ( $update->replacements as $code => $messages ) {
53 $this->replacements[$code] = array_merge( $this->replacements[$code] ?? [], $messages );
54 }
55 }
56
57 public function doUpdate() {
58 $messageCache = MediaWikiServices::getInstance()->getMessageCache();
59 foreach ( $this->replacements as $code => $replacements ) {
60 $messageCache->refreshAndReplaceInternal( $code, $replacements );
61 }
62 }
63}
64
66class_alias( MessageCacheUpdate::class, 'MessageCacheUpdate' );
Message cache purging and in-place update handler for specific message page changes.
merge(MergeableUpdate $update)
Merge this enqueued update with a new MergeableUpdate of the same qualified class name.
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Interface that deferrable updates should implement.
Interface that deferrable updates can implement to signal that updates can be combined.