MediaWiki REL1_28
LocalPasswordPrimaryAuthenticationProviderTest.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Auth;
4
11
12 private $manager = null;
13 private $config = null;
14 private $validity = null;
15
25 protected function getProvider( $loginOnly = false ) {
26 if ( !$this->config ) {
27 $this->config = new \HashConfig();
28 }
29 $config = new \MultiConfig( [
30 $this->config,
31 \ConfigFactory::getDefaultInstance()->makeConfig( 'main' )
32 ] );
33
34 if ( !$this->manager ) {
35 $this->manager = new AuthManager( new \FauxRequest(), $config );
36 }
37 $this->validity = \Status::newGood();
38
39 $provider = $this->getMock(
40 LocalPasswordPrimaryAuthenticationProvider::class,
41 [ 'checkPasswordValidity' ],
42 [ [ 'loginOnly' => $loginOnly ] ]
43 );
44 $provider->expects( $this->any() )->method( 'checkPasswordValidity' )
45 ->will( $this->returnCallback( function () {
46 return $this->validity;
47 } ) );
48 $provider->setConfig( $config );
49 $provider->setLogger( new \Psr\Log\NullLogger() );
50 $provider->setManager( $this->manager );
51
52 return $provider;
53 }
54
55 public function testBasics() {
56 $user = $this->getMutableTestUser()->getUser();
57 $userName = $user->getName();
58 $lowerInitialUserName = mb_strtolower( $userName[0] ) . substr( $userName, 1 );
59
61
62 $this->assertSame(
64 $provider->accountCreationType()
65 );
66
67 $this->assertTrue( $provider->testUserExists( $userName ) );
68 $this->assertTrue( $provider->testUserExists( $lowerInitialUserName ) );
69 $this->assertFalse( $provider->testUserExists( 'DoesNotExist' ) );
70 $this->assertFalse( $provider->testUserExists( '<invalid>' ) );
71
72 $provider = new LocalPasswordPrimaryAuthenticationProvider( [ 'loginOnly' => true ] );
73
74 $this->assertSame(
76 $provider->accountCreationType()
77 );
78
79 $this->assertTrue( $provider->testUserExists( $userName ) );
80 $this->assertFalse( $provider->testUserExists( 'DoesNotExist' ) );
81
84 $req->username = '<invalid>';
85 $provider->providerChangeAuthenticationData( $req );
86 }
87
88 public function testTestUserCanAuthenticate() {
89 $user = $this->getMutableTestUser()->getUser();
90 $userName = $user->getName();
91 $dbw = wfGetDB( DB_MASTER );
92
93 $provider = $this->getProvider();
94
95 $this->assertFalse( $provider->testUserCanAuthenticate( '<invalid>' ) );
96
97 $this->assertFalse( $provider->testUserCanAuthenticate( 'DoesNotExist' ) );
98
99 $this->assertTrue( $provider->testUserCanAuthenticate( $userName ) );
100 $lowerInitialUserName = mb_strtolower( $userName[0] ) . substr( $userName, 1 );
101 $this->assertTrue( $provider->testUserCanAuthenticate( $lowerInitialUserName ) );
102
103 $dbw->update(
104 'user',
105 [ 'user_password' => \PasswordFactory::newInvalidPassword()->toString() ],
106 [ 'user_name' => $userName ]
107 );
108 $this->assertFalse( $provider->testUserCanAuthenticate( $userName ) );
109
110 // Really old format
111 $dbw->update(
112 'user',
113 [ 'user_password' => '0123456789abcdef0123456789abcdef' ],
114 [ 'user_name' => $userName ]
115 );
116 $this->assertTrue( $provider->testUserCanAuthenticate( $userName ) );
117 }
118
119 public function testSetPasswordResetFlag() {
120 // Set instance vars
121 $this->getProvider();
122
124 $this->setMwGlobals( [ 'wgPasswordExpireGrace' => 100 ] );
125
126 $this->config->set( 'PasswordExpireGrace', 100 );
127 $this->config->set( 'InvalidPasswordReset', true );
128
130 $provider->setConfig( $this->config );
131 $provider->setLogger( new \Psr\Log\NullLogger() );
132 $provider->setManager( $this->manager );
133 $providerPriv = \TestingAccessWrapper::newFromObject( $provider );
134
135 $user = $this->getMutableTestUser()->getUser();
136 $userName = $user->getName();
137 $dbw = wfGetDB( DB_MASTER );
138 $row = $dbw->selectRow(
139 'user',
140 '*',
141 [ 'user_name' => $userName ],
142 __METHOD__
143 );
144
145 $this->manager->removeAuthenticationSessionData( null );
146 $row->user_password_expires = wfTimestamp( TS_MW, time() + 200 );
147 $providerPriv->setPasswordResetFlag( $userName, \Status::newGood(), $row );
148 $this->assertNull( $this->manager->getAuthenticationSessionData( 'reset-pass' ) );
149
150 $this->manager->removeAuthenticationSessionData( null );
151 $row->user_password_expires = wfTimestamp( TS_MW, time() - 200 );
152 $providerPriv->setPasswordResetFlag( $userName, \Status::newGood(), $row );
153 $ret = $this->manager->getAuthenticationSessionData( 'reset-pass' );
154 $this->assertNotNull( $ret );
155 $this->assertSame( 'resetpass-expired', $ret->msg->getKey() );
156 $this->assertTrue( $ret->hard );
157
158 $this->manager->removeAuthenticationSessionData( null );
159 $row->user_password_expires = wfTimestamp( TS_MW, time() - 1 );
160 $providerPriv->setPasswordResetFlag( $userName, \Status::newGood(), $row );
161 $ret = $this->manager->getAuthenticationSessionData( 'reset-pass' );
162 $this->assertNotNull( $ret );
163 $this->assertSame( 'resetpass-expired-soft', $ret->msg->getKey() );
164 $this->assertFalse( $ret->hard );
165
166 $this->manager->removeAuthenticationSessionData( null );
167 $row->user_password_expires = null;
168 $status = \Status::newGood();
169 $status->error( 'testing' );
170 $providerPriv->setPasswordResetFlag( $userName, $status, $row );
171 $ret = $this->manager->getAuthenticationSessionData( 'reset-pass' );
172 $this->assertNotNull( $ret );
173 $this->assertSame( 'resetpass-validity-soft', $ret->msg->getKey() );
174 $this->assertFalse( $ret->hard );
175 }
176
177 public function testAuthentication() {
178 $testUser = $this->getMutableTestUser();
179 $userName = $testUser->getUser()->getName();
180
181 $dbw = wfGetDB( DB_MASTER );
182 $id = \User::idFromName( $userName );
183
186 $reqs = [ PasswordAuthenticationRequest::class => $req ];
187
188 $provider = $this->getProvider();
189
190 // General failures
191 $this->assertEquals(
193 $provider->beginPrimaryAuthentication( [] )
194 );
195
196 $req->username = 'foo';
197 $req->password = null;
198 $this->assertEquals(
200 $provider->beginPrimaryAuthentication( $reqs )
201 );
202
203 $req->username = null;
204 $req->password = 'bar';
205 $this->assertEquals(
207 $provider->beginPrimaryAuthentication( $reqs )
208 );
209
210 $req->username = '<invalid>';
211 $req->password = 'WhoCares';
212 $ret = $provider->beginPrimaryAuthentication( $reqs );
213 $this->assertEquals(
215 $provider->beginPrimaryAuthentication( $reqs )
216 );
217
218 $req->username = 'DoesNotExist';
219 $req->password = 'DoesNotExist';
220 $ret = $provider->beginPrimaryAuthentication( $reqs );
221 $this->assertEquals(
223 $ret->status
224 );
225 $this->assertEquals(
226 'wrongpassword',
227 $ret->message->getKey()
228 );
229
230 // Validation failure
231 $req->username = $userName;
232 $req->password = $testUser->getPassword();
233 $this->validity = \Status::newFatal( 'arbitrary-failure' );
234 $ret = $provider->beginPrimaryAuthentication( $reqs );
235 $this->assertEquals(
237 $ret->status
238 );
239 $this->assertEquals(
240 'arbitrary-failure',
241 $ret->message->getKey()
242 );
243
244 // Successful auth
245 $this->manager->removeAuthenticationSessionData( null );
246 $this->validity = \Status::newGood();
247 $this->assertEquals(
249 $provider->beginPrimaryAuthentication( $reqs )
250 );
251 $this->assertNull( $this->manager->getAuthenticationSessionData( 'reset-pass' ) );
252
253 // Successful auth after normalizing name
254 $this->manager->removeAuthenticationSessionData( null );
255 $this->validity = \Status::newGood();
256 $req->username = mb_strtolower( $userName[0] ) . substr( $userName, 1 );
257 $this->assertEquals(
259 $provider->beginPrimaryAuthentication( $reqs )
260 );
261 $this->assertNull( $this->manager->getAuthenticationSessionData( 'reset-pass' ) );
262 $req->username = $userName;
263
264 // Successful auth with reset
265 $this->manager->removeAuthenticationSessionData( null );
266 $this->validity->error( 'arbitrary-warning' );
267 $this->assertEquals(
269 $provider->beginPrimaryAuthentication( $reqs )
270 );
271 $this->assertNotNull( $this->manager->getAuthenticationSessionData( 'reset-pass' ) );
272
273 // Wrong password
274 $this->validity = \Status::newGood();
275 $req->password = 'Wrong';
276 $ret = $provider->beginPrimaryAuthentication( $reqs );
277 $this->assertEquals(
279 $ret->status
280 );
281 $this->assertEquals(
282 'wrongpassword',
283 $ret->message->getKey()
284 );
285
286 // Correct handling of legacy encodings
287 $password = ':B:salt:' . md5( 'salt-' . md5( "\xe1\xe9\xed\xf3\xfa" ) );
288 $dbw->update( 'user', [ 'user_password' => $password ], [ 'user_name' => $userName ] );
289 $req->password = 'áéíóú';
290 $ret = $provider->beginPrimaryAuthentication( $reqs );
291 $this->assertEquals(
293 $ret->status
294 );
295 $this->assertEquals(
296 'wrongpassword',
297 $ret->message->getKey()
298 );
299
300 $this->config->set( 'LegacyEncoding', true );
301 $this->assertEquals(
303 $provider->beginPrimaryAuthentication( $reqs )
304 );
305
306 $req->password = 'áéíóú Wrong';
307 $ret = $provider->beginPrimaryAuthentication( $reqs );
308 $this->assertEquals(
310 $ret->status
311 );
312 $this->assertEquals(
313 'wrongpassword',
314 $ret->message->getKey()
315 );
316
317 // Correct handling of really old password hashes
318 $this->config->set( 'PasswordSalt', false );
319 $password = md5( 'FooBar' );
320 $dbw->update( 'user', [ 'user_password' => $password ], [ 'user_name' => $userName ] );
321 $req->password = 'FooBar';
322 $this->assertEquals(
324 $provider->beginPrimaryAuthentication( $reqs )
325 );
326
327 $this->config->set( 'PasswordSalt', true );
328 $password = md5( "$id-" . md5( 'FooBar' ) );
329 $dbw->update( 'user', [ 'user_password' => $password ], [ 'user_name' => $userName ] );
330 $req->password = 'FooBar';
331 $this->assertEquals(
333 $provider->beginPrimaryAuthentication( $reqs )
334 );
335
336 }
337
347 \StatusValue $expect1, \StatusValue $expect2
348 ) {
349 if ( $type === PasswordAuthenticationRequest::class ) {
350 $req = new $type();
351 } elseif ( $type === PasswordDomainAuthenticationRequest::class ) {
352 $req = new $type( [] );
353 } else {
354 $req = $this->getMock( $type );
355 }
357 $req->username = $user;
358 $req->password = 'NewPassword';
359 $req->retype = 'NewPassword';
360
361 $provider = $this->getProvider();
362 $this->validity = $validity;
363 $this->assertEquals( $expect1, $provider->providerAllowsAuthenticationDataChange( $req, false ) );
364 $this->assertEquals( $expect2, $provider->providerAllowsAuthenticationDataChange( $req, true ) );
365
366 $req->retype = 'BadRetype';
367 $this->assertEquals(
368 $expect1,
369 $provider->providerAllowsAuthenticationDataChange( $req, false )
370 );
371 $this->assertEquals(
372 $expect2->getValue() === 'ignored' ? $expect2 : \StatusValue::newFatal( 'badretype' ),
373 $provider->providerAllowsAuthenticationDataChange( $req, true )
374 );
375
376 $provider = $this->getProvider( true );
377 $this->assertEquals(
378 \StatusValue::newGood( 'ignored' ),
379 $provider->providerAllowsAuthenticationDataChange( $req, true ),
380 'loginOnly mode should claim to ignore all changes'
381 );
382 }
383
385 $err = \StatusValue::newGood();
386 $err->error( 'arbitrary-warning' );
387
388 return [
389 [ AuthenticationRequest::class, 'UTSysop', \Status::newGood(),
390 \StatusValue::newGood( 'ignored' ), \StatusValue::newGood( 'ignored' ) ],
391 [ PasswordAuthenticationRequest::class, 'UTSysop', \Status::newGood(),
392 \StatusValue::newGood(), \StatusValue::newGood() ],
393 [ PasswordAuthenticationRequest::class, 'uTSysop', \Status::newGood(),
394 \StatusValue::newGood(), \StatusValue::newGood() ],
395 [ PasswordAuthenticationRequest::class, 'UTSysop', \Status::wrap( $err ),
396 \StatusValue::newGood(), $err ],
397 [ PasswordAuthenticationRequest::class, 'UTSysop', \Status::newFatal( 'arbitrary-error' ),
398 \StatusValue::newGood(), \StatusValue::newFatal( 'arbitrary-error' ) ],
399 [ PasswordAuthenticationRequest::class, 'DoesNotExist', \Status::newGood(),
400 \StatusValue::newGood(), \StatusValue::newGood( 'ignored' ) ],
401 [ PasswordDomainAuthenticationRequest::class, 'UTSysop', \Status::newGood(),
402 \StatusValue::newGood( 'ignored' ), \StatusValue::newGood( 'ignored' ) ],
403 ];
404 }
405
414 $usernameTransform, $type, $loginOnly, $changed ) {
415 $testUser = $this->getMutableTestUser();
416 $user = $testUser->getUser()->getName();
417 if ( is_callable( $usernameTransform ) ) {
418 $user = call_user_func( $usernameTransform, $user );
419 }
420 $cuser = ucfirst( $user );
421 $oldpass = $testUser->getPassword();
422 $newpass = 'NewPassword';
423
424 $dbw = wfGetDB( DB_MASTER );
425 $oldExpiry = $dbw->selectField( 'user', 'user_password_expires', [ 'user_name' => $cuser ] );
426
427 $this->mergeMwGlobalArrayValue( 'wgHooks', [
428 'ResetPasswordExpiration' => [ function ( $user, &$expires ) {
429 $expires = '30001231235959';
430 } ]
431 ] );
432
433 $provider = $this->getProvider( $loginOnly );
434
435 // Sanity check
436 $loginReq = new PasswordAuthenticationRequest();
437 $loginReq->action = AuthManager::ACTION_LOGIN;
438 $loginReq->username = $user;
439 $loginReq->password = $oldpass;
440 $loginReqs = [ PasswordAuthenticationRequest::class => $loginReq ];
441 $this->assertEquals(
443 $provider->beginPrimaryAuthentication( $loginReqs ),
444 'Sanity check'
445 );
446
447 if ( $type === PasswordAuthenticationRequest::class ) {
448 $changeReq = new $type();
449 } else {
450 $changeReq = $this->getMock( $type );
451 }
452 $changeReq->action = AuthManager::ACTION_CHANGE;
453 $changeReq->username = $user;
454 $changeReq->password = $newpass;
455 $provider->providerChangeAuthenticationData( $changeReq );
456
457 if ( $loginOnly ) {
458 $old = 'fail';
459 $new = 'fail';
460 $expectExpiry = null;
461 } elseif ( $changed ) {
462 $old = 'fail';
463 $new = 'pass';
464 $expectExpiry = '30001231235959';
465 } else {
466 $old = 'pass';
467 $new = 'fail';
468 $expectExpiry = $oldExpiry;
469 }
470
471 $loginReq->password = $oldpass;
472 $ret = $provider->beginPrimaryAuthentication( $loginReqs );
473 if ( $old === 'pass' ) {
474 $this->assertEquals(
476 $ret,
477 'old password should pass'
478 );
479 } else {
480 $this->assertEquals(
482 $ret->status,
483 'old password should fail'
484 );
485 $this->assertEquals(
486 'wrongpassword',
487 $ret->message->getKey(),
488 'old password should fail'
489 );
490 }
491
492 $loginReq->password = $newpass;
493 $ret = $provider->beginPrimaryAuthentication( $loginReqs );
494 if ( $new === 'pass' ) {
495 $this->assertEquals(
497 $ret,
498 'new password should pass'
499 );
500 } else {
501 $this->assertEquals(
503 $ret->status,
504 'new password should fail'
505 );
506 $this->assertEquals(
507 'wrongpassword',
508 $ret->message->getKey(),
509 'new password should fail'
510 );
511 }
512
513 $this->assertSame(
514 $expectExpiry,
515 $dbw->selectField( 'user', 'user_password_expires', [ 'user_name' => $cuser ] )
516 );
517 }
518
520 return [
521 [ false, AuthenticationRequest::class, false, false ],
522 [ false, PasswordAuthenticationRequest::class, false, true ],
523 [ false, AuthenticationRequest::class, true, false ],
524 [ false, PasswordAuthenticationRequest::class, true, true ],
525 [ 'ucfirst', PasswordAuthenticationRequest::class, false, true ],
526 [ 'ucfirst', PasswordAuthenticationRequest::class, true, true ],
527 ];
528 }
529
530 public function testTestForAccountCreation() {
531 $user = \User::newFromName( 'foo' );
534 $req->username = 'Foo';
535 $req->password = 'Bar';
536 $req->retype = 'Bar';
537 $reqs = [ PasswordAuthenticationRequest::class => $req ];
538
539 $provider = $this->getProvider();
540 $this->assertEquals(
541 \StatusValue::newGood(),
542 $provider->testForAccountCreation( $user, $user, [] ),
543 'No password request'
544 );
545
546 $this->assertEquals(
547 \StatusValue::newGood(),
548 $provider->testForAccountCreation( $user, $user, $reqs ),
549 'Password request, validated'
550 );
551
552 $req->retype = 'Baz';
553 $this->assertEquals(
554 \StatusValue::newFatal( 'badretype' ),
555 $provider->testForAccountCreation( $user, $user, $reqs ),
556 'Password request, bad retype'
557 );
558 $req->retype = 'Bar';
559
560 $this->validity->error( 'arbitrary warning' );
561 $expect = \StatusValue::newGood();
562 $expect->error( 'arbitrary warning' );
563 $this->assertEquals(
564 $expect,
565 $provider->testForAccountCreation( $user, $user, $reqs ),
566 'Password request, not validated'
567 );
568
569 $provider = $this->getProvider( true );
570 $this->validity->error( 'arbitrary warning' );
571 $this->assertEquals(
572 \StatusValue::newGood(),
573 $provider->testForAccountCreation( $user, $user, $reqs ),
574 'Password request, not validated, loginOnly'
575 );
576 }
577
578 public function testAccountCreation() {
579 $user = \User::newFromName( 'Foo' );
580
583 $reqs = [ PasswordAuthenticationRequest::class => $req ];
584
585 $provider = $this->getProvider( true );
586 try {
587 $provider->beginPrimaryAccountCreation( $user, $user, [] );
588 $this->fail( 'Expected exception was not thrown' );
589 } catch ( \BadMethodCallException $ex ) {
590 $this->assertSame(
591 'Shouldn\'t call this when accountCreationType() is NONE', $ex->getMessage()
592 );
593 }
594
595 try {
596 $provider->finishAccountCreation( $user, $user, AuthenticationResponse::newPass() );
597 $this->fail( 'Expected exception was not thrown' );
598 } catch ( \BadMethodCallException $ex ) {
599 $this->assertSame(
600 'Shouldn\'t call this when accountCreationType() is NONE', $ex->getMessage()
601 );
602 }
603
604 $provider = $this->getProvider( false );
605
606 $this->assertEquals(
608 $provider->beginPrimaryAccountCreation( $user, $user, [] )
609 );
610
611 $req->username = 'foo';
612 $req->password = null;
613 $this->assertEquals(
615 $provider->beginPrimaryAccountCreation( $user, $user, $reqs )
616 );
617
618 $req->username = null;
619 $req->password = 'bar';
620 $this->assertEquals(
622 $provider->beginPrimaryAccountCreation( $user, $user, $reqs )
623 );
624
625 $req->username = 'foo';
626 $req->password = 'bar';
627
628 $expect = AuthenticationResponse::newPass( 'Foo' );
629 $expect->createRequest = clone( $req );
630 $expect->createRequest->username = 'Foo';
631 $this->assertEquals( $expect, $provider->beginPrimaryAccountCreation( $user, $user, $reqs ) );
632
633 // We have to cheat a bit to avoid having to add a new user to
634 // the database to test the actual setting of the password works right
635 $dbw = wfGetDB( DB_MASTER );
636
637 $user = \User::newFromName( 'UTSysop' );
638 $req->username = $user->getName();
639 $req->password = 'NewPassword';
640 $expect = AuthenticationResponse::newPass( 'UTSysop' );
641 $expect->createRequest = $req;
642
643 $res2 = $provider->beginPrimaryAccountCreation( $user, $user, $reqs );
644 $this->assertEquals( $expect, $res2, 'Sanity check' );
645
646 $ret = $provider->beginPrimaryAuthentication( $reqs );
647 $this->assertEquals( AuthenticationResponse::FAIL, $ret->status, 'sanity check' );
648
649 $this->assertNull( $provider->finishAccountCreation( $user, $user, $res2 ) );
650 $ret = $provider->beginPrimaryAuthentication( $reqs );
651 $this->assertEquals( AuthenticationResponse::PASS, $ret->status, 'new password is set' );
652
653 }
654
655}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static getDefaultInstance()
WebRequest clone which takes values from a provided array.
static getMutableTestUser( $groups=[])
Convenience method for getting a mutable test user.
mergeMwGlobalArrayValue( $name, $values)
Merges the given values into a MW global array variable.
setMwGlobals( $pairs, $value=null)
This serves as the entry point to the authentication system.
const ACTION_CHANGE
Change a user's credentials.
const ACTION_LOGIN
Log in with an existing (not necessarily local) user.
const ACTION_CREATE
Create a new user.
const FAIL
Indicates that the authentication failed.
const PASS
Indicates that the authentication succeeded.
AuthManager Database MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider.
testProviderAllowsAuthenticationDataChange( $type, $user, \Status $validity, \StatusValue $expect1, \StatusValue $expect2)
provideProviderAllowsAuthenticationDataChange
testProviderChangeAuthenticationData( $usernameTransform, $type, $loginOnly, $changed)
provideProviderChangeAuthenticationData
A primary authentication provider that uses the password field in the 'user' table.
This is a value object for authentication requests with a username and password.
static newInvalidPassword()
Create an InvalidPassword.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:40
this hook is for auditing only $req
Definition hooks.txt:1010
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition hooks.txt:1049
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:249
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition hooks.txt:2568
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:1950
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:1949
processing should stop and the error should be shown to the user * false
Definition hooks.txt:189
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
const TYPE_NONE
Provider cannot create or link to accounts.
const DB_MASTER
Definition defines.php:23
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
Definition defines.php:11