MediaWiki  master
RevisionStoreTest.php
Go to the documentation of this file.
1 <?php
2 
4 
19 use Title;
25 
30 
31  private function useTextId() {
33 
34  return (bool)( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_READ_OLD );
35  }
36 
44  private function getRevisionStore(
45  $loadBalancer = null,
46  $blobStore = null,
47  $WANObjectCache = null
48  ) {
50  // the migration stage should be irrelevant, since all the tests that interact with
51  // the database are in RevisionStoreDbTest, not here.
52 
53  return new RevisionStore(
54  $loadBalancer ?: $this->getMockLoadBalancer(),
55  $blobStore ?: $this->getMockSqlBlobStore(),
56  $WANObjectCache ?: $this->getHashWANObjectCache(),
57  MediaWikiServices::getInstance()->getCommentStore(),
58  MediaWikiServices::getInstance()->getContentModelStore(),
59  MediaWikiServices::getInstance()->getSlotRoleStore(),
60  MediaWikiServices::getInstance()->getSlotRoleRegistry(),
61  $wgMultiContentRevisionSchemaMigrationStage,
62  MediaWikiServices::getInstance()->getActorMigration()
63  );
64  }
65 
69  private function getMockLoadBalancer() {
70  return $this->getMockBuilder( LoadBalancer::class )
71  ->disableOriginalConstructor()->getMock();
72  }
73 
77  private function getMockDatabase() {
78  return $this->getMockBuilder( IDatabase::class )
79  ->disableOriginalConstructor()->getMock();
80  }
81 
87  private function getMockDBConnRefCallback( ILoadBalancer $mockLoadBalancer, IDatabase $db ) {
88  return function ( $i, $g, $domain, $flg ) use ( $mockLoadBalancer, $db ) {
89  return new MaintainableDBConnRef( $mockLoadBalancer, $db, $i );
90  };
91  }
92 
96  private function getMockSqlBlobStore() {
97  return $this->getMockBuilder( SqlBlobStore::class )
98  ->disableOriginalConstructor()->getMock();
99  }
100 
104  private function getMockCommentStore() {
105  return $this->getMockBuilder( CommentStore::class )
106  ->disableOriginalConstructor()->getMock();
107  }
108 
112  private function getMockSlotRoleRegistry() {
113  return $this->getMockBuilder( SlotRoleRegistry::class )
114  ->disableOriginalConstructor()->getMock();
115  }
116 
117  private function getHashWANObjectCache() {
118  return new WANObjectCache( [ 'cache' => new \HashBagOStuff() ] );
119  }
120 
121  public function provideSetContentHandlerUseDB() {
122  return [
123  // ContentHandlerUseDB can be true of false pre migration.
124  [ false, SCHEMA_COMPAT_OLD, false ],
125  [ true, SCHEMA_COMPAT_OLD, false ],
126  // During and after migration it can not be false...
129  [ false, SCHEMA_COMPAT_NEW, true ],
130  // ...but it can be true.
133  [ true, SCHEMA_COMPAT_NEW, false ],
134  ];
135  }
136 
142  public function testSetContentHandlerUseDB( $contentHandlerDb, $migrationMode, $expectedFail ) {
143  if ( $expectedFail ) {
144  $this->setExpectedException( MWException::class );
145  }
146 
147  $nameTables = MediaWikiServices::getInstance()->getNameTableStoreFactory();
148 
149  $store = new RevisionStore(
150  $this->getMockLoadBalancer(),
151  $this->getMockSqlBlobStore(),
152  $this->getHashWANObjectCache(),
153  $this->getMockCommentStore(),
154  $nameTables->getContentModels(),
155  $nameTables->getSlotRoles(),
156  $this->getMockSlotRoleRegistry(),
157  $migrationMode,
158  MediaWikiServices::getInstance()->getActorMigration()
159  );
160 
161  $store->setContentHandlerUseDB( $contentHandlerDb );
162  $this->assertSame( $contentHandlerDb, $store->getContentHandlerUseDB() );
163  }
164 
168  public function testGetTitle_successFromPageId() {
169  $mockLoadBalancer = $this->getMockLoadBalancer();
170  // Title calls wfGetDB() so we have to set the main service
171  $this->setService( 'DBLoadBalancer', $mockLoadBalancer );
172 
173  $db = $this->getMockDatabase();
174  // RevisionStore uses getConnectionRef
175  $mockLoadBalancer->expects( $this->any() )
176  ->method( 'getConnectionRef' )
177  ->willReturnCallback( $this->getMockDBConnRefCallback( $mockLoadBalancer, $db ) );
178  // Title calls wfGetDB() which uses getMaintenanceConnectionRef
179  $mockLoadBalancer->expects( $this->atLeastOnce() )
180  ->method( 'getMaintenanceConnectionRef' )
181  ->willReturnCallback( $this->getMockDBConnRefCallback( $mockLoadBalancer, $db ) );
182 
183  // First call to Title::newFromID, faking no result (db lag?)
184  $db->expects( $this->at( 0 ) )
185  ->method( 'selectRow' )
186  ->with(
187  'page',
188  $this->anything(),
189  [ 'page_id' => 1 ]
190  )
191  ->willReturn( (object)[
192  'page_namespace' => '1',
193  'page_title' => 'Food',
194  ] );
195 
196  $store = $this->getRevisionStore( $mockLoadBalancer );
197  $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
198 
199  $this->assertSame( 1, $title->getNamespace() );
200  $this->assertSame( 'Food', $title->getDBkey() );
201  }
202 
207  $mockLoadBalancer = $this->getMockLoadBalancer();
208  // Title calls wfGetDB() so we have to set the main service
209  $this->setService( 'DBLoadBalancer', $mockLoadBalancer );
210 
211  $db = $this->getMockDatabase();
212  // Title calls wfGetDB() which uses getMaintenanceConnectionRef
213  // Assert that the first call uses a REPLICA and the second falls back to master
214  $mockLoadBalancer->expects( $this->atLeastOnce() )
215  ->method( 'getConnectionRef' )
216  ->willReturnCallback( $this->getMockDBConnRefCallback( $mockLoadBalancer, $db ) );
217  // Title calls wfGetDB() which uses getMaintenanceConnectionRef
218  $mockLoadBalancer->expects( $this->exactly( 2 ) )
219  ->method( 'getMaintenanceConnectionRef' )
220  ->willReturnCallback( $this->getMockDBConnRefCallback( $mockLoadBalancer, $db ) );
221 
222  // First call to Title::newFromID, faking no result (db lag?)
223  $db->expects( $this->at( 0 ) )
224  ->method( 'selectRow' )
225  ->with(
226  'page',
227  $this->anything(),
228  [ 'page_id' => 1 ]
229  )
230  ->willReturn( false );
231 
232  // First select using rev_id, faking no result (db lag?)
233  $db->expects( $this->at( 1 ) )
234  ->method( 'selectRow' )
235  ->with(
236  [ 'revision', 'page' ],
237  $this->anything(),
238  [ 'rev_id' => 2 ]
239  )
240  ->willReturn( false );
241 
242  // Second call to Title::newFromID, no result
243  $db->expects( $this->at( 2 ) )
244  ->method( 'selectRow' )
245  ->with(
246  'page',
247  $this->anything(),
248  [ 'page_id' => 1 ]
249  )
250  ->willReturn( (object)[
251  'page_namespace' => '2',
252  'page_title' => 'Foodey',
253  ] );
254 
255  $store = $this->getRevisionStore( $mockLoadBalancer );
256  $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
257 
258  $this->assertSame( 2, $title->getNamespace() );
259  $this->assertSame( 'Foodey', $title->getDBkey() );
260  }
261 
265  public function testGetTitle_successFromRevId() {
266  $mockLoadBalancer = $this->getMockLoadBalancer();
267  // Title calls wfGetDB() so we have to set the main service
268  $this->setService( 'DBLoadBalancer', $mockLoadBalancer );
269 
270  $db = $this->getMockDatabase();
271  $mockLoadBalancer->expects( $this->atLeastOnce() )
272  ->method( 'getConnectionRef' )
273  ->willReturnCallback( $this->getMockDBConnRefCallback( $mockLoadBalancer, $db ) );
274  // Title calls wfGetDB() which uses getMaintenanceConnectionRef
275  // RevisionStore getTitle uses getMaintenanceConnectionRef
276  $mockLoadBalancer->expects( $this->atLeastOnce() )
277  ->method( 'getMaintenanceConnectionRef' )
278  ->willReturnCallback( $this->getMockDBConnRefCallback( $mockLoadBalancer, $db ) );
279 
280  // First call to Title::newFromID, faking no result (db lag?)
281  $db->expects( $this->at( 0 ) )
282  ->method( 'selectRow' )
283  ->with(
284  'page',
285  $this->anything(),
286  [ 'page_id' => 1 ]
287  )
288  ->willReturn( false );
289 
290  // First select using rev_id, faking no result (db lag?)
291  $db->expects( $this->at( 1 ) )
292  ->method( 'selectRow' )
293  ->with(
294  [ 'revision', 'page' ],
295  $this->anything(),
296  [ 'rev_id' => 2 ]
297  )
298  ->willReturn( (object)[
299  'page_namespace' => '1',
300  'page_title' => 'Food2',
301  ] );
302 
303  $store = $this->getRevisionStore( $mockLoadBalancer );
304  $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
305 
306  $this->assertSame( 1, $title->getNamespace() );
307  $this->assertSame( 'Food2', $title->getDBkey() );
308  }
309 
314  $mockLoadBalancer = $this->getMockLoadBalancer();
315  // Title calls wfGetDB() so we have to set the main service
316  $this->setService( 'DBLoadBalancer', $mockLoadBalancer );
317 
318  $db = $this->getMockDatabase();
319  // Assert that the first call uses a REPLICA and the second falls back to master
320  // RevisionStore uses getMaintenanceConnectionRef
321  $mockLoadBalancer->expects( $this->atLeastOnce() )
322  ->method( 'getConnectionRef' )
323  ->willReturnCallback( $this->getMockDBConnRefCallback( $mockLoadBalancer, $db ) );
324  // Title calls wfGetDB() which uses getMaintenanceConnectionRef
325  $mockLoadBalancer->expects( $this->exactly( 2 ) )
326  ->method( 'getMaintenanceConnectionRef' )
327  ->willReturnCallback( $this->getMockDBConnRefCallback( $mockLoadBalancer, $db ) );
328 
329  // First call to Title::newFromID, faking no result (db lag?)
330  $db->expects( $this->at( 0 ) )
331  ->method( 'selectRow' )
332  ->with(
333  'page',
334  $this->anything(),
335  [ 'page_id' => 1 ]
336  )
337  ->willReturn( false );
338 
339  // First select using rev_id, faking no result (db lag?)
340  $db->expects( $this->at( 1 ) )
341  ->method( 'selectRow' )
342  ->with(
343  [ 'revision', 'page' ],
344  $this->anything(),
345  [ 'rev_id' => 2 ]
346  )
347  ->willReturn( false );
348 
349  // Second call to Title::newFromID, no result
350  $db->expects( $this->at( 2 ) )
351  ->method( 'selectRow' )
352  ->with(
353  'page',
354  $this->anything(),
355  [ 'page_id' => 1 ]
356  )
357  ->willReturn( false );
358 
359  // Second select using rev_id, result
360  $db->expects( $this->at( 3 ) )
361  ->method( 'selectRow' )
362  ->with(
363  [ 'revision', 'page' ],
364  $this->anything(),
365  [ 'rev_id' => 2 ]
366  )
367  ->willReturn( (object)[
368  'page_namespace' => '2',
369  'page_title' => 'Foodey',
370  ] );
371 
372  $store = $this->getRevisionStore( $mockLoadBalancer );
373  $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
374 
375  $this->assertSame( 2, $title->getNamespace() );
376  $this->assertSame( 'Foodey', $title->getDBkey() );
377  }
378 
383  $mockLoadBalancer = $this->getMockLoadBalancer();
384  // Title calls wfGetDB() so we have to set the main service
385  $this->setService( 'DBLoadBalancer', $mockLoadBalancer );
386 
387  $db = $this->getMockDatabase();
388  // Title calls wfGetDB() which uses getMaintenanceConnectionRef
389  // Assert that the first call uses a REPLICA and the second falls back to master
390 
391  // RevisionStore getTitle uses getConnectionRef
392  // Title::newFromID uses getMaintenanceConnectionRef
393  foreach ( [
394  'getConnectionRef', 'getMaintenanceConnectionRef'
395  ] as $method ) {
396  $mockLoadBalancer->expects( $this->exactly( 2 ) )
397  ->method( $method )
398  ->willReturnCallback( function ( $masterOrReplica ) use ( $db ) {
399  static $callCounter = 0;
400  $callCounter++;
401  // The first call should be to a REPLICA, and the second a MASTER.
402  if ( $callCounter === 1 ) {
403  $this->assertSame( DB_REPLICA, $masterOrReplica );
404  } elseif ( $callCounter === 2 ) {
405  $this->assertSame( DB_MASTER, $masterOrReplica );
406  }
407  return $db;
408  } );
409  }
410  // First and third call to Title::newFromID, faking no result
411  foreach ( [ 0, 2 ] as $counter ) {
412  $db->expects( $this->at( $counter ) )
413  ->method( 'selectRow' )
414  ->with(
415  'page',
416  $this->anything(),
417  [ 'page_id' => 1 ]
418  )
419  ->willReturn( false );
420  }
421 
422  foreach ( [ 1, 3 ] as $counter ) {
423  $db->expects( $this->at( $counter ) )
424  ->method( 'selectRow' )
425  ->with(
426  [ 'revision', 'page' ],
427  $this->anything(),
428  [ 'rev_id' => 2 ]
429  )
430  ->willReturn( false );
431  }
432 
433  $store = $this->getRevisionStore( $mockLoadBalancer );
434 
435  $this->setExpectedException( RevisionAccessException::class );
436  $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
437  }
438 
440  yield 'windows-1252, old_flags is empty' => [
441  'windows-1252',
442  'en',
443  [
444  'old_flags' => '',
445  'old_text' => "S\xF6me Content",
446  ],
447  'Söme Content'
448  ];
449 
450  yield 'windows-1252, old_flags is null' => [
451  'windows-1252',
452  'en',
453  [
454  'old_flags' => null,
455  'old_text' => "S\xF6me Content",
456  ],
457  'Söme Content'
458  ];
459  }
460 
466  public function testNewRevisionFromRow_legacyEncoding_applied( $encoding, $locale, $row, $text ) {
467  if ( !$this->useTextId() ) {
468  $this->markTestSkipped( 'No longer applicable with MCR schema' );
469  }
470 
471  $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
473  $lb = $services->getDBLoadBalancer();
474  $access = $services->getExternalStoreAccess();
475 
476  $blobStore = new SqlBlobStore( $lb, $access, $cache );
477 
478  $blobStore->setLegacyEncoding( $encoding, Language::factory( $locale ) );
479 
480  $store = $this->getRevisionStore( $lb, $blobStore, $cache );
481 
482  $record = $store->newRevisionFromRow(
483  $this->makeRow( $row ),
484  0,
485  Title::newFromText( __METHOD__ . '-UTPage' )
486  );
487 
488  $this->assertSame( $text, $record->getContent( SlotRecord::MAIN )->serialize() );
489  }
490 
495  if ( !$this->useTextId() ) {
496  $this->markTestSkipped( 'No longer applicable with MCR schema' );
497  }
498 
499  $row = [
500  'old_flags' => 'utf-8',
501  'old_text' => 'Söme Content',
502  ];
503 
504  $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
506  $lb = $services->getDBLoadBalancer();
507  $access = $services->getExternalStoreAccess();
508 
509  $blobStore = new SqlBlobStore( $lb, $access, $cache );
510  $blobStore->setLegacyEncoding( 'windows-1252', Language::factory( 'en' ) );
511 
512  $store = $this->getRevisionStore( $lb, $blobStore, $cache );
513 
514  $record = $store->newRevisionFromRow(
515  $this->makeRow( $row ),
516  0,
517  Title::newFromText( __METHOD__ . '-UTPage' )
518  );
519  $this->assertSame( 'Söme Content', $record->getContent( SlotRecord::MAIN )->serialize() );
520  }
521 
522  private function makeRow( array $array ) {
523  $row = $array + [
524  'rev_id' => 7,
525  'rev_page' => 5,
526  'rev_timestamp' => '20110101000000',
527  'rev_user_text' => 'Tester',
528  'rev_user' => 17,
529  'rev_minor_edit' => 0,
530  'rev_deleted' => 0,
531  'rev_len' => 100,
532  'rev_parent_id' => 0,
533  'rev_sha1' => 'deadbeef',
534  'rev_comment_text' => 'Testing',
535  'rev_comment_data' => '{}',
536  'rev_comment_cid' => 111,
537  'page_namespace' => 0,
538  'page_title' => 'TEST',
539  'page_id' => 5,
540  'page_latest' => 7,
541  'page_is_redirect' => 0,
542  'page_len' => 100,
543  'user_name' => 'Tester',
544  ];
545 
546  if ( $this->useTextId() ) {
547  $row += [
548  'rev_content_format' => CONTENT_FORMAT_TEXT,
549  'rev_content_model' => CONTENT_MODEL_TEXT,
550  'rev_text_id' => 11,
551  'old_id' => 11,
552  'old_text' => 'Hello World',
553  'old_flags' => 'utf-8',
554  ];
555  } elseif ( !isset( $row['content'] ) && isset( $array['old_text'] ) ) {
556  $row['content'] = [
557  'main' => new WikitextContent( $array['old_text'] ),
558  ];
559  }
560 
561  return (object)$row;
562  }
563 
564  public function provideMigrationConstruction() {
565  return [
573  ];
574  }
575 
580  public function testMigrationConstruction( $migration, $expectException ) {
581  if ( $expectException ) {
582  $this->setExpectedException( InvalidArgumentException::class );
583  }
584  $loadBalancer = $this->getMockLoadBalancer();
585  $blobStore = $this->getMockSqlBlobStore();
586  $cache = $this->getHashWANObjectCache();
587  $commentStore = $this->getMockCommentStore();
589  $nameTables = $services->getNameTableStoreFactory();
590  $contentModelStore = $nameTables->getContentModels();
591  $slotRoleStore = $nameTables->getSlotRoles();
592  $slotRoleRegistry = $services->getSlotRoleRegistry();
593  $store = new RevisionStore(
594  $loadBalancer,
595  $blobStore,
596  $cache,
597  $commentStore,
598  $nameTables->getContentModels(),
599  $nameTables->getSlotRoles(),
600  $slotRoleRegistry,
601  $migration,
602  $services->getActorMigration()
603  );
604  if ( !$expectException ) {
605  $store = TestingAccessWrapper::newFromObject( $store );
606  $this->assertSame( $loadBalancer, $store->loadBalancer );
607  $this->assertSame( $blobStore, $store->blobStore );
608  $this->assertSame( $cache, $store->cache );
609  $this->assertSame( $commentStore, $store->commentStore );
610  $this->assertSame( $contentModelStore, $store->contentModelStore );
611  $this->assertSame( $slotRoleStore, $store->slotRoleStore );
612  $this->assertSame( $migration, $store->mcrMigrationStage );
613  }
614  }
615 
616 }
const SCHEMA_COMPAT_WRITE_OLD
Definition: Defines.php:264
Service for storing and loading Content objects.
testMigrationConstruction( $migration, $expectException)
\MediaWiki\Revision\RevisionStore::__construct provideMigrationConstruction
const SCHEMA_COMPAT_READ_BOTH
Definition: Defines.php:269
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:193
int $wgMultiContentRevisionSchemaMigrationStage
RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables)...
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
testSetContentHandlerUseDB( $contentHandlerDb, $migrationMode, $expectedFail)
provideSetContentHandlerUseDB \MediaWiki\Revision\RevisionStore::getContentHandlerUseDB \MediaWiki\Re...
const SCHEMA_COMPAT_READ_NEW
Definition: Defines.php:267
testGetTitle_successFromRevIdOnFallback()
\MediaWiki\Revision\RevisionStore::getTitle
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 MediaWikiServices
Definition: injection.txt:23
const CONTENT_MODEL_TEXT
Definition: Defines.php:218
static getInstance()
Returns the global default instance of the top level service locator.
const DB_MASTER
Definition: defines.php:26
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 and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same so they can t rely on Unix and must forbid reads to even standard directories like tmp lest users read each others files We cannot assume that the user has the ability to install or run any programs not written as web accessible PHP scripts Since anything that works on cheap shared hosting will work if you have shell or root access MediaWiki s design is based around catering to the lowest common denominator Although we support higher end setups as the way many things work by default is tailored toward shared hosting These defaults are unconventional from the point of view of and they certainly aren t ideal for someone who s installing MediaWiki as MediaWiki does not conform to normal Unix filesystem layout Hopefully we ll offer direct support for standard layouts in the but for now *any change to the location of files is unsupported *Moving things and leaving symlinks will *probably *not break anything
getRevisionStore( $loadBalancer=null, $blobStore=null, $WANObjectCache=null)
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:1978
const CONTENT_FORMAT_TEXT
Definition: Defines.php:236
testNewRevisionFromRow_legacyEncoding_applied( $encoding, $locale, $row, $text)
provideNewRevisionFromRow_legacyEncoding_applied
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Definition: hooks.txt:2211
Service for looking up page revisions.
const SCHEMA_COMPAT_WRITE_NEW
Definition: Defines.php:266
$cache
Definition: mcc.php:33
getMockDBConnRefCallback(ILoadBalancer $mockLoadBalancer, IDatabase $db)
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:773
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:918
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:216
testGetTitle_successFromRevId()
\MediaWiki\Revision\RevisionStore::getTitle
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
const SCHEMA_COMPAT_WRITE_BOTH
Definition: Defines.php:268
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
Database cluster connection, tracking, load balancing, and transaction manager interface.
testGetTitle_successFromPageId()
\MediaWiki\Revision\RevisionStore::getTitle
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
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:52
setContentHandlerUseDB( $contentHandlerUseDB)
const SCHEMA_COMPAT_NEW
Definition: Defines.php:271
Helper class to handle automatically marking connections as reusable (via RAII pattern) as well handl...
testNewRevisionFromRow_legacyEncoding_ignored()
\MediaWiki\Revision\RevisionStore::newRevisionFromRow
const DB_REPLICA
Definition: defines.php:25
const SCHEMA_COMPAT_READ_OLD
Definition: Defines.php:265
const SCHEMA_COMPAT_OLD
Definition: Defines.php:270
testGetTitle_correctFallbackAndthrowsExceptionAfterFallbacks()
\MediaWiki\Revision\RevisionStore::getTitle
testGetTitle_successFromPageIdOnFallback()
\MediaWiki\Revision\RevisionStore::getTitle
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:322