MediaWiki  REL1_31
LBFactoryTest.php
Go to the documentation of this file.
1 <?php
33 
40 
45  public function testGetLBFactoryClass( $expected, $deprecated ) {
46  $mockDB = $this->getMockBuilder( DatabaseMysqli::class )
47  ->disableOriginalConstructor()
48  ->getMock();
49 
50  $config = [
51  'class' => $deprecated,
52  'connection' => $mockDB,
53  # Various other parameters required:
54  'sectionsByDB' => [],
55  'sectionLoads' => [],
56  'serverTemplate' => [],
57  ];
58 
59  $this->hideDeprecated( '$wgLBFactoryConf must be updated. See RELEASE-NOTES for details' );
61 
62  $this->assertEquals( $expected, $result );
63  }
64 
65  public function getLBFactoryClassProvider() {
66  return [
67  # Format: new class, old class
68  [ Wikimedia\Rdbms\LBFactorySimple::class, 'LBFactory_Simple' ],
69  [ Wikimedia\Rdbms\LBFactorySingle::class, 'LBFactory_Single' ],
70  [ Wikimedia\Rdbms\LBFactoryMulti::class, 'LBFactory_Multi' ],
71  [ Wikimedia\Rdbms\LBFactorySimple::class, 'LBFactorySimple' ],
72  [ Wikimedia\Rdbms\LBFactorySingle::class, 'LBFactorySingle' ],
73  [ Wikimedia\Rdbms\LBFactoryMulti::class, 'LBFactoryMulti' ],
74  ];
75  }
76 
77  public function testLBFactorySimpleServer() {
79 
80  $servers = [
81  [
82  'host' => $wgDBserver,
83  'dbname' => $wgDBname,
84  'user' => $wgDBuser,
85  'password' => $wgDBpassword,
86  'type' => $wgDBtype,
87  'dbDirectory' => $wgSQLiteDataDir,
88  'load' => 0,
89  'flags' => DBO_TRX // REPEATABLE-READ for consistency
90  ],
91  ];
92 
93  $factory = new LBFactorySimple( [ 'servers' => $servers ] );
94  $lb = $factory->getMainLB();
95 
96  $dbw = $lb->getConnection( DB_MASTER );
97  $this->assertTrue( $dbw->getLBInfo( 'master' ), 'master shows as master' );
98 
99  $dbr = $lb->getConnection( DB_REPLICA );
100  $this->assertTrue( $dbr->getLBInfo( 'master' ), 'DB_REPLICA also gets the master' );
101 
102  $factory->shutdown();
103  $lb->closeAll();
104  }
105 
106  public function testLBFactorySimpleServers() {
108 
109  $servers = [
110  [ // master
111  'host' => $wgDBserver,
112  'dbname' => $wgDBname,
113  'user' => $wgDBuser,
114  'password' => $wgDBpassword,
115  'type' => $wgDBtype,
116  'dbDirectory' => $wgSQLiteDataDir,
117  'load' => 0,
118  'flags' => DBO_TRX // REPEATABLE-READ for consistency
119  ],
120  [ // emulated slave
121  'host' => $wgDBserver,
122  'dbname' => $wgDBname,
123  'user' => $wgDBuser,
124  'password' => $wgDBpassword,
125  'type' => $wgDBtype,
126  'dbDirectory' => $wgSQLiteDataDir,
127  'load' => 100,
128  'flags' => DBO_TRX // REPEATABLE-READ for consistency
129  ]
130  ];
131 
132  $factory = new LBFactorySimple( [
133  'servers' => $servers,
134  'loadMonitorClass' => LoadMonitorNull::class
135  ] );
136  $lb = $factory->getMainLB();
137 
138  $dbw = $lb->getConnection( DB_MASTER );
139  $this->assertTrue( $dbw->getLBInfo( 'master' ), 'master shows as master' );
140  $this->assertEquals(
141  ( $wgDBserver != '' ) ? $wgDBserver : 'localhost',
142  $dbw->getLBInfo( 'clusterMasterHost' ),
143  'cluster master set' );
144 
145  $dbr = $lb->getConnection( DB_REPLICA );
146  $this->assertTrue( $dbr->getLBInfo( 'replica' ), 'slave shows as slave' );
147  $this->assertEquals(
148  ( $wgDBserver != '' ) ? $wgDBserver : 'localhost',
149  $dbr->getLBInfo( 'clusterMasterHost' ),
150  'cluster master set' );
151 
152  $factory->shutdown();
153  $lb->closeAll();
154  }
155 
156  public function testLBFactoryMulti() {
158 
159  $factory = new LBFactoryMulti( [
160  'sectionsByDB' => [],
161  'sectionLoads' => [
162  'DEFAULT' => [
163  'test-db1' => 0,
164  'test-db2' => 100,
165  ],
166  ],
167  'serverTemplate' => [
168  'dbname' => $wgDBname,
169  'user' => $wgDBuser,
170  'password' => $wgDBpassword,
171  'type' => $wgDBtype,
172  'dbDirectory' => $wgSQLiteDataDir,
173  'flags' => DBO_DEFAULT
174  ],
175  'hostsByName' => [
176  'test-db1' => $wgDBserver,
177  'test-db2' => $wgDBserver
178  ],
179  'loadMonitorClass' => LoadMonitorNull::class
180  ] );
181  $lb = $factory->getMainLB();
182 
183  $dbw = $lb->getConnection( DB_MASTER );
184  $this->assertTrue( $dbw->getLBInfo( 'master' ), 'master shows as master' );
185 
186  $dbr = $lb->getConnection( DB_REPLICA );
187  $this->assertTrue( $dbr->getLBInfo( 'replica' ), 'slave shows as slave' );
188 
189  $factory->shutdown();
190  $lb->closeAll();
191  }
192 
196  public function testChronologyProtector() {
197  $now = microtime( true );
198 
199  // (a) First HTTP request
200  $m1Pos = new MySQLMasterPos( 'db1034-bin.000976/843431247', $now );
201  $m2Pos = new MySQLMasterPos( 'db1064-bin.002400/794074907', $now );
202 
203  // Master DB 1
204  $mockDB1 = $this->getMockBuilder( DatabaseMysqli::class )
205  ->disableOriginalConstructor()
206  ->getMock();
207  $mockDB1->method( 'writesOrCallbacksPending' )->willReturn( true );
208  $mockDB1->method( 'lastDoneWrites' )->willReturn( $now );
209  $mockDB1->method( 'getMasterPos' )->willReturn( $m1Pos );
210  // Load balancer for master DB 1
211  $lb1 = $this->getMockBuilder( LoadBalancer::class )
212  ->disableOriginalConstructor()
213  ->getMock();
214  $lb1->method( 'getConnection' )->willReturn( $mockDB1 );
215  $lb1->method( 'getServerCount' )->willReturn( 2 );
216  $lb1->method( 'getAnyOpenConnection' )->willReturn( $mockDB1 );
217  $lb1->method( 'hasOrMadeRecentMasterChanges' )->will( $this->returnCallback(
218  function () use ( $mockDB1 ) {
219  $p = 0;
220  $p |= call_user_func( [ $mockDB1, 'writesOrCallbacksPending' ] );
221  $p |= call_user_func( [ $mockDB1, 'lastDoneWrites' ] );
222 
223  return (bool)$p;
224  }
225  ) );
226  $lb1->method( 'getMasterPos' )->willReturn( $m1Pos );
227  $lb1->method( 'getServerName' )->with( 0 )->willReturn( 'master1' );
228  // Master DB 2
229  $mockDB2 = $this->getMockBuilder( DatabaseMysqli::class )
230  ->disableOriginalConstructor()
231  ->getMock();
232  $mockDB2->method( 'writesOrCallbacksPending' )->willReturn( true );
233  $mockDB2->method( 'lastDoneWrites' )->willReturn( $now );
234  $mockDB2->method( 'getMasterPos' )->willReturn( $m2Pos );
235  // Load balancer for master DB 2
236  $lb2 = $this->getMockBuilder( LoadBalancer::class )
237  ->disableOriginalConstructor()
238  ->getMock();
239  $lb2->method( 'getConnection' )->willReturn( $mockDB2 );
240  $lb2->method( 'getServerCount' )->willReturn( 2 );
241  $lb2->method( 'getAnyOpenConnection' )->willReturn( $mockDB2 );
242  $lb2->method( 'hasOrMadeRecentMasterChanges' )->will( $this->returnCallback(
243  function () use ( $mockDB2 ) {
244  $p = 0;
245  $p |= call_user_func( [ $mockDB2, 'writesOrCallbacksPending' ] );
246  $p |= call_user_func( [ $mockDB2, 'lastDoneWrites' ] );
247 
248  return (bool)$p;
249  }
250  ) );
251  $lb2->method( 'getMasterPos' )->willReturn( $m2Pos );
252  $lb2->method( 'getServerName' )->with( 0 )->willReturn( 'master2' );
253 
254  $bag = new HashBagOStuff();
255  $cp = new ChronologyProtector(
256  $bag,
257  [
258  'ip' => '127.0.0.1',
259  'agent' => "Totally-Not-FireFox"
260  ]
261  );
262 
263  $mockDB1->expects( $this->exactly( 1 ) )->method( 'writesOrCallbacksPending' );
264  $mockDB1->expects( $this->exactly( 1 ) )->method( 'lastDoneWrites' );
265  $mockDB2->expects( $this->exactly( 1 ) )->method( 'writesOrCallbacksPending' );
266  $mockDB2->expects( $this->exactly( 1 ) )->method( 'lastDoneWrites' );
267 
268  // Nothing to wait for on first HTTP request start
269  $cp->initLB( $lb1 );
270  $cp->initLB( $lb2 );
271  // Record positions in stash on first HTTP request end
272  $cp->shutdownLB( $lb1 );
273  $cp->shutdownLB( $lb2 );
274  $cpIndex = null;
275  $cp->shutdown( null, 'sync', $cpIndex );
276 
277  $this->assertEquals( 1, $cpIndex, "CP write index set" );
278 
279  // (b) Second HTTP request
280 
281  // Load balancer for master DB 1
282  $lb1 = $this->getMockBuilder( LoadBalancer::class )
283  ->disableOriginalConstructor()
284  ->getMock();
285  $lb1->method( 'getServerCount' )->willReturn( 2 );
286  $lb1->method( 'getServerName' )->with( 0 )->willReturn( 'master1' );
287  $lb1->expects( $this->once() )
288  ->method( 'waitFor' )->with( $this->equalTo( $m1Pos ) );
289  // Load balancer for master DB 2
290  $lb2 = $this->getMockBuilder( LoadBalancer::class )
291  ->disableOriginalConstructor()
292  ->getMock();
293  $lb2->method( 'getServerCount' )->willReturn( 2 );
294  $lb2->method( 'getServerName' )->with( 0 )->willReturn( 'master2' );
295  $lb2->expects( $this->once() )
296  ->method( 'waitFor' )->with( $this->equalTo( $m2Pos ) );
297 
298  $cp = new ChronologyProtector(
299  $bag,
300  [
301  'ip' => '127.0.0.1',
302  'agent' => "Totally-Not-FireFox"
303  ],
304  $cpIndex
305  );
306 
307  // Wait for last positions to be reached on second HTTP request start
308  $cp->initLB( $lb1 );
309  $cp->initLB( $lb2 );
310  // Shutdown (nothing to record)
311  $cp->shutdownLB( $lb1 );
312  $cp->shutdownLB( $lb2 );
313  $cpIndex = null;
314  $cp->shutdown( null, 'sync', $cpIndex );
315 
316  $this->assertEquals( null, $cpIndex, "CP write index retained" );
317  }
318 
319  private function newLBFactoryMulti( array $baseOverride = [], array $serverOverride = [] ) {
322 
323  return new LBFactoryMulti( $baseOverride + [
324  'sectionsByDB' => [],
325  'sectionLoads' => [
326  'DEFAULT' => [
327  'test-db1' => 1,
328  ],
329  ],
330  'serverTemplate' => $serverOverride + [
331  'dbname' => $wgDBname,
332  'tablePrefix' => $wgDBprefix,
333  'user' => $wgDBuser,
334  'password' => $wgDBpassword,
335  'type' => $wgDBtype,
336  'dbDirectory' => $wgSQLiteDataDir,
337  'flags' => DBO_DEFAULT
338  ],
339  'hostsByName' => [
340  'test-db1' => $wgDBserver,
341  ],
342  'loadMonitorClass' => LoadMonitorNull::class,
343  'localDomain' => new DatabaseDomain( $wgDBname, null, $wgDBprefix )
344  ] );
345  }
346 
347  public function testNiceDomains() {
349 
350  if ( wfGetDB( DB_MASTER )->databasesAreIndependent() ) {
351  self::markTestSkipped( "Skipping tests about selecting DBs: not applicable" );
352  return;
353  }
354 
355  $factory = $this->newLBFactoryMulti(
356  [],
357  []
358  );
359  $lb = $factory->getMainLB();
360 
361  $db = $lb->getConnectionRef( DB_MASTER );
362  $this->assertEquals(
363  wfWikiID(),
364  $db->getDomainID()
365  );
366  unset( $db );
367 
369  $db = $lb->getConnection( DB_MASTER, [], '' );
370 
371  $this->assertEquals(
372  '',
373  $db->getDomainId(),
374  'Null domain ID handle used'
375  );
376  $this->assertEquals(
377  '',
378  $db->getDBname(),
379  'Null domain ID handle used'
380  );
381  $this->assertEquals(
382  '',
383  $db->tablePrefix(),
384  'Main domain ID handle used; prefix is empty though'
385  );
386  $this->assertEquals(
387  $this->quoteTable( $db, 'page' ),
388  $db->tableName( 'page' ),
389  "Correct full table name"
390  );
391  $this->assertEquals(
392  $this->quoteTable( $db, $wgDBname ) . '.' . $this->quoteTable( $db, 'page' ),
393  $db->tableName( "$wgDBname.page" ),
394  "Correct full table name"
395  );
396  $this->assertEquals(
397  $this->quoteTable( $db, 'nice_db' ) . '.' . $this->quoteTable( $db, 'page' ),
398  $db->tableName( 'nice_db.page' ),
399  "Correct full table name"
400  );
401 
402  $lb->reuseConnection( $db ); // don't care
403 
404  $db = $lb->getConnection( DB_MASTER ); // local domain connection
405  $factory->setDomainPrefix( 'my_' );
406 
407  $this->assertEquals( $wgDBname, $db->getDBname() );
408  $this->assertEquals(
409  "$wgDBname-my_",
410  $db->getDomainID()
411  );
412  $this->assertEquals(
413  $this->quoteTable( $db, 'my_page' ),
414  $db->tableName( 'page' ),
415  "Correct full table name"
416  );
417  $this->assertEquals(
418  $this->quoteTable( $db, 'other_nice_db' ) . '.' . $this->quoteTable( $db, 'page' ),
419  $db->tableName( 'other_nice_db.page' ),
420  "Correct full table name"
421  );
422 
423  $factory->closeAll();
424  $factory->destroy();
425  }
426 
427  public function testTrickyDomain() {
429 
430  if ( wfGetDB( DB_MASTER )->databasesAreIndependent() ) {
431  self::markTestSkipped( "Skipping tests about selecting DBs: not applicable" );
432  return;
433  }
434 
435  $dbname = 'unittest-domain'; // explodes if DB is selected
436  $factory = $this->newLBFactoryMulti(
437  [ 'localDomain' => ( new DatabaseDomain( $dbname, null, '' ) )->getId() ],
438  [
439  'dbName' => 'do_not_select_me' // explodes if DB is selected
440  ]
441  );
442  $lb = $factory->getMainLB();
444  $db = $lb->getConnection( DB_MASTER, [], '' );
445 
446  $this->assertEquals( '', $db->getDomainID(), "Null domain used" );
447 
448  $this->assertEquals(
449  $this->quoteTable( $db, 'page' ),
450  $db->tableName( 'page' ),
451  "Correct full table name"
452  );
453 
454  $this->assertEquals(
455  $this->quoteTable( $db, $dbname ) . '.' . $this->quoteTable( $db, 'page' ),
456  $db->tableName( "$dbname.page" ),
457  "Correct full table name"
458  );
459 
460  $this->assertEquals(
461  $this->quoteTable( $db, 'nice_db' ) . '.' . $this->quoteTable( $db, 'page' ),
462  $db->tableName( 'nice_db.page' ),
463  "Correct full table name"
464  );
465 
466  $lb->reuseConnection( $db ); // don't care
467 
468  $factory->setDomainPrefix( 'my_' );
469  $db = $lb->getConnection( DB_MASTER, [], "$wgDBname-my_" );
470 
471  $this->assertEquals(
472  $this->quoteTable( $db, 'my_page' ),
473  $db->tableName( 'page' ),
474  "Correct full table name"
475  );
476  $this->assertEquals(
477  $this->quoteTable( $db, 'other_nice_db' ) . '.' . $this->quoteTable( $db, 'page' ),
478  $db->tableName( 'other_nice_db.page' ),
479  "Correct full table name"
480  );
481  $this->assertEquals(
482  $this->quoteTable( $db, 'garbage-db' ) . '.' . $this->quoteTable( $db, 'page' ),
483  $db->tableName( 'garbage-db.page' ),
484  "Correct full table name"
485  );
486 
487  $lb->reuseConnection( $db ); // don't care
488 
489  $factory->closeAll();
490  $factory->destroy();
491  }
492 
493  public function testInvalidSelectDB() {
494  $dbname = 'unittest-domain'; // explodes if DB is selected
495  $factory = $this->newLBFactoryMulti(
496  [ 'localDomain' => ( new DatabaseDomain( $dbname, null, '' ) )->getId() ],
497  [
498  'dbName' => 'do_not_select_me' // explodes if DB is selected
499  ]
500  );
501  $lb = $factory->getMainLB();
503  $db = $lb->getConnection( DB_MASTER, [], '' );
504 
505  if ( $db->getType() === 'sqlite' ) {
506  $this->assertFalse( $db->selectDB( 'garbage-db' ) );
507  } elseif ( $db->databasesAreIndependent() ) {
508  try {
509  $e = null;
510  $db->selectDB( 'garbage-db' );
511  } catch ( \Wikimedia\Rdbms\DBConnectionError $e ) {
512  // expected
513  }
514  $this->assertInstanceOf( \Wikimedia\Rdbms\DBConnectionError::class, $e );
515  $this->assertFalse( $db->isOpen() );
516  } else {
517  \Wikimedia\suppressWarnings();
518  $this->assertFalse( $db->selectDB( 'garbage-db' ) );
519  \Wikimedia\restoreWarnings();
520  }
521  }
522 
523  private function quoteTable( Database $db, $table ) {
524  if ( $db->getType() === 'sqlite' ) {
525  return $table;
526  } else {
527  return $db->addIdentifierQuotes( $table );
528  }
529  }
530 }
$wgDBserver
$wgDBserver
Database host name or IP address.
Definition: DefaultSettings.php:1794
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
HashBagOStuff
Simple store for keeping values in an associative array for the current process.
Definition: HashBagOStuff.php:31
array
the array() calling protocol came about after MediaWiki 1.4rc1.
$wgDBtype
$wgDBtype
Database type.
Definition: DefaultSettings.php:1819
Wikimedia\Rdbms\DatabaseMysqli
Database abstraction object for PHP extension mysqli.
Definition: DatabaseMysqli.php:37
LBFactoryTest
Database \Wikimedia\Rdbms\LBFactorySimple \Wikimedia\Rdbms\LBFactoryMulti.
Definition: LBFactoryTest.php:39
$result
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. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. '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 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name '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:Array with elements of the form "language:title" in the order that they will be output. & $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':DEPRECATED! Use HtmlPageLinkRendererBegin instead. 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:1993
LBFactoryTest\testInvalidSelectDB
testInvalidSelectDB()
Definition: LBFactoryTest.php:493
$wgDBpassword
$wgDBpassword
Database user's password.
Definition: DefaultSettings.php:1814
DBO_TRX
const DBO_TRX
Definition: defines.php:12
$wgDBprefix
$wgDBprefix
Table name prefix.
Definition: DefaultSettings.php:1871
php
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:37
$dbr
$dbr
Definition: testCompression.php:50
LBFactoryTest\quoteTable
quoteTable(Database $db, $table)
Definition: LBFactoryTest.php:523
$wgSQLiteDataDir
$wgSQLiteDataDir
To override default SQLite data directory ($docroot/../data)
Definition: DefaultSettings.php:1894
$wgDBname
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned $wgDBname
Definition: memcached.txt:138
Wikimedia\Rdbms\LBFactorySimple
A simple single-master LBFactory that gets its configuration from the b/c globals.
Definition: LBFactorySimple.php:31
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2812
MediaWikiTestCase
Definition: MediaWikiTestCase.php:17
LBFactoryTest\testLBFactorySimpleServer
testLBFactorySimpleServer()
Definition: LBFactoryTest.php:77
MediaWikiTestCase\hideDeprecated
hideDeprecated( $function)
Don't throw a warning if $function is deprecated and called later.
Definition: MediaWikiTestCase.php:1675
Wikimedia\Rdbms\MySQLMasterPos
DBMasterPos class for MySQL/MariaDB.
Definition: MySQLMasterPos.php:19
MWLBFactory\getLBFactoryClass
static getLBFactoryClass(array $config)
Returns the LBFactory class to use and the load balancer configuration.
Definition: MWLBFactory.php:178
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
DB_MASTER
const DB_MASTER
Definition: defines.php:29
Wikimedia\Rdbms\LoadBalancer
Database connection, tracking, load balancing, and transaction manager for a cluster.
Definition: LoadBalancer.php:41
wfWikiID
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Definition: GlobalFunctions.php:2763
LBFactoryTest\testLBFactorySimpleServers
testLBFactorySimpleServers()
Definition: LBFactoryTest.php:106
Wikimedia\Rdbms\LBFactoryMulti
A multi-database, multi-master factory for Wikimedia and similar installations.
Definition: LBFactoryMulti.php:34
LBFactoryTest\newLBFactoryMulti
newLBFactoryMulti(array $baseOverride=[], array $serverOverride=[])
Definition: LBFactoryTest.php:319
Wikimedia\Rdbms\ChronologyProtector
Class for ensuring a consistent ordering of events as seen by the user, despite replication.
Definition: ChronologyProtector.php:36
LBFactoryTest\testChronologyProtector
testChronologyProtector()
\Wikimedia\Rdbms\ChronologyProtector
Definition: LBFactoryTest.php:196
Wikimedia
LBFactoryTest\testGetLBFactoryClass
testGetLBFactoryClass( $expected, $deprecated)
MWLBFactory::getLBFactoryClass getLBFactoryClassProvider.
Definition: LBFactoryTest.php:45
LBFactoryTest\testNiceDomains
testNiceDomains()
Definition: LBFactoryTest.php:347
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:56
$wgDBuser
$wgDBuser
Database username.
Definition: DefaultSettings.php:1809
LBFactoryTest\testLBFactoryMulti
testLBFactoryMulti()
Definition: LBFactoryTest.php:156
Wikimedia\Rdbms\DatabaseDomain
Class to handle database/prefix specification for IDatabase domains.
Definition: DatabaseDomain.php:28
DBO_DEFAULT
const DBO_DEFAULT
Definition: defines.php:13
LBFactoryTest\testTrickyDomain
testTrickyDomain()
Definition: LBFactoryTest.php:427
MediaWikiTestCase\$db
Database $db
Primary database.
Definition: MediaWikiTestCase.php:57
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2171
LBFactoryTest\getLBFactoryClassProvider
getLBFactoryClassProvider()
Definition: LBFactoryTest.php:65