MediaWiki  master
MessageCacheUpdate.php
Go to the documentation of this file.
1 <?php
24 use Wikimedia\Assert\Assert;
25 
34  private $replacements = [];
35 
41  public function __construct( $code, $title, $msg ) {
42  $this->replacements[$code][] = [ $title, $msg ];
43  }
44 
45  public function merge( MergeableUpdate $update ) {
47  Assert::parameterType( __CLASS__, $update, '$update' );
48  '@phan-var self $update';
49 
50  foreach ( $update->replacements as $code => $messages ) {
51  $this->replacements[$code] = array_merge( $this->replacements[$code] ?? [], $messages );
52  }
53  }
54 
55  public function doUpdate() {
56  $messageCache = MediaWikiServices::getInstance()->getMessageCache();
57  foreach ( $this->replacements as $code => $replacements ) {
58  $messageCache->refreshAndReplaceInternal( $code, $replacements );
59  }
60  }
61 }
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:152
MessageCacheUpdate\merge
merge(MergeableUpdate $update)
Merge this update with $update.
Definition: MessageCacheUpdate.php:45
MessageCacheUpdate\doUpdate
doUpdate()
Perform the actual work.
Definition: MessageCacheUpdate.php:55
MergeableUpdate
Interface that deferrable updates can implement to signal that updates can be combined.
Definition: MergeableUpdate.php:20
MessageCacheUpdate\__construct
__construct( $code, $title, $msg)
Definition: MessageCacheUpdate.php:41
$title
$title
Definition: testCompression.php:38
MessageCacheUpdate
Message cache purging and in-place update handler for specific message page changes.
Definition: MessageCacheUpdate.php:32
MessageCacheUpdate\$replacements
array[] $replacements
Map of (language code => list of (DB key, DB key without code))
Definition: MessageCacheUpdate.php:34
DeferrableUpdate
Interface that deferrable updates should implement.
Definition: DeferrableUpdate.php:11