Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
SerializedMessageIndex.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\MessageLoading;
5
7
23 private ?array $index = null;
24 private const FILENAME = 'translate_messageindex.ser';
25
26 public function retrieve( bool $readLatest = false ): array {
27 if ( $this->index !== null ) {
28 return $this->index;
29 }
30
31 $file = Utilities::cacheFile( self::FILENAME );
32 if ( file_exists( $file ) ) {
33 $this->index = unserialize( file_get_contents( $file ) );
34 } else {
35 $this->index = [];
36 }
37
38 return $this->index;
39 }
40
41 public function store( array $array, array $diff ): void {
42 $file = Utilities::cacheFile( self::FILENAME );
43 file_put_contents( $file, serialize( $array ) );
44 $this->index = $array;
45 }
46}
serialize( $data)
These are probably slower than serialize and unserialize, but they are more space efficient because w...
Essentially random collection of helper functions, similar to GlobalFunctions.php.
Definition Utilities.php:31