MediaWiki  1.27.3
WANObjectCacheTest.php
Go to the documentation of this file.
1 <?php
2 
5  private $cache;
7  private $internalCache;
8 
9  protected function setUp() {
10  parent::setUp();
11 
12  if ( $this->getCliArg( 'use-wanobjectcache' ) ) {
13  $name = $this->getCliArg( 'use-wanobjectcache' );
14 
16  } else {
17  $this->cache = new WANObjectCache( [
18  'cache' => new HashBagOStuff(),
19  'pool' => 'testcache-hash',
20  'relayer' => new EventRelayerNull( [] )
21  ] );
22  }
23 
24  $wanCache = TestingAccessWrapper::newFromObject( $this->cache );
25  $this->internalCache = $wanCache->cache;
26  }
27 
35  public function testSetAndGet( $value, $ttl ) {
36  $key = wfRandomString();
37  $this->cache->set( $key, $value, $ttl );
38 
39  $curTTL = null;
40  $this->assertEquals( $value, $this->cache->get( $key, $curTTL ) );
41  if ( is_infinite( $ttl ) || $ttl == 0 ) {
42  $this->assertTrue( is_infinite( $curTTL ), "Current TTL is infinite" );
43  } else {
44  $this->assertGreaterThan( 0, $curTTL, "Current TTL > 0" );
45  $this->assertLessThanOrEqual( $ttl, $curTTL, "Current TTL < nominal TTL" );
46  }
47  }
48 
49  public static function provideSetAndGet() {
50  return [
51  [ 14141, 3 ],
52  [ 3535.666, 3 ],
53  [ [], 3 ],
54  [ null, 3 ],
55  [ '0', 3 ],
56  [ (object)[ 'meow' ], 3 ],
57  [ INF, 3 ],
58  [ '', 3 ],
59  [ 'pizzacat', INF ],
60  ];
61  }
62 
66  public function testGetNotExists() {
67  $key = wfRandomString();
68  $curTTL = null;
69  $value = $this->cache->get( $key, $curTTL );
70 
71  $this->assertFalse( $value, "Non-existing key has false value" );
72  $this->assertNull( $curTTL, "Non-existing key has null current TTL" );
73  }
74 
78  public function testSetOver() {
79  $key = wfRandomString();
80  for ( $i = 0; $i < 3; ++$i ) {
82  $this->cache->set( $key, $value, 3 );
83 
84  $this->assertEquals( $this->cache->get( $key ), $value );
85  }
86  }
87 
91  public function testStaleSet() {
92  $key = wfRandomString();
94  $this->cache->set( $key, $value, 3, [ 'since' => microtime( true ) - 30 ] );
95 
96  $this->assertFalse( $this->cache->get( $key ), "Stale set() value ignored" );
97  }
98 
103  public function testGetWithSetCallback() {
105 
106  $key = wfRandomString();
108  $cKey1 = wfRandomString();
109  $cKey2 = wfRandomString();
110 
111  $wasSet = 0;
112  $func = function( $old, &$ttl ) use ( &$wasSet, $value ) {
113  ++$wasSet;
114  $ttl = 20; // override with another value
115  return $value;
116  };
117 
118  $wasSet = 0;
119  $v = $cache->getWithSetCallback( $key, 30, $func, [ 'lockTSE' => 5 ] );
120  $this->assertEquals( $value, $v, "Value returned" );
121  $this->assertEquals( 1, $wasSet, "Value regenerated" );
122 
123  $curTTL = null;
124  $cache->get( $key, $curTTL );
125  $this->assertLessThanOrEqual( 20, $curTTL, 'Current TTL between 19-20 (overriden)' );
126  $this->assertGreaterThanOrEqual( 19, $curTTL, 'Current TTL between 19-20 (overriden)' );
127 
128  $wasSet = 0;
129  $v = $cache->getWithSetCallback( $key, 30, $func, [
130  'lowTTL' => 0,
131  'lockTSE' => 5,
132  ] );
133  $this->assertEquals( $value, $v, "Value returned" );
134  $this->assertEquals( 0, $wasSet, "Value not regenerated" );
135 
136  $priorTime = microtime( true );
137  usleep( 1 );
138  $wasSet = 0;
139  $v = $cache->getWithSetCallback( $key, 30, $func,
140  [ 'checkKeys' => [ $cKey1, $cKey2 ] ] );
141  $this->assertEquals( $value, $v, "Value returned" );
142  $this->assertEquals( 1, $wasSet, "Value regenerated due to check keys" );
143  $t1 = $cache->getCheckKeyTime( $cKey1 );
144  $this->assertGreaterThanOrEqual( $priorTime, $t1, 'Check keys generated on miss' );
145  $t2 = $cache->getCheckKeyTime( $cKey2 );
146  $this->assertGreaterThanOrEqual( $priorTime, $t2, 'Check keys generated on miss' );
147 
148  $priorTime = microtime( true );
149  $wasSet = 0;
150  $v = $cache->getWithSetCallback( $key, 30, $func,
151  [ 'checkKeys' => [ $cKey1, $cKey2 ] ] );
152  $this->assertEquals( $value, $v, "Value returned" );
153  $this->assertEquals( 1, $wasSet, "Value regenerated due to still-recent check keys" );
154  $t1 = $cache->getCheckKeyTime( $cKey1 );
155  $this->assertLessThanOrEqual( $priorTime, $t1, 'Check keys did not change again' );
156  $t2 = $cache->getCheckKeyTime( $cKey2 );
157  $this->assertLessThanOrEqual( $priorTime, $t2, 'Check keys did not change again' );
158 
159  $curTTL = null;
160  $v = $cache->get( $key, $curTTL, [ $cKey1, $cKey2 ] );
161  $this->assertEquals( $value, $v, "Value returned" );
162  $this->assertLessThanOrEqual( 0, $curTTL, "Value has current TTL < 0 due to check keys" );
163 
164  $wasSet = 0;
165  $key = wfRandomString();
166  $v = $cache->getWithSetCallback( $key, 30, $func, [ 'pcTTL' => 5 ] );
167  $this->assertEquals( $value, $v, "Value returned" );
168  $cache->delete( $key );
169  $v = $cache->getWithSetCallback( $key, 30, $func, [ 'pcTTL' => 5 ] );
170  $this->assertEquals( $value, $v, "Value still returned after deleted" );
171  $this->assertEquals( 1, $wasSet, "Value process cached while deleted" );
172  }
173 
178  public function testLockTSE() {
180  $key = wfRandomString();
182 
183  $calls = 0;
184  $func = function() use ( &$calls, $value ) {
185  ++$calls;
186  return $value;
187  };
188 
189  $ret = $cache->getWithSetCallback( $key, 30, $func, [ 'lockTSE' => 5 ] );
190  $this->assertEquals( $value, $ret );
191  $this->assertEquals( 1, $calls, 'Value was populated' );
192 
193  // Acquire a lock to verify that getWithSetCallback uses lockTSE properly
194  $this->internalCache->lock( $key, 0 );
195  $ret = $cache->getWithSetCallback( $key, 30, $func, [ 'lockTSE' => 5 ] );
196  $this->assertEquals( $value, $ret );
197  $this->assertEquals( 1, $calls, 'Callback was not used' );
198  }
199 
204  public function testLockTSESlow() {
206  $key = wfRandomString();
208 
209  $calls = 0;
210  $func = function( $oldValue, &$ttl, &$setOpts ) use ( &$calls, $value ) {
211  ++$calls;
212  $setOpts['since'] = microtime( true ) - 10;
213  return $value;
214  };
215 
216  // Value should be marked as stale due to snapshot lag
217  $curTTL = null;
218  $ret = $cache->getWithSetCallback( $key, 30, $func, [ 'lockTSE' => 5 ] );
219  $this->assertEquals( $value, $ret );
220  $this->assertEquals( $value, $cache->get( $key, $curTTL ), 'Value was populated' );
221  $this->assertLessThan( 0, $curTTL, 'Value has negative curTTL' );
222  $this->assertEquals( 1, $calls, 'Value was generated' );
223 
224  // Acquire a lock to verify that getWithSetCallback uses lockTSE properly
225  $this->internalCache->lock( $key, 0 );
226  $ret = $cache->getWithSetCallback( $key, 30, $func, [ 'lockTSE' => 5 ] );
227  $this->assertEquals( $value, $ret );
228  $this->assertEquals( 1, $calls, 'Callback was not used' );
229  }
230 
234  public function testGetMulti() {
236 
237  $value1 = [ 'this' => 'is', 'a' => 'test' ];
238  $value2 = [ 'this' => 'is', 'another' => 'test' ];
239 
240  $key1 = wfRandomString();
241  $key2 = wfRandomString();
242  $key3 = wfRandomString();
243 
244  $cache->set( $key1, $value1, 5 );
245  $cache->set( $key2, $value2, 10 );
246 
247  $curTTLs = [];
248  $this->assertEquals(
249  [ $key1 => $value1, $key2 => $value2 ],
250  $cache->getMulti( [ $key1, $key2, $key3 ], $curTTLs ),
251  'Result array populated'
252  );
253 
254  $this->assertEquals( 2, count( $curTTLs ), "Two current TTLs in array" );
255  $this->assertGreaterThan( 0, $curTTLs[$key1], "Key 1 has current TTL > 0" );
256  $this->assertGreaterThan( 0, $curTTLs[$key2], "Key 2 has current TTL > 0" );
257 
258  $cKey1 = wfRandomString();
259  $cKey2 = wfRandomString();
260 
261  $priorTime = microtime( true );
262  usleep( 1 );
263  $curTTLs = [];
264  $this->assertEquals(
265  [ $key1 => $value1, $key2 => $value2 ],
266  $cache->getMulti( [ $key1, $key2, $key3 ], $curTTLs, [ $cKey1, $cKey2 ] ),
267  "Result array populated even with new check keys"
268  );
269  $t1 = $cache->getCheckKeyTime( $cKey1 );
270  $this->assertGreaterThanOrEqual( $priorTime, $t1, 'Check key 1 generated on miss' );
271  $t2 = $cache->getCheckKeyTime( $cKey2 );
272  $this->assertGreaterThanOrEqual( $priorTime, $t2, 'Check key 2 generated on miss' );
273  $this->assertEquals( 2, count( $curTTLs ), "Current TTLs array set" );
274  $this->assertLessThanOrEqual( 0, $curTTLs[$key1], 'Key 1 has current TTL <= 0' );
275  $this->assertLessThanOrEqual( 0, $curTTLs[$key2], 'Key 2 has current TTL <= 0' );
276 
277  usleep( 1 );
278  $curTTLs = [];
279  $this->assertEquals(
280  [ $key1 => $value1, $key2 => $value2 ],
281  $cache->getMulti( [ $key1, $key2, $key3 ], $curTTLs, [ $cKey1, $cKey2 ] ),
282  "Result array still populated even with new check keys"
283  );
284  $this->assertEquals( 2, count( $curTTLs ), "Current TTLs still array set" );
285  $this->assertLessThan( 0, $curTTLs[$key1], 'Key 1 has negative current TTL' );
286  $this->assertLessThan( 0, $curTTLs[$key2], 'Key 2 has negative current TTL' );
287  }
288 
293  public function testGetMultiCheckKeys() {
295 
296  $checkAll = wfRandomString();
297  $check1 = wfRandomString();
298  $check2 = wfRandomString();
299  $check3 = wfRandomString();
300  $value1 = wfRandomString();
301  $value2 = wfRandomString();
302 
303  // Fake initial check key to be set in the past. Otherwise we'd have to sleep for
304  // several seconds during the test to assert the behaviour.
305  foreach ( [ $checkAll, $check1, $check2 ] as $checkKey ) {
307  }
308  usleep( 100 );
309 
310  $cache->set( 'key1', $value1, 10 );
311  $cache->set( 'key2', $value2, 10 );
312 
313  $curTTLs = [];
314  $result = $cache->getMulti( [ 'key1', 'key2', 'key3' ], $curTTLs, [
315  'key1' => $check1,
316  $checkAll,
317  'key2' => $check2,
318  'key3' => $check3,
319  ] );
320  $this->assertEquals(
321  [ 'key1' => $value1, 'key2' => $value2 ],
322  $result,
323  'Initial values'
324  );
325  $this->assertGreaterThanOrEqual( 9.5, $curTTLs['key1'], 'Initial ttls' );
326  $this->assertLessThanOrEqual( 10.5, $curTTLs['key1'], 'Initial ttls' );
327  $this->assertGreaterThanOrEqual( 9.5, $curTTLs['key2'], 'Initial ttls' );
328  $this->assertLessThanOrEqual( 10.5, $curTTLs['key2'], 'Initial ttls' );
329 
330  $cache->touchCheckKey( $check1 );
331 
332  $curTTLs = [];
333  $result = $cache->getMulti( [ 'key1', 'key2', 'key3' ], $curTTLs, [
334  'key1' => $check1,
335  $checkAll,
336  'key2' => $check2,
337  'key3' => $check3,
338  ] );
339  $this->assertEquals(
340  [ 'key1' => $value1, 'key2' => $value2 ],
341  $result,
342  'key1 expired by check1, but value still provided'
343  );
344  $this->assertLessThan( 0, $curTTLs['key1'], 'key1 TTL expired' );
345  $this->assertGreaterThan( 0, $curTTLs['key2'], 'key2 still valid' );
346 
347  $cache->touchCheckKey( $checkAll );
348 
349  $curTTLs = [];
350  $result = $cache->getMulti( [ 'key1', 'key2', 'key3' ], $curTTLs, [
351  'key1' => $check1,
352  $checkAll,
353  'key2' => $check2,
354  'key3' => $check3,
355  ] );
356  $this->assertEquals(
357  [ 'key1' => $value1, 'key2' => $value2 ],
358  $result,
359  'All keys expired by checkAll, but value still provided'
360  );
361  $this->assertLessThan( 0, $curTTLs['key1'], 'key1 expired by checkAll' );
362  $this->assertLessThan( 0, $curTTLs['key2'], 'key2 expired by checkAll' );
363  }
364 
369  public function testCheckKeyInitHoldoff() {
371 
372  for ( $i = 0; $i < 500; ++$i ) {
373  $key = wfRandomString();
374  $checkKey = wfRandomString();
375  // miss, set, hit
376  $cache->get( $key, $curTTL, [ $checkKey ] );
377  $cache->set( $key, 'val', 10 );
378  $curTTL = null;
379  $v = $cache->get( $key, $curTTL, [ $checkKey ] );
380 
381  $this->assertEquals( 'val', $v );
382  $this->assertLessThan( 0, $curTTL, "Step $i: CTL < 0 (miss/set/hit)" );
383  }
384 
385  for ( $i = 0; $i < 500; ++$i ) {
386  $key = wfRandomString();
387  $checkKey = wfRandomString();
388  // set, hit
389  $cache->set( $key, 'val', 10 );
390  $curTTL = null;
391  $v = $cache->get( $key, $curTTL, [ $checkKey ] );
392 
393  $this->assertEquals( 'val', $v );
394  $this->assertLessThan( 0, $curTTL, "Step $i: CTL < 0 (set/hit)" );
395  }
396  }
397 
401  public function testDelete() {
402  $key = wfRandomString();
404  $this->cache->set( $key, $value );
405 
406  $curTTL = null;
407  $v = $this->cache->get( $key, $curTTL );
408  $this->assertEquals( $value, $v, "Key was created with value" );
409  $this->assertGreaterThan( 0, $curTTL, "Existing key has current TTL > 0" );
410 
411  $this->cache->delete( $key );
412 
413  $curTTL = null;
414  $v = $this->cache->get( $key, $curTTL );
415  $this->assertFalse( $v, "Deleted key has false value" );
416  $this->assertLessThan( 0, $curTTL, "Deleted key has current TTL < 0" );
417 
418  $this->cache->set( $key, $value . 'more' );
419  $v = $this->cache->get( $key, $curTTL );
420  $this->assertFalse( $v, "Deleted key is tombstoned and has false value" );
421  $this->assertLessThan( 0, $curTTL, "Deleted key is tombstoned and has current TTL < 0" );
422 
423  $this->cache->set( $key, $value );
424  $this->cache->delete( $key, WANObjectCache::HOLDOFF_NONE );
425 
426  $curTTL = null;
427  $v = $this->cache->get( $key, $curTTL );
428  $this->assertFalse( $v, "Deleted key has false value" );
429  $this->assertNull( $curTTL, "Deleted key has null current TTL" );
430 
431  $this->cache->set( $key, $value );
432  $v = $this->cache->get( $key, $curTTL );
433  $this->assertEquals( $value, $v, "Key was created with value" );
434  $this->assertGreaterThan( 0, $curTTL, "Existing key has current TTL > 0" );
435  }
436 
442  public function testTouchKeys() {
443  $key = wfRandomString();
444 
445  $priorTime = microtime( true );
446  usleep( 100 );
447  $t0 = $this->cache->getCheckKeyTime( $key );
448  $this->assertGreaterThanOrEqual( $priorTime, $t0, 'Check key auto-created' );
449 
450  $priorTime = microtime( true );
451  usleep( 100 );
452  $this->cache->touchCheckKey( $key );
453  $t1 = $this->cache->getCheckKeyTime( $key );
454  $this->assertGreaterThanOrEqual( $priorTime, $t1, 'Check key created' );
455 
456  $t2 = $this->cache->getCheckKeyTime( $key );
457  $this->assertEquals( $t1, $t2, 'Check key time did not change' );
458 
459  usleep( 100 );
460  $this->cache->touchCheckKey( $key );
461  $t3 = $this->cache->getCheckKeyTime( $key );
462  $this->assertGreaterThan( $t2, $t3, 'Check key time increased' );
463 
464  $t4 = $this->cache->getCheckKeyTime( $key );
465  $this->assertEquals( $t3, $t4, 'Check key time did not change' );
466 
467  usleep( 100 );
468  $this->cache->resetCheckKey( $key );
469  $t5 = $this->cache->getCheckKeyTime( $key );
470  $this->assertGreaterThan( $t4, $t5, 'Check key time increased' );
471 
472  $t6 = $this->cache->getCheckKeyTime( $key );
473  $this->assertEquals( $t5, $t6, 'Check key time did not change' );
474  }
475 
479  public function testGetWithSeveralCheckKeys() {
480  $key = wfRandomString();
481  $tKey1 = wfRandomString();
482  $tKey2 = wfRandomString();
483  $value = 'meow';
484 
485  // Two check keys are newer (given hold-off) than $key, another is older
486  $this->internalCache->set(
488  WANObjectCache::PURGE_VAL_PREFIX . ( microtime( true ) - 3 )
489  );
490  $this->internalCache->set(
492  WANObjectCache::PURGE_VAL_PREFIX . ( microtime( true ) - 5 )
493  );
494  $this->internalCache->set(
496  WANObjectCache::PURGE_VAL_PREFIX . ( microtime( true ) - 30 )
497  );
498  $this->cache->set( $key, $value, 30 );
499 
500  $curTTL = null;
501  $v = $this->cache->get( $key, $curTTL, [ $tKey1, $tKey2 ] );
502  $this->assertEquals( $value, $v, "Value matches" );
503  $this->assertLessThan( -4.9, $curTTL, "Correct CTL" );
504  $this->assertGreaterThan( -5.1, $curTTL, "Correct CTL" );
505  }
506 
510  public function testSetWithLag() {
511  $value = 1;
512 
513  $key = wfRandomString();
514  $opts = [ 'lag' => 300, 'since' => microtime( true ) ];
515  $this->cache->set( $key, $value, 30, $opts );
516  $this->assertEquals( $value, $this->cache->get( $key ), "Rep-lagged value written." );
517 
518  $key = wfRandomString();
519  $opts = [ 'lag' => 0, 'since' => microtime( true ) - 300 ];
520  $this->cache->set( $key, $value, 30, $opts );
521  $this->assertEquals( false, $this->cache->get( $key ), "Trx-lagged value not written." );
522 
523  $key = wfRandomString();
524  $opts = [ 'lag' => 5, 'since' => microtime( true ) - 5 ];
525  $this->cache->set( $key, $value, 30, $opts );
526  $this->assertEquals( false, $this->cache->get( $key ), "Lagged value not written." );
527  }
528 
532  public function testWritePending() {
533  $value = 1;
534 
535  $key = wfRandomString();
536  $opts = [ 'pending' => true ];
537  $this->cache->set( $key, $value, 30, $opts );
538  $this->assertEquals( false, $this->cache->get( $key ), "Pending value not written." );
539  }
540 }
set($key, $value, $ttl=0, array $opts=[])
Set the value of a key in cache.
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
Definition: hooks.txt:2325
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
testCheckKeyInitHoldoff()
WANObjectCache::get() WANObjectCache::processCheckKeys()
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1802
testGetMultiCheckKeys()
WANObjectCache::getMulti() WANObjectCache::processCheckKeys()
testSetAndGet($value, $ttl)
provideSetAndGet WANObjectCache::set() WANObjectCache::get()
touchCheckKey($key, $holdoff=self::HOLDOFF_TTL)
Purge a "check" key from all datacenters, invalidating keys that use it.
$value
testTouchKeys()
WANObjectCache::touchCheckKey() WANObjectCache::resetCheckKey() WANObjectCache::getCheckKeyTime() ...
Multi-datacenter aware caching interface.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
Definition: globals.txt:25
wfRandomString($length=32)
Get a random string containing a number of pseudo-random hex characters.
No-op class for publishing messages into a PubSub system.
getWithSetCallback($key, $ttl, $callback, array $opts=[])
Method to fetch/regenerate cache keys.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message.Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object &$pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports.&$fullInterwikiPrefix:Interwiki prefix, may contain colons.&$pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page.$context:IContextSource object &$pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect.&$title:Title object for the current page &$request:WebRequest &$ignoreRedirect:boolean to skip redirect check &$target:Title/string of redirect target &$article:Article object 'InternalParseBeforeLinks':during Parser's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InternalParseBeforeSanitize':during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not.Return true without providing an interwiki to continue interwiki search.$prefix:interwiki prefix we are looking for.&$iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user's email has been invalidated successfully.$user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification.Callee may modify $url and $query, URL will be constructed as $url.$query &$url:URL to index.php &$query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) &$article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() &$ip:IP being check &$result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from &$allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn't match your organization.$addr:The e-mail address entered by the user &$result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user &$result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we're looking for a messages file for &$file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces.Do not use this hook to add namespaces.Use CanonicalNamespaces for that.&$namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names.&$names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page's language links.This is called in various places to allow extensions to define the effective language links for a page.$title:The page's Title.&$links:Associative array mapping language codes to prefixed links of the form"language:title".&$linkFlags:Associative array mapping prefixed links to arrays of flags.Currently unused, but planned to provide support for marking individual language links in the UI, e.g.for featured articles. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts.Return false to skip default processing and return $ret.See documentation for Linker::link() for details on the expected meanings of parameters.$skin:the Skin object $target:the Title that the link is pointing to &$html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1800
you have access to all of the normal MediaWiki so you can get a DB use the cache
Definition: maintenance.txt:52
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1802
testLockTSE()
WANObjectCache::getWithSetCallback() WANObjectCache::doGetWithSetCallback()
testStaleSet()
WANObjectCache::set()
get($key, &$curTTL=null, array $checkKeys=[])
Fetch the value of a key from cache.
testLockTSESlow()
WANObjectCache::getWithSetCallback() WANObjectCache::doGetWithSetCallback()
WANObjectCache $cache
getCheckKeyTime($key)
Fetch the value of a timestamp "check" key.
getMulti(array $keys, &$curTTLs=[], array $checkKeys=[])
Fetch the value of several keys from cache.
testSetOver()
WANObjectCache::set()
testGetMulti()
WANObjectCache::getMulti()
testSetWithLag()
WANObjectCache::set()
const HOLDOFF_NONE
Idiom for delete() for "no hold-off".
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
testGetWithSeveralCheckKeys()
WANObjectCache::getMulti()
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
delete($key, $ttl=self::HOLDOFF_TTL)
Purge a key from all datacenters.
static getWANInstance($id)
Get a cached instance of the specified type of WAN cache object.
testGetWithSetCallback()
WANObjectCache::getWithSetCallback() WANObjectCache::doGetWithSetCallback()
testWritePending()
WANObjectCache::set()
testGetNotExists()
WANObjectCache::get()
static newFromObject($object)
Return the same object, without access restrictions.
testDelete()
WANObjectCache::delete()
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:314