MediaWiki  1.34.0
MessageCacheUpdate.php
Go to the documentation of this file.
1 <?php
23 use Wikimedia\Assert\Assert;
24 
33  private $replacements = [];
34 
40  public function __construct( $code, $title, $msg ) {
41  $this->replacements[$code][] = [ $title, $msg ];
42  }
43 
44  public function merge( MergeableUpdate $update ) {
46  Assert::parameterType( __CLASS__, $update, '$update' );
47  '@phan-var self $update';
48 
49  foreach ( $update->replacements as $code => $messages ) {
50  $this->replacements[$code] = array_merge( $this->replacements[$code] ?? [], $messages );
51  }
52  }
53 
54  public function doUpdate() {
55  $messageCache = MessageCache::singleton();
56  foreach ( $this->replacements as $code => $replacements ) {
57  $messageCache->refreshAndReplaceInternal( $code, $replacements );
58  }
59  }
60 }
MessageCacheUpdate\merge
merge(MergeableUpdate $update)
Merge this update with $update.
Definition: MessageCacheUpdate.php:44
MessageCacheUpdate\doUpdate
doUpdate()
Perform the actual work.
Definition: MessageCacheUpdate.php:54
MergeableUpdate
Interface that deferrable updates can implement to signal that updates can be combined.
Definition: MergeableUpdate.php:18
MessageCacheUpdate\__construct
__construct( $code, $title, $msg)
Definition: MessageCacheUpdate.php:40
$title
$title
Definition: testCompression.php:34
MessageCacheUpdate
Message cache purging and in-place update handler for specific message page changes.
Definition: MessageCacheUpdate.php:31
MessageCache\singleton
static singleton()
Get the singleton instance of this class.
Definition: MessageCache.php:114
MessageCacheUpdate\$replacements
array[] $replacements
Map of (language code => list of (DB key, DB key without code))
Definition: MessageCacheUpdate.php:33
DeferrableUpdate
Interface that deferrable updates should implement.
Definition: DeferrableUpdate.php:9