MediaWiki REL1_33
NameTableStoreTest.php
Go to the documentation of this file.
1<?php
2
4
12use PHPUnit\Framework\MockObject\MockObject;
13use Psr\Log\NullLogger;
14use RuntimeException;
19use Wikimedia\TestingAccessWrapper;
20
27
28 public function setUp() {
29 $this->tablesUsed[] = 'slot_roles';
30 parent::setUp();
31 }
32
33 protected function addCoreDBData() {
34 // The default implementation causes the slot_roles to already have content. Skip that.
35 }
36
37 private function populateTable( $values ) {
38 $insertValues = [];
39 foreach ( $values as $name ) {
40 $insertValues[] = [ 'role_name' => $name ];
41 }
42 $this->db->insert( 'slot_roles', $insertValues );
43 }
44
45 private function getHashWANObjectCache( $cacheBag ) {
46 return new WANObjectCache( [ 'cache' => $cacheBag ] );
47 }
48
53 private function getMockLoadBalancer( $db ) {
54 $mock = $this->getMockBuilder( LoadBalancer::class )
55 ->disableOriginalConstructor()
56 ->getMock();
57 $mock->expects( $this->any() )
58 ->method( 'getConnectionRef' )
59 ->willReturnCallback( function ( $i ) use ( $mock, $db ) {
60 return new MaintainableDBConnRef( $mock, $db, $i );
61 } );
62 return $mock;
63 }
64
71 private function getProxyDb( $insertCalls = null, $selectCalls = null ) {
72 $proxiedMethods = [
73 'select' => $selectCalls,
74 'insert' => $insertCalls,
75 'affectedRows' => null,
76 'insertId' => null,
77 'getSessionLagStatus' => null,
78 'writesPending' => null,
79 'onTransactionPreCommitOrIdle' => null,
80 'onAtomicSectionCancel' => null,
81 'doAtomicSection' => null,
82 'begin' => null,
83 'rollback' => null,
84 'commit' => null,
85 ];
86 $mock = $this->getMockBuilder( IDatabase::class )
87 ->disableOriginalConstructor()
88 ->getMock();
89 foreach ( $proxiedMethods as $method => $count ) {
90 $mock->expects( is_int( $count ) ? $this->exactly( $count ) : $this->any() )
91 ->method( $method )
92 ->willReturnCallback( function ( ...$args ) use ( $method ) {
93 return call_user_func_array( [ $this->db, $method ], $args );
94 } );
95 }
96 return $mock;
97 }
98
99 private function getNameTableSqlStore(
100 BagOStuff $cacheBag,
101 $insertCalls,
102 $selectCalls,
103 $normalizationCallback = null,
104 $insertCallback = null
105 ) {
106 return new NameTableStore(
107 $this->getMockLoadBalancer( $this->getProxyDb( $insertCalls, $selectCalls ) ),
108 $this->getHashWANObjectCache( $cacheBag ),
109 new NullLogger(),
110 'slot_roles', 'role_id', 'role_name',
111 $normalizationCallback,
112 false,
113 $insertCallback
114 );
115 }
116
117 public function provideGetAndAcquireId() {
118 return [
119 'no wancache, empty table' =>
120 [ new EmptyBagOStuff(), true, 1, [], 'foo', 1 ],
121 'no wancache, one matching value' =>
122 [ new EmptyBagOStuff(), false, 1, [ 'foo' ], 'foo', 1 ],
123 'no wancache, one not matching value' =>
124 [ new EmptyBagOStuff(), true, 1, [ 'bar' ], 'foo', 2 ],
125 'no wancache, multiple, one matching value' =>
126 [ new EmptyBagOStuff(), false, 1, [ 'foo', 'bar' ], 'bar', 2 ],
127 'no wancache, multiple, no matching value' =>
128 [ new EmptyBagOStuff(), true, 1, [ 'foo', 'bar' ], 'baz', 3 ],
129 'wancache, empty table' =>
130 [ new HashBagOStuff(), true, 1, [], 'foo', 1 ],
131 'wancache, one matching value' =>
132 [ new HashBagOStuff(), false, 1, [ 'foo' ], 'foo', 1 ],
133 'wancache, one not matching value' =>
134 [ new HashBagOStuff(), true, 1, [ 'bar' ], 'foo', 2 ],
135 'wancache, multiple, one matching value' =>
136 [ new HashBagOStuff(), false, 1, [ 'foo', 'bar' ], 'bar', 2 ],
137 'wancache, multiple, no matching value' =>
138 [ new HashBagOStuff(), true, 1, [ 'foo', 'bar' ], 'baz', 3 ],
139 ];
140 }
141
151 public function testGetAndAcquireId(
152 $cacheBag,
153 $needsInsert,
154 $selectCalls,
155 $existingValues,
156 $name,
157 $expectedId
158 ) {
159 // Make sure the table is empty!
160 $this->truncateTable( 'slot_roles' );
161
162 $this->populateTable( $existingValues );
163 $store = $this->getNameTableSqlStore( $cacheBag, (int)$needsInsert, $selectCalls );
164
165 // Some names will not initially exist
166 try {
167 $result = $store->getId( $name );
168 $this->assertSame( $expectedId, $result );
169 } catch ( NameTableAccessException $e ) {
170 if ( $needsInsert ) {
171 $this->assertTrue( true ); // Expected exception
172 } else {
173 $this->fail( 'Did not expect an exception, but got one: ' . $e->getMessage() );
174 }
175 }
176
177 // All names should return their id here
178 $this->assertSame( $expectedId, $store->acquireId( $name ) );
179
180 // acquireId inserted these names, so now everything should exist with getId
181 $this->assertSame( $expectedId, $store->getId( $name ) );
182
183 // calling getId again will also still work, and not result in more selects
184 $this->assertSame( $expectedId, $store->getId( $name ) );
185 }
186
188 yield [ 'A', 'a', 'strtolower' ];
189 yield [ 'b', 'B', 'strtoupper' ];
190 yield [
191 'X',
192 'X',
193 function ( $name ) {
194 return $name;
195 }
196 ];
197 yield [ 'ZZ', 'ZZ-a', __CLASS__ . '::appendDashAToString' ];
198 }
199
200 public static function appendDashAToString( $string ) {
201 return $string . '-a';
202 }
203
208 $nameIn,
209 $nameOut,
210 $normalizationCallback
211 ) {
212 $store = $this->getNameTableSqlStore(
213 new EmptyBagOStuff(),
214 1,
215 1,
216 $normalizationCallback
217 );
218 $acquiredId = $store->acquireId( $nameIn );
219 $this->assertSame( $nameOut, $store->getName( $acquiredId ) );
220 }
221
222 public function provideGetName() {
223 return [
224 [ new HashBagOStuff(), 3, 2 ],
225 [ new EmptyBagOStuff(), 3, 3 ],
226 ];
227 }
228
232 public function testGetName( $cacheBag, $insertCalls, $selectCalls ) {
233 // Check for operations to in-memory cache (IMC) and persistent cache (PC)
234 $store = $this->getNameTableSqlStore( $cacheBag, $insertCalls, $selectCalls );
235
236 // Get 1 ID and make sure getName returns correctly
237 $fooId = $store->acquireId( 'foo' ); // regen PC, set IMC, update IMC, tombstone PC
238 $this->assertSame( 'foo', $store->getName( $fooId ) ); // use IMC
239
240 // Get another ID and make sure getName returns correctly
241 $barId = $store->acquireId( 'bar' ); // update IMC, tombstone PC
242 $this->assertSame( 'bar', $store->getName( $barId ) ); // use IMC
243
244 // Blitz the cache and make sure it still returns
245 TestingAccessWrapper::newFromObject( $store )->tableCache = null; // clear IMC
246 $this->assertSame( 'foo', $store->getName( $fooId ) ); // regen interim PC, set IMC
247 $this->assertSame( 'bar', $store->getName( $barId ) ); // use IMC
248
249 // Blitz the cache again and get another ID and make sure getName returns correctly
250 TestingAccessWrapper::newFromObject( $store )->tableCache = null; // clear IMC
251 $bazId = $store->acquireId( 'baz' ); // set IMC using interim PC, update IMC, tombstone PC
252 $this->assertSame( 'baz', $store->getName( $bazId ) ); // uses IMC
253 $this->assertSame( 'baz', $store->getName( $bazId ) ); // uses IMC
254 }
255
256 public function testGetName_masterFallback() {
257 $store = $this->getNameTableSqlStore( new EmptyBagOStuff(), 1, 2 );
258
259 // Insert a new name
260 $fooId = $store->acquireId( 'foo' );
261
262 // Empty the process cache, getCachedTable() will now return this empty array
263 TestingAccessWrapper::newFromObject( $store )->tableCache = [];
264
265 // getName should fallback to master, which is why we assert 2 selectCalls above
266 $this->assertSame( 'foo', $store->getName( $fooId ) );
267 }
268
269 public function testGetMap_empty() {
270 $this->populateTable( [] );
271 $store = $this->getNameTableSqlStore( new HashBagOStuff(), 0, 1 );
272 $table = $store->getMap();
273 $this->assertSame( [], $table );
274 }
275
276 public function testGetMap_twoValues() {
277 $this->populateTable( [ 'foo', 'bar' ] );
278 $store = $this->getNameTableSqlStore( new HashBagOStuff(), 0, 1 );
279
280 // We are using a cache, so 2 calls should only result in 1 select on the db
281 $store->getMap();
282 $table = $store->getMap();
283
284 $expected = [ 1 => 'foo', 2 => 'bar' ];
285 $this->assertSame( $expected, $table );
286 // Make sure the table returned is the same as the cached table
287 $this->assertSame( $expected, TestingAccessWrapper::newFromObject( $store )->tableCache );
288 }
289
290 public function testReloadMap() {
291 $this->populateTable( [ 'foo' ] );
292 $store = $this->getNameTableSqlStore( new HashBagOStuff(), 0, 2 );
293
294 // force load
295 $this->assertCount( 1, $store->getMap() );
296
297 // add more stuff to the table, so the cache gets out of sync
298 $this->populateTable( [ 'bar' ] );
299
300 $expected = [ 1 => 'foo', 2 => 'bar' ];
301 $this->assertSame( $expected, $store->reloadMap() );
302 $this->assertSame( $expected, $store->getMap() );
303 }
304
305 public function testCacheRaceCondition() {
306 $wanHashBag = new HashBagOStuff();
307 $store1 = $this->getNameTableSqlStore( $wanHashBag, 1, 1 );
308 $store2 = $this->getNameTableSqlStore( $wanHashBag, 1, 0 );
309 $store3 = $this->getNameTableSqlStore( $wanHashBag, 1, 1 );
310
311 // Cache the current table in the instances we will use
312 // This simulates multiple requests running simultaneously
313 $store1->getMap();
314 $store2->getMap();
315 $store3->getMap();
316
317 // Store 2 separate names using different instances
318 $fooId = $store1->acquireId( 'foo' );
319 $barId = $store2->acquireId( 'bar' );
320
321 // Each of these instances should be aware of what they have inserted
322 $this->assertSame( $fooId, $store1->acquireId( 'foo' ) );
323 $this->assertSame( $barId, $store2->acquireId( 'bar' ) );
324
325 // A new store should be able to get both of these new Ids
326 // Note: before there was a race condition here where acquireId( 'bar' ) would update the
327 // cache with data missing the 'foo' key that it was not aware of
328 $store4 = $this->getNameTableSqlStore( $wanHashBag, 0, 1 );
329 $this->assertSame( $fooId, $store4->getId( 'foo' ) );
330 $this->assertSame( $barId, $store4->getId( 'bar' ) );
331
332 // If a store with old cached data tries to acquire these we will get the same ids.
333 $this->assertSame( $fooId, $store3->acquireId( 'foo' ) );
334 $this->assertSame( $barId, $store3->acquireId( 'bar' ) );
335 }
336
338 // FIXME: fails under postgres
339 $this->markTestSkippedIfDbType( 'postgres' );
340
341 $store = $this->getNameTableSqlStore(
342 new EmptyBagOStuff(),
343 1,
344 1,
345 null,
346 function ( $insertFields ) {
347 $insertFields['role_id'] = 7251;
348 return $insertFields;
349 }
350 );
351 $this->assertSame( 7251, $store->acquireId( 'A' ) );
352 }
353
354 public function testTransactionRollback() {
355 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
356
357 // Two instances hitting the real database using separate caches.
358 $store1 = new NameTableStore(
359 $lb,
360 $this->getHashWANObjectCache( new HashBagOStuff() ),
361 new NullLogger(),
362 'slot_roles', 'role_id', 'role_name'
363 );
364 $store2 = new NameTableStore(
365 $lb,
366 $this->getHashWANObjectCache( new HashBagOStuff() ),
367 new NullLogger(),
368 'slot_roles', 'role_id', 'role_name'
369 );
370
371 $this->db->begin( __METHOD__ );
372 $fooId = $store1->acquireId( 'foo' );
373 $this->db->rollback( __METHOD__ );
374
375 $this->assertSame( $fooId, $store2->getId( 'foo' ) );
376 $this->assertSame( $fooId, $store1->getId( 'foo' ) );
377 }
378
380 $insertCalls = 0;
381
382 $db = $this->getProxyDb( 2 );
383 $db->method( 'insert' )
384 ->willReturnCallback( function () use ( &$insertCalls, $db ) {
385 $insertCalls++;
386 switch ( $insertCalls ) {
387 case 1:
388 return true;
389 case 2:
390 throw new RuntimeException( 'Testing' );
391 }
392
393 return true;
394 } );
395
396 $lb = $this->getMockBuilder( LoadBalancer::class )
397 ->disableOriginalConstructor()
398 ->getMock();
399 $lb->method( 'getConnectionRef' )
400 ->willReturn( $db );
401 $lb->method( 'resolveDomainID' )
402 ->willReturnArgument( 0 );
403
404 // Two instances hitting the real database using separate caches.
405 $store1 = new NameTableStore(
406 $lb,
407 $this->getHashWANObjectCache( new HashBagOStuff() ),
408 new NullLogger(),
409 'slot_roles', 'role_id', 'role_name'
410 );
411
412 $this->db->begin( __METHOD__ );
413 $store1->acquireId( 'foo' );
414 $this->db->rollback( __METHOD__ );
415
416 $this->assertArrayNotHasKey( 'foo', $store1->getMap() );
417 }
418
420 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
421
422 // Two instances hitting the real database using separate caches.
423 $store1 = new NameTableStore(
424 $lb,
425 $this->getHashWANObjectCache( new HashBagOStuff() ),
426 new NullLogger(),
427 'slot_roles', 'role_id', 'role_name'
428 );
429 $store2 = new NameTableStore(
430 $lb,
431 $this->getHashWANObjectCache( new HashBagOStuff() ),
432 new NullLogger(),
433 'slot_roles', 'role_id', 'role_name'
434 );
435
436 $this->db->begin( __METHOD__ );
437
438 $quuxId = null;
439 $this->db->onTransactionResolution(
440 function () use ( $store1, &$quuxId ) {
441 $quuxId = $store1->acquireId( 'quux' );
442 }
443 );
444
445 $store1->acquireId( 'foo' );
446 $this->db->rollback( __METHOD__ );
447
448 // $store2 should know about the insert by $store1
449 $this->assertSame( $quuxId, $store2->getId( 'quux' ) );
450
451 // A "best effort" attempt was made to restore the entry for 'foo'
452 // after the transaction failed. This may succeed on some databases like MySQL,
453 // while it fails on others. Since we are giving no guarantee about this,
454 // the only thing we can test here is that acquireId( 'foo' ) returns an
455 // ID that is distinct from the ID of quux (but might be different from the
456 // value returned by the original call to acquireId( 'foo' ).
457 // Note that $store2 will not know about the ID for 'foo' acquired by $store1,
458 // because it's using a separate cache, and getId() does not fall back to
459 // checking the database.
460 $this->assertNotSame( $quuxId, $store1->acquireId( 'foo' ) );
461 }
462
464 $fname = __METHOD__;
465
466 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
467 $store = new NameTableStore(
468 $lb,
469 $this->getHashWANObjectCache( new HashBagOStuff() ),
470 new NullLogger(),
471 'slot_roles', 'role_id', 'role_name'
472 );
473
474 // Nested atomic sections
475 $atomic1 = $this->db->startAtomic( $fname, $this->db::ATOMIC_CANCELABLE );
476 $atomic2 = $this->db->startAtomic( $fname, $this->db::ATOMIC_CANCELABLE );
477
478 // Acquire ID
479 $id = $store->acquireId( 'foo' );
480
481 // Oops, rolled back
482 $this->db->cancelAtomic( $fname, $atomic2 );
483
484 // Should have been re-inserted
485 $store->reloadMap();
486 $this->assertSame( $id, $store->getId( 'foo' ) );
487
488 // Oops, re-insert was rolled back too.
489 $this->db->cancelAtomic( $fname, $atomic1 );
490
491 // This time, no re-insertion happened.
492 try {
493 $id2 = $store->getId( 'foo' );
494 $this->fail( "Expected NameTableAccessException, got $id2 (originally was $id)" );
495 } catch ( NameTableAccessException $ex ) {
496 // expected
497 }
498 }
499
500}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition Setup.php:123
if( $line===false) $args
Definition cdb.php:64
Class representing a cache/ephemeral data store.
Definition BagOStuff.php:58
A BagOStuff object with no objects in it.
Simple store for keeping values in an associative array for the current process.
Database $db
Primary database.
truncateTable( $tableName, IDatabase $db=null)
Empties the given table and resets any auto-increment counters.
markTestSkippedIfDbType( $type)
Skip the test if using the specified database type.
MediaWikiServices is the service locator for the application scope of MediaWiki.
static getInstance()
Returns the global default instance of the top level service locator.
Exception representing a failure to look up a row from a name table.
testGetName( $cacheBag, $insertCalls, $selectCalls)
provideGetName
testGetAndAcquireIdNameNormalization( $nameIn, $nameOut, $normalizationCallback)
provideTestGetAndAcquireIdNameNormalization
getProxyDb( $insertCalls=null, $selectCalls=null)
getNameTableSqlStore(BagOStuff $cacheBag, $insertCalls, $selectCalls, $normalizationCallback=null, $insertCallback=null)
testGetAndAcquireId( $cacheBag, $needsInsert, $selectCalls, $existingValues, $name, $expectedId)
provideGetAndAcquireId
Multi-datacenter aware caching interface.
Database connection, tracking, load balancing, and transaction manager for a cluster.
Helper class to handle automatically marking connections as reusable (via RAII pattern) as well handl...
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
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. '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 '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 since 1.28! 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:1991
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:271
returning false will NOT prevent logging $e
Definition hooks.txt:2175
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
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38