28use Psr\Log\LoggerAwareInterface;
29use Psr\Log\LoggerInterface;
34use Wikimedia\ObjectFactory;
152 if ( self::$instance ===
null ) {
153 self::$instance =
new self(
154 \RequestContext::getMain()->getRequest(),
192 $this->logger->warning(
"Overriding AuthManager primary authn because $why" );
194 if ( $this->primaryAuthenticationProviders !==
null ) {
195 $this->logger->warning(
196 'PrimaryAuthenticationProviders have already been accessed! I hope nothing breaks.'
199 $this->allAuthenticationProviders = array_diff_key(
200 $this->allAuthenticationProviders,
201 $this->primaryAuthenticationProviders
203 $session = $this->
request->getSession();
204 $session->remove(
'AuthManager::authnState' );
205 $session->remove(
'AuthManager::accountCreationState' );
206 $session->remove(
'AuthManager::accountLinkState' );
207 $this->createdAccountAuthenticationRequests = [];
210 $this->primaryAuthenticationProviders = [];
211 foreach ( $providers
as $provider ) {
213 throw new \RuntimeException(
214 'Expected instance of MediaWiki\\Auth\\PrimaryAuthenticationProvider, got ' .
215 get_class( $provider )
218 $provider->setLogger( $this->logger );
219 $provider->setManager( $this );
220 $provider->setConfig( $this->config );
221 $id = $provider->getUniqueId();
222 if ( isset( $this->allAuthenticationProviders[$id] ) ) {
223 throw new \RuntimeException(
224 "Duplicate specifications for id $id (classes " .
225 get_class( $provider ) .
' and ' .
226 get_class( $this->allAuthenticationProviders[$id] ) .
')'
229 $this->allAuthenticationProviders[$id] = $provider;
230 $this->primaryAuthenticationProviders[$id] = $provider;
264 return $this->
request->getSession()->canSetUser();
286 $session = $this->
request->getSession();
287 if ( !$session->canSetUser() ) {
289 $session->remove(
'AuthManager::authnState' );
290 throw new \LogicException(
'Authentication is not possible now' );
293 $guessUserName =
null;
294 foreach ( $reqs
as $req ) {
295 $req->returnToUrl = $returnToUrl;
297 if (
$req->username !==
null &&
$req->username !==
'' ) {
298 if ( $guessUserName ===
null ) {
299 $guessUserName =
$req->username;
300 } elseif ( $guessUserName !==
$req->username ) {
301 $guessUserName =
null;
310 $reqs, CreatedAccountAuthenticationRequest::class
313 if ( !in_array(
$req, $this->createdAccountAuthenticationRequests,
true ) ) {
314 throw new \LogicException(
315 'CreatedAccountAuthenticationRequests are only valid on ' .
316 'the same AuthManager that created the account'
323 throw new \UnexpectedValueException(
324 "CreatedAccountAuthenticationRequest had invalid username \"{$req->username}\""
326 } elseif (
$user->getId() !=
$req->id ) {
327 throw new \UnexpectedValueException(
328 "ID for \"{$req->username}\" was {$user->getId()}, expected {$req->id}"
333 $this->logger->info(
'Logging in {user} after account creation', [
334 'user' =>
$user->getName(),
339 $session->remove(
'AuthManager::authnState' );
340 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$ret,
$user,
$user->getName(), [] ] );
347 $status = $provider->testForAuthentication( $reqs );
349 $this->logger->debug(
'Login failed in pre-authentication by ' . $provider->getUniqueId() );
351 Status::wrap(
$status )->getMessage()
356 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$ret,
null, $guessUserName, [] ] );
363 'returnToUrl' => $returnToUrl,
364 'guessUserName' => $guessUserName,
366 'primaryResponse' =>
null,
369 'continueRequests' => [],
374 $reqs, CreateFromLoginAuthenticationRequest::class
377 $state[
'maybeLink'] =
$req->maybeLink;
380 $session = $this->
request->getSession();
381 $session->setSecret(
'AuthManager::authnState', $state );
410 $session = $this->
request->getSession();
412 if ( !$session->canSetUser() ) {
415 throw new \LogicException(
'Authentication is not possible now' );
419 $state = $session->getSecret(
'AuthManager::authnState' );
420 if ( !is_array( $state ) ) {
422 wfMessage(
'authmanager-authn-not-in-progress' )
425 $state[
'continueRequests'] = [];
427 $guessUserName = $state[
'guessUserName'];
429 foreach ( $reqs
as $req ) {
430 $req->returnToUrl = $state[
'returnToUrl'];
435 if ( $state[
'primary'] ===
null ) {
438 $guessUserName =
null;
439 foreach ( $reqs
as $req ) {
440 if (
$req->username !==
null &&
$req->username !==
'' ) {
441 if ( $guessUserName ===
null ) {
442 $guessUserName =
$req->username;
443 } elseif ( $guessUserName !==
$req->username ) {
444 $guessUserName =
null;
449 $state[
'guessUserName'] = $guessUserName;
451 $state[
'reqs'] = $reqs;
454 $res = $provider->beginPrimaryAuthentication( $reqs );
455 switch (
$res->status ) {
457 $state[
'primary'] = $id;
458 $state[
'primaryResponse'] =
$res;
459 $this->logger->debug(
"Primary login with $id succeeded" );
462 $this->logger->debug(
"Login failed in primary authentication by $id" );
463 if (
$res->createRequest || $state[
'maybeLink'] ) {
465 $res->createRequest, $state[
'maybeLink']
471 $session->remove(
'AuthManager::authnState' );
472 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$res,
null, $guessUserName, [] ] );
479 $this->logger->debug(
"Primary login with $id returned $res->status" );
480 $this->
fillRequests(
$res->neededRequests, self::ACTION_LOGIN, $guessUserName );
481 $state[
'primary'] = $id;
482 $state[
'continueRequests'] =
$res->neededRequests;
483 $session->setSecret(
'AuthManager::authnState', $state );
488 throw new \DomainException(
489 get_class( $provider ) .
"::beginPrimaryAuthentication() returned $res->status"
494 if ( $state[
'primary'] ===
null ) {
495 $this->logger->debug(
'Login failed in primary authentication because no provider accepted' );
497 wfMessage(
'authmanager-authn-no-primary' )
502 $session->remove(
'AuthManager::authnState' );
505 } elseif ( $state[
'primaryResponse'] ===
null ) {
511 wfMessage(
'authmanager-authn-not-in-progress' )
516 $session->remove(
'AuthManager::authnState' );
520 $id = $provider->getUniqueId();
521 $res = $provider->continuePrimaryAuthentication( $reqs );
522 switch (
$res->status ) {
524 $state[
'primaryResponse'] =
$res;
525 $this->logger->debug(
"Primary login with $id succeeded" );
528 $this->logger->debug(
"Login failed in primary authentication by $id" );
529 if (
$res->createRequest || $state[
'maybeLink'] ) {
531 $res->createRequest, $state[
'maybeLink']
537 $session->remove(
'AuthManager::authnState' );
538 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$res,
null, $guessUserName, [] ] );
542 $this->logger->debug(
"Primary login with $id returned $res->status" );
543 $this->
fillRequests(
$res->neededRequests, self::ACTION_LOGIN, $guessUserName );
544 $state[
'continueRequests'] =
$res->neededRequests;
545 $session->setSecret(
'AuthManager::authnState', $state );
548 throw new \DomainException(
549 get_class( $provider ) .
"::continuePrimaryAuthentication() returned $res->status"
554 $res = $state[
'primaryResponse'];
555 if (
$res->username ===
null ) {
561 wfMessage(
'authmanager-authn-not-in-progress' )
566 $session->remove(
'AuthManager::authnState' );
576 $state[
'maybeLink'][
$res->linkRequest->getUniqueId()] =
$res->linkRequest;
577 $msg =
'authmanager-authn-no-local-user-link';
579 $msg =
'authmanager-authn-no-local-user';
581 $this->logger->debug(
582 "Primary login with {$provider->getUniqueId()} succeeded, but returned no user"
590 if (
$res->createRequest || $state[
'maybeLink'] ) {
592 $res->createRequest, $state[
'maybeLink']
594 $ret->neededRequests[] =
$ret->createRequest;
596 $this->
fillRequests(
$ret->neededRequests, self::ACTION_LOGIN,
null,
true );
597 $session->setSecret(
'AuthManager::authnState', [
600 'primaryResponse' =>
null,
602 'continueRequests' =>
$ret->neededRequests,
613 throw new \DomainException(
614 get_class( $provider ) .
" returned an invalid username: {$res->username}"
617 if (
$user->getId() === 0 ) {
619 $this->logger->info(
'Auto-creating {user} on login', [
620 'user' =>
$user->getName(),
625 Status::wrap(
$status )->getMessage(
'authmanager-authn-autocreate-failed' )
628 $session->remove(
'AuthManager::authnState' );
629 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$ret,
$user,
$user->getName(), [] ] );
636 $beginReqs = $state[
'reqs'];
639 if ( !isset( $state[
'secondary'][$id] ) ) {
643 $func =
'beginSecondaryAuthentication';
644 $res = $provider->beginSecondaryAuthentication(
$user, $beginReqs );
645 } elseif ( !$state[
'secondary'][$id] ) {
646 $func =
'continueSecondaryAuthentication';
647 $res = $provider->continueSecondaryAuthentication(
$user, $reqs );
651 switch (
$res->status ) {
653 $this->logger->debug(
"Secondary login with $id succeeded" );
656 $state[
'secondary'][$id] =
true;
659 $this->logger->debug(
"Login failed in secondary authentication by $id" );
661 $session->remove(
'AuthManager::authnState' );
662 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$res,
$user,
$user->getName(), [] ] );
666 $this->logger->debug(
"Secondary login with $id returned " .
$res->status );
668 $state[
'secondary'][$id] =
false;
669 $state[
'continueRequests'] =
$res->neededRequests;
670 $session->setSecret(
'AuthManager::authnState', $state );
675 throw new \DomainException(
676 get_class( $provider ) .
"::{$func}() returned $res->status"
685 $this->logger->info(
'Login for {user} succeeded from {clientip}', [
686 'user' =>
$user->getName(),
687 'clientip' => $this->request->getIP(),
691 $beginReqs, RememberMeAuthenticationRequest::class
696 $session->remove(
'AuthManager::authnState' );
698 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$ret,
$user,
$user->getName(), [] ] );
700 }
catch ( \Exception $ex ) {
701 $session->remove(
'AuthManager::authnState' );
720 $this->logger->debug( __METHOD__ .
": Checking $operation" );
722 $session = $this->
request->getSession();
723 $aId = $session->getUser()->getId();
727 $this->logger->info( __METHOD__ .
": Not logged in! $operation is $status" );
731 if ( $session->canSetUser() ) {
732 $id = $session->get(
'AuthManager:lastAuthId' );
733 $last = $session->get(
'AuthManager:lastAuthTimestamp' );
734 if ( $id !== $aId ||
$last ===
null ) {
735 $timeSinceLogin = PHP_INT_MAX;
737 $timeSinceLogin = max( 0, time() -
$last );
740 $thresholds = $this->config->get(
'ReauthenticateTime' );
741 if ( isset( $thresholds[$operation] ) ) {
742 $threshold = $thresholds[$operation];
743 } elseif ( isset( $thresholds[
'default'] ) ) {
744 $threshold = $thresholds[
'default'];
746 throw new \UnexpectedValueException(
'$wgReauthenticateTime lacks a default' );
749 if ( $threshold >= 0 && $timeSinceLogin > $threshold ) {
753 $timeSinceLogin = -1;
755 $pass = $this->config->get(
'AllowSecuritySensitiveOperationIfCannotReauthenticate' );
756 if ( isset( $pass[$operation] ) ) {
758 } elseif ( isset( $pass[
'default'] ) ) {
761 throw new \UnexpectedValueException(
762 '$wgAllowSecuritySensitiveOperationIfCannotReauthenticate lacks a default'
767 \Hooks::run(
'SecuritySensitiveOperationStatus', [
768 &
$status, $operation, $session, $timeSinceLogin
776 $this->logger->info( __METHOD__ .
": $operation is $status for '{user}'",
778 'user' => $session->getUser()->getName(),
779 'clientip' => $this->getRequest()->getIP(),
797 if ( $provider->testUserCanAuthenticate(
$username ) ) {
821 $normalized = $provider->providerNormalizeUsername(
$username );
822 if ( $normalized !==
null ) {
823 $ret[$normalized] =
true;
826 return array_keys(
$ret );
844 $this->logger->info(
'Revoking access for {user}', [
863 foreach ( $providers
as $provider ) {
864 $status = $provider->providerAllowsAuthenticationDataChange(
$req, $checkData );
866 return Status::wrap(
$status );
868 $any = $any ||
$status->value !==
'ignored';
871 $status = Status::newGood(
'ignored' );
872 $status->warning(
'authmanager-change-not-supported' );
875 return Status::newGood();
896 $this->logger->info(
'Changing authentication data for {user} class {what}', [
897 'user' => is_string(
$req->username ) ?
$req->username :
'<no name>',
898 'what' => get_class(
$req ),
905 if ( !$isAddition ) {
906 \BotPassword::invalidateAllPasswordsForUser(
$req->username );
923 switch ( $provider->accountCreationType() ) {
946 'flags' => User::READ_NORMAL,
952 return Status::newFatal(
'authmanager-create-disabled' );
956 return Status::newFatal(
'userexists' );
960 if ( !is_object(
$user ) ) {
961 return Status::newFatal(
'noname' );
963 $user->load( $flags );
964 if (
$user->getId() !== 0 ) {
965 return Status::newFatal(
'userexists' );
973 foreach ( $providers
as $provider ) {
976 return Status::wrap(
$status );
980 return Status::newGood();
995 $permErrors = \SpecialPage::getTitleFor(
'CreateAccount' )
996 ->getUserPermissionsErrors(
'createaccount', $creator,
'secure' );
999 foreach ( $permErrors
as $args ) {
1008 $block->getTarget(),
1009 $block->getReason() ?:
wfMessage(
'blockednoreason' )->text(),
1014 $errorMessage =
'cantcreateaccount-range-text';
1015 $errorParams[] = $this->
getRequest()->getIP();
1017 $errorMessage =
'cantcreateaccount-text';
1020 return Status::newFatal(
wfMessage( $errorMessage, $errorParams ) );
1025 return Status::newFatal(
'sorbs_create_account_reason' );
1028 return Status::newGood();
1051 $session = $this->
request->getSession();
1054 $session->remove(
'AuthManager::accountCreationState' );
1055 throw new \LogicException(
'Account creation is not possible' );
1060 }
catch ( \UnexpectedValueException $ex ) {
1064 $this->logger->debug( __METHOD__ .
': No username provided' );
1071 $this->logger->debug( __METHOD__ .
': {creator} cannot create users: {reason}', [
1073 'creator' => $creator->
getName(),
1074 'reason' =>
$status->getWikiText(
null,
null,
'en' )
1083 $this->logger->debug( __METHOD__ .
': {user} cannot be created: {reason}', [
1085 'creator' => $creator->
getName(),
1086 'reason' =>
$status->getWikiText(
null,
null,
'en' )
1092 foreach ( $reqs
as $req ) {
1094 $req->returnToUrl = $returnToUrl;
1099 $session->remove(
'AuthManager::accountCreationState' );
1100 $this->logger->debug( __METHOD__ .
': UserData is invalid: {reason}', [
1101 'user' =>
$user->getName(),
1102 'creator' => $creator->
getName(),
1103 'reason' =>
$status->getWikiText(
null,
null,
'en' ),
1115 'creatorid' => $creator->
getId(),
1116 'creatorname' => $creator->
getName(),
1118 'returnToUrl' => $returnToUrl,
1120 'primaryResponse' =>
null,
1122 'continueRequests' => [],
1124 'ranPreTests' =>
false,
1129 $reqs, CreateFromLoginAuthenticationRequest::class
1132 $state[
'maybeLink'] =
$req->maybeLink;
1134 if (
$req->createRequest ) {
1135 $reqs[] =
$req->createRequest;
1136 $state[
'reqs'][] =
$req->createRequest;
1140 $session->setSecret(
'AuthManager::accountCreationState', $state );
1141 $session->persist();
1152 $session = $this->
request->getSession();
1156 $session->remove(
'AuthManager::accountCreationState' );
1157 throw new \LogicException(
'Account creation is not possible' );
1160 $state = $session->getSecret(
'AuthManager::accountCreationState' );
1161 if ( !is_array( $state ) ) {
1163 wfMessage(
'authmanager-create-not-in-progress' )
1166 $state[
'continueRequests'] = [];
1171 if ( !is_object(
$user ) ) {
1172 $session->remove(
'AuthManager::accountCreationState' );
1173 $this->logger->debug( __METHOD__ .
': Invalid username', [
1174 'user' => $state[
'username'],
1179 if ( $state[
'creatorid'] ) {
1182 $creator =
new User;
1183 $creator->
setName( $state[
'creatorname'] );
1187 $cache = \ObjectCache::getLocalClusterInstance();
1188 $lock =
$cache->getScopedLock(
$cache->makeGlobalKey(
'account', md5(
$user->getName() ) ) );
1192 $this->logger->debug( __METHOD__ .
': Could not acquire account creation lock', [
1193 'user' =>
$user->getName(),
1194 'creator' => $creator->getName(),
1202 $this->logger->debug( __METHOD__ .
': {creator} cannot create users: {reason}', [
1203 'user' =>
$user->getName(),
1204 'creator' => $creator->getName(),
1205 'reason' =>
$status->getWikiText(
null,
null,
'en' )
1209 $session->remove(
'AuthManager::accountCreationState' );
1216 if ( $state[
'userid'] === 0 ) {
1217 if (
$user->getId() !== 0 ) {
1218 $this->logger->debug( __METHOD__ .
': User exists locally', [
1219 'user' =>
$user->getName(),
1220 'creator' => $creator->getName(),
1224 $session->remove(
'AuthManager::accountCreationState' );
1228 if (
$user->getId() === 0 ) {
1229 $this->logger->debug( __METHOD__ .
': User does not exist locally when it should', [
1230 'user' =>
$user->getName(),
1231 'creator' => $creator->getName(),
1232 'expected_id' => $state[
'userid'],
1234 throw new \UnexpectedValueException(
1235 "User \"{$state['username']}\" should exist now, but doesn't!"
1238 if (
$user->getId() !== $state[
'userid'] ) {
1239 $this->logger->debug( __METHOD__ .
': User ID/name mismatch', [
1240 'user' =>
$user->getName(),
1241 'creator' => $creator->getName(),
1242 'expected_id' => $state[
'userid'],
1243 'actual_id' =>
$user->getId(),
1245 throw new \UnexpectedValueException(
1246 "User \"{$state['username']}\" exists, but " .
1247 "ID {$user->getId()} !== {$state['userid']}!"
1251 foreach ( $state[
'reqs']
as $req ) {
1257 $this->logger->debug( __METHOD__ .
': UserData is invalid: {reason}', [
1258 'user' =>
$user->getName(),
1259 'creator' => $creator->getName(),
1260 'reason' =>
$status->getWikiText(
null,
null,
'en' ),
1264 $session->remove(
'AuthManager::accountCreationState' );
1270 foreach ( $reqs
as $req ) {
1271 $req->returnToUrl = $state[
'returnToUrl'];
1272 $req->username = $state[
'username'];
1276 if ( !$state[
'ranPreTests'] ) {
1280 foreach ( $providers
as $id => $provider ) {
1281 $status = $provider->testForAccountCreation(
$user, $creator, $reqs );
1283 $this->logger->debug( __METHOD__ .
": Fail in pre-authentication by $id", [
1284 'user' =>
$user->getName(),
1285 'creator' => $creator->getName(),
1288 Status::wrap(
$status )->getMessage()
1291 $session->remove(
'AuthManager::accountCreationState' );
1296 $state[
'ranPreTests'] =
true;
1301 if ( $state[
'primary'] ===
null ) {
1307 $res = $provider->beginPrimaryAccountCreation(
$user, $creator, $reqs );
1308 switch (
$res->status ) {
1310 $this->logger->debug( __METHOD__ .
": Primary creation passed by $id", [
1311 'user' =>
$user->getName(),
1312 'creator' => $creator->getName(),
1314 $state[
'primary'] = $id;
1315 $state[
'primaryResponse'] =
$res;
1318 $this->logger->debug( __METHOD__ .
": Primary creation failed by $id", [
1319 'user' =>
$user->getName(),
1320 'creator' => $creator->getName(),
1323 $session->remove(
'AuthManager::accountCreationState' );
1330 $this->logger->debug( __METHOD__ .
": Primary creation $res->status by $id", [
1331 'user' =>
$user->getName(),
1332 'creator' => $creator->getName(),
1335 $state[
'primary'] = $id;
1336 $state[
'continueRequests'] =
$res->neededRequests;
1337 $session->setSecret(
'AuthManager::accountCreationState', $state );
1342 throw new \DomainException(
1343 get_class( $provider ) .
"::beginPrimaryAccountCreation() returned $res->status"
1348 if ( $state[
'primary'] ===
null ) {
1349 $this->logger->debug( __METHOD__ .
': Primary creation failed because no provider accepted', [
1350 'user' =>
$user->getName(),
1351 'creator' => $creator->getName(),
1354 wfMessage(
'authmanager-create-no-primary' )
1357 $session->remove(
'AuthManager::accountCreationState' );
1360 } elseif ( $state[
'primaryResponse'] ===
null ) {
1366 wfMessage(
'authmanager-create-not-in-progress' )
1369 $session->remove(
'AuthManager::accountCreationState' );
1373 $id = $provider->getUniqueId();
1374 $res = $provider->continuePrimaryAccountCreation(
$user, $creator, $reqs );
1375 switch (
$res->status ) {
1377 $this->logger->debug( __METHOD__ .
": Primary creation passed by $id", [
1378 'user' =>
$user->getName(),
1379 'creator' => $creator->getName(),
1381 $state[
'primaryResponse'] =
$res;
1384 $this->logger->debug( __METHOD__ .
": Primary creation failed by $id", [
1385 'user' =>
$user->getName(),
1386 'creator' => $creator->getName(),
1389 $session->remove(
'AuthManager::accountCreationState' );
1393 $this->logger->debug( __METHOD__ .
": Primary creation $res->status by $id", [
1394 'user' =>
$user->getName(),
1395 'creator' => $creator->getName(),
1398 $state[
'continueRequests'] =
$res->neededRequests;
1399 $session->setSecret(
'AuthManager::accountCreationState', $state );
1402 throw new \DomainException(
1403 get_class( $provider ) .
"::continuePrimaryAccountCreation() returned $res->status"
1411 if ( $state[
'userid'] === 0 ) {
1412 $this->logger->info(
'Creating user {user} during account creation', [
1413 'user' =>
$user->getName(),
1414 'creator' => $creator->getName(),
1421 $session->remove(
'AuthManager::accountCreationState' );
1426 \Hooks::runWithoutAbort(
'LocalUserCreated', [
$user,
false ] );
1427 $user->saveSettings();
1428 $state[
'userid'] =
$user->getId();
1431 \DeferredUpdates::addUpdate( \SiteStatsUpdate::factory( [
'users' => 1 ] ) );
1437 $logSubtype = $provider->finishAccountCreation(
$user, $creator, $state[
'primaryResponse'] );
1440 if ( $this->config->get(
'NewUserLog' ) ) {
1441 $isAnon = $creator->isAnon();
1442 $logEntry = new \ManualLogEntry(
1444 $logSubtype ?: ( $isAnon ?
'create' :
'create2' )
1446 $logEntry->setPerformer( $isAnon ?
$user : $creator );
1447 $logEntry->setTarget(
$user->getUserPage() );
1450 $state[
'reqs'], CreationReasonAuthenticationRequest::class
1452 $logEntry->setComment(
$req ?
$req->reason :
'' );
1453 $logEntry->setParameters( [
1454 '4::userid' =>
$user->getId(),
1456 $logid = $logEntry->insert();
1457 $logEntry->publish( $logid );
1463 $beginReqs = $state[
'reqs'];
1466 if ( !isset( $state[
'secondary'][$id] ) ) {
1470 $func =
'beginSecondaryAccountCreation';
1471 $res = $provider->beginSecondaryAccountCreation(
$user, $creator, $beginReqs );
1472 } elseif ( !$state[
'secondary'][$id] ) {
1473 $func =
'continueSecondaryAccountCreation';
1474 $res = $provider->continueSecondaryAccountCreation(
$user, $creator, $reqs );
1478 switch (
$res->status ) {
1480 $this->logger->debug( __METHOD__ .
": Secondary creation passed by $id", [
1481 'user' =>
$user->getName(),
1482 'creator' => $creator->getName(),
1486 $state[
'secondary'][$id] =
true;
1490 $this->logger->debug( __METHOD__ .
": Secondary creation $res->status by $id", [
1491 'user' =>
$user->getName(),
1492 'creator' => $creator->getName(),
1495 $state[
'secondary'][$id] =
false;
1496 $state[
'continueRequests'] =
$res->neededRequests;
1497 $session->setSecret(
'AuthManager::accountCreationState', $state );
1500 throw new \DomainException(
1501 get_class( $provider ) .
"::{$func}() returned $res->status." .
1502 ' Secondary providers are not allowed to fail account creation, that' .
1503 ' should have been done via testForAccountCreation().'
1507 throw new \DomainException(
1508 get_class( $provider ) .
"::{$func}() returned $res->status"
1514 $id =
$user->getId();
1519 $this->createdAccountAuthenticationRequests[] =
$req;
1521 $this->logger->info( __METHOD__ .
': Account creation succeeded for {user}', [
1522 'user' =>
$user->getName(),
1523 'creator' => $creator->getName(),
1527 $session->remove(
'AuthManager::accountCreationState' );
1530 }
catch ( \Exception $ex ) {
1531 $session->remove(
'AuthManager::accountCreationState' );
1554 if (
$source !== self::AUTOCREATE_SOURCE_SESSION &&
1555 $source !== self::AUTOCREATE_SOURCE_MAINT &&
1558 throw new \InvalidArgumentException(
"Unknown auto-creation source: $source" );
1565 $flags = User::READ_NORMAL;
1575 $flags = User::READ_LATEST;
1580 $this->logger->debug( __METHOD__ .
': {username} already exists locally', [
1583 $user->setId( $localId );
1584 $user->loadFromId( $flags );
1589 $status->warning(
'userexists' );
1595 $this->logger->debug( __METHOD__ .
': denied by wfReadOnly(): {reason}', [
1600 $user->loadFromId();
1606 $session = $this->
request->getSession();
1607 if ( $session->get(
'AuthManager::AutoCreateBlacklist' ) ) {
1608 $this->logger->debug( __METHOD__ .
': blacklisted in session {sessionid}', [
1610 'sessionid' => $session->getId(),
1613 $user->loadFromId();
1614 $reason = $session->get(
'AuthManager::AutoCreateBlacklist' );
1616 return Status::wrap( $reason );
1618 return Status::newFatal( $reason );
1624 $this->logger->debug( __METHOD__ .
': name "{username}" is not creatable', [
1627 $session->set(
'AuthManager::AutoCreateBlacklist',
'noname' );
1629 $user->loadFromId();
1630 return Status::newFatal(
'noname' );
1635 if (
$source !== self::AUTOCREATE_SOURCE_MAINT &&
1636 !$anon->isAllowedAny(
'createaccount',
'autocreateaccount' )
1638 $this->logger->debug( __METHOD__ .
': IP lacks the ability to create or autocreate accounts', [
1640 'ip' => $anon->getName(),
1642 $session->set(
'AuthManager::AutoCreateBlacklist',
'authmanager-autocreate-noperm' );
1643 $session->persist();
1645 $user->loadFromId();
1646 return Status::newFatal(
'authmanager-autocreate-noperm' );
1650 $cache = \ObjectCache::getLocalClusterInstance();
1653 $this->logger->debug( __METHOD__ .
': Could not acquire account creation lock', [
1657 $user->loadFromId();
1658 return Status::newFatal(
'usernameinprogress' );
1663 'flags' => User::READ_LATEST,
1669 foreach ( $providers
as $provider ) {
1673 $this->logger->debug( __METHOD__ .
': Provider denied creation of {username}: {reason}', [
1675 'reason' =>
$ret->getWikiText(
null,
null,
'en' ),
1677 $session->set(
'AuthManager::AutoCreateBlacklist',
$status );
1679 $user->loadFromId();
1684 $backoffKey =
$cache->makeKey(
'AuthManager',
'autocreate-failed', md5(
$username ) );
1685 if (
$cache->get( $backoffKey ) ) {
1686 $this->logger->debug( __METHOD__ .
': {username} denied by prior creation attempt failures', [
1690 $user->loadFromId();
1691 return Status::newFatal(
'authmanager-autocreate-exception' );
1695 $from = $_SERVER[
'REQUEST_URI'] ??
'CLI';
1696 $this->logger->info( __METHOD__ .
': creating new user ({username}) - from: {from}', [
1702 $trxProfiler = \Profiler::instance()->getTransactionProfiler();
1703 $old = $trxProfiler->setSilenced(
true );
1709 if (
$user->getId() ) {
1710 $this->logger->info( __METHOD__ .
': {username} already exists locally (race)', [
1717 $status->warning(
'userexists' );
1719 $this->logger->error( __METHOD__ .
': {username} failed with message {msg}', [
1721 'msg' =>
$status->getWikiText(
null,
null,
'en' )
1724 $user->loadFromId();
1728 }
catch ( \Exception $ex ) {
1729 $trxProfiler->setSilenced( $old );
1730 $this->logger->error( __METHOD__ .
': {username} failed with exception {exception}', [
1735 $cache->set( $backoffKey, 1, 600 );
1745 \Hooks::run(
'LocalUserCreated', [
$user,
true ] );
1746 $user->saveSettings();
1749 \DeferredUpdates::addUpdate( \SiteStatsUpdate::factory( [
'users' => 1 ] ) );
1751 \DeferredUpdates::addCallableUpdate(
function ()
use (
$user ) {
1756 if ( $this->config->get(
'NewUserLog' ) ) {
1757 $logEntry = new \ManualLogEntry(
'newusers',
'autocreate' );
1758 $logEntry->setPerformer(
$user );
1759 $logEntry->setTarget(
$user->getUserPage() );
1760 $logEntry->setComment(
'' );
1761 $logEntry->setParameters( [
1762 '4::userid' =>
$user->getId(),
1764 $logEntry->insert();
1767 $trxProfiler->setSilenced( $old );
1773 return Status::newGood();
1806 $session = $this->
request->getSession();
1807 $session->remove(
'AuthManager::accountLinkState' );
1811 throw new \LogicException(
'Account linking is not possible' );
1814 if (
$user->getId() === 0 ) {
1818 $msg =
wfMessage(
'authmanager-userdoesnotexist',
$user->getName() );
1822 foreach ( $reqs
as $req ) {
1824 $req->returnToUrl = $returnToUrl;
1830 foreach ( $providers
as $id => $provider ) {
1833 $this->logger->debug( __METHOD__ .
": Account linking pre-check failed by $id", [
1834 'user' =>
$user->getName(),
1837 Status::wrap(
$status )->getMessage()
1845 'username' =>
$user->getName(),
1846 'userid' =>
$user->getId(),
1847 'returnToUrl' => $returnToUrl,
1849 'continueRequests' => [],
1853 foreach ( $providers
as $id => $provider ) {
1858 $res = $provider->beginPrimaryAccountLink(
$user, $reqs );
1859 switch (
$res->status ) {
1861 $this->logger->info(
"Account linked to {user} by $id", [
1862 'user' =>
$user->getName(),
1868 $this->logger->debug( __METHOD__ .
": Account linking failed by $id", [
1869 'user' =>
$user->getName(),
1880 $this->logger->debug( __METHOD__ .
": Account linking $res->status by $id", [
1881 'user' =>
$user->getName(),
1884 $state[
'primary'] = $id;
1885 $state[
'continueRequests'] =
$res->neededRequests;
1886 $session->setSecret(
'AuthManager::accountLinkState', $state );
1887 $session->persist();
1892 throw new \DomainException(
1893 get_class( $provider ) .
"::beginPrimaryAccountLink() returned $res->status"
1899 $this->logger->debug( __METHOD__ .
': Account linking failed because no provider accepted', [
1900 'user' =>
$user->getName(),
1903 wfMessage(
'authmanager-link-no-primary' )
1915 $session = $this->
request->getSession();
1919 $session->remove(
'AuthManager::accountLinkState' );
1920 throw new \LogicException(
'Account linking is not possible' );
1923 $state = $session->getSecret(
'AuthManager::accountLinkState' );
1924 if ( !is_array( $state ) ) {
1926 wfMessage(
'authmanager-link-not-in-progress' )
1929 $state[
'continueRequests'] = [];
1934 if ( !is_object(
$user ) ) {
1935 $session->remove(
'AuthManager::accountLinkState' );
1938 if (
$user->getId() !== $state[
'userid'] ) {
1939 throw new \UnexpectedValueException(
1940 "User \"{$state['username']}\" is valid, but " .
1941 "ID {$user->getId()} !== {$state['userid']}!"
1945 foreach ( $reqs
as $req ) {
1946 $req->username = $state[
'username'];
1947 $req->returnToUrl = $state[
'returnToUrl'];
1957 wfMessage(
'authmanager-link-not-in-progress' )
1960 $session->remove(
'AuthManager::accountLinkState' );
1964 $id = $provider->getUniqueId();
1965 $res = $provider->continuePrimaryAccountLink(
$user, $reqs );
1966 switch (
$res->status ) {
1968 $this->logger->info(
"Account linked to {user} by $id", [
1969 'user' =>
$user->getName(),
1972 $session->remove(
'AuthManager::accountLinkState' );
1975 $this->logger->debug( __METHOD__ .
": Account linking failed by $id", [
1976 'user' =>
$user->getName(),
1979 $session->remove(
'AuthManager::accountLinkState' );
1983 $this->logger->debug( __METHOD__ .
": Account linking $res->status by $id", [
1984 'user' =>
$user->getName(),
1987 $state[
'continueRequests'] =
$res->neededRequests;
1988 $session->setSecret(
'AuthManager::accountLinkState', $state );
1991 throw new \DomainException(
1992 get_class( $provider ) .
"::continuePrimaryAccountLink() returned $res->status"
1995 }
catch ( \Exception $ex ) {
1996 $session->remove(
'AuthManager::accountLinkState' );
2028 $providerAction = $action;
2031 switch ( $action ) {
2040 $state = $this->
request->getSession()->getSecret(
'AuthManager::authnState' );
2041 return is_array( $state ) ? $state[
'continueRequests'] : [];
2044 $state = $this->
request->getSession()->getSecret(
'AuthManager::accountCreationState' );
2045 return is_array( $state ) ? $state[
'continueRequests'] : [];
2063 $state = $this->
request->getSession()->getSecret(
'AuthManager::accountLinkState' );
2064 return is_array( $state ) ? $state[
'continueRequests'] : [];
2074 throw new \DomainException( __METHOD__ .
": Invalid action \"$action\"" );
2093 $user =
$user ?: \RequestContext::getMain()->getUser();
2098 foreach ( $providers
as $provider ) {
2100 foreach ( $provider->getAuthenticationRequests( $providerAction,
$options )
as $req ) {
2104 if ( $isPrimary &&
$req->required ) {
2109 !isset( $reqs[$id] )
2119 switch ( $providerAction ) {
2127 if (
$options[
'username'] !==
null ) {
2138 if ( $providerAction === self::ACTION_CHANGE || $providerAction === self::ACTION_REMOVE ) {
2139 $reqs = array_filter( $reqs,
function (
$req ) {
2144 return array_values( $reqs );
2155 foreach ( $reqs
as $req ) {
2156 if ( !
$req->action || $forceAction ) {
2157 $req->action = $action;
2159 if (
$req->username ===
null ) {
2173 if ( $provider->testUserExists(
$username, $flags ) ) {
2195 foreach ( $providers
as $provider ) {
2196 if ( !$provider->providerAllowsPropertyChange(
$property ) ) {
2213 if ( isset( $this->allAuthenticationProviders[$id] ) ) {
2214 return $this->allAuthenticationProviders[$id];
2219 if ( isset( $providers[$id] ) ) {
2220 return $providers[$id];
2223 if ( isset( $providers[$id] ) ) {
2224 return $providers[$id];
2227 if ( isset( $providers[$id] ) ) {
2228 return $providers[$id];
2248 $session = $this->
request->getSession();
2249 $arr = $session->getSecret(
'authData' );
2250 if ( !is_array( $arr ) ) {
2254 $session->setSecret(
'authData', $arr );
2265 $arr = $this->
request->getSession()->getSecret(
'authData' );
2266 if ( is_array( $arr ) && array_key_exists( $key, $arr ) ) {
2279 $session = $this->
request->getSession();
2280 if ( $key ===
null ) {
2281 $session->remove(
'authData' );
2283 $arr = $session->getSecret(
'authData' );
2284 if ( is_array( $arr ) && array_key_exists( $key, $arr ) ) {
2285 unset( $arr[$key] );
2286 $session->setSecret(
'authData', $arr );
2299 foreach ( $specs
as &$spec ) {
2300 $spec = [
'sort2' => $i++ ] + $spec + [
'sort' => 0 ];
2304 usort( $specs,
function ( $a, $b ) {
2305 return $a[
'sort'] <=> $b[
'sort']
2306 ?: $a[
'sort2'] <=> $b[
'sort2'];
2310 foreach ( $specs
as $spec ) {
2311 $provider = ObjectFactory::getObjectFromSpec( $spec );
2312 if ( !$provider instanceof $class ) {
2313 throw new \RuntimeException(
2314 "Expected instance of $class, got " . get_class( $provider )
2317 $provider->setLogger( $this->logger );
2318 $provider->setManager( $this );
2319 $provider->setConfig( $this->config );
2320 $id = $provider->getUniqueId();
2321 if ( isset( $this->allAuthenticationProviders[$id] ) ) {
2322 throw new \RuntimeException(
2323 "Duplicate specifications for id $id (classes " .
2324 get_class( $provider ) .
' and ' .
2325 get_class( $this->allAuthenticationProviders[$id] ) .
')'
2328 $this->allAuthenticationProviders[$id] = $provider;
2329 $ret[$id] = $provider;
2339 return $this->config->get(
'AuthManagerConfig' ) ?: $this->config->get(
'AuthManagerAutoConfig' );
2347 if ( $this->preAuthenticationProviders ===
null ) {
2350 PreAuthenticationProvider::class, $conf[
'preauth']
2361 if ( $this->primaryAuthenticationProviders ===
null ) {
2364 PrimaryAuthenticationProvider::class, $conf[
'primaryauth']
2375 if ( $this->secondaryAuthenticationProviders ===
null ) {
2378 SecondaryAuthenticationProvider::class, $conf[
'secondaryauth']
2390 $session = $this->
request->getSession();
2391 $delay = $session->delaySave();
2393 $session->resetId();
2394 $session->resetAllTokens();
2395 if ( $session->canSetUser() ) {
2396 $session->setUser(
$user );
2398 if ( $remember !==
null ) {
2399 $session->setRememberUser( $remember );
2401 $session->set(
'AuthManager:lastAuthId',
$user->getId() );
2402 $session->set(
'AuthManager:lastAuthTimestamp', time() );
2403 $session->persist();
2405 \Wikimedia\ScopedCallback::consume( $delay );
2407 \Hooks::run(
'UserLoggedIn', [
$user ] );
2419 $lang = $useContextLang ? \RequestContext::getMain()->getLanguage() : $contLang;
2420 $user->setOption(
'language',
$lang->getPreferredVariant() );
2422 if ( $contLang->hasVariants() ) {
2423 $user->setOption(
'variant', $contLang->getPreferredVariant() );
2443 foreach ( $providers
as $provider ) {
2444 $provider->$method( ...
$args );
2453 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
2455 throw new \MWException( __METHOD__ .
' may only be called from unit tests!' );
2459 self::$instance =
null;
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfReadOnly()
Check whether the wiki is in read-only mode.
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
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.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getName()
Get the user name, or the IP of an anonymous user.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static isCreatableName( $name)
Usernames which fail to pass this function will be blocked from new account registrations,...
isDnsBlacklisted( $ip, $checkWhitelist=false)
Whether the given IP is in a DNS blacklist.
setName( $str)
Set the user name.
getId()
Get the user's ID.
static newFromId( $id)
Static factory method for creation from a given user ID.
static isUsableName( $name)
Usernames which fail to pass this function will be blocked from user login and new account registrati...
isBlockedFromCreateAccount()
Get whether the user is explicitly blocked from account creation.
static idFromName( $name, $flags=self::READ_NORMAL)
Get database id given a user name.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
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
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
this hook is for auditing only $req
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action, or null $user:User who performed the tagging when the tagging is subsequent to the action, or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'ContentSecurityPolicyDefaultSource':Modify the allowed CSP load sources. This affects all directives except for the script directive. If you want to add a script source, see ContentSecurityPolicyScriptSource hook. & $defaultSrc:Array of Content-Security-Policy allowed sources $policyConfig:Current configuration for the Content-Security-Policy header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyDirectives':Modify the content security policy directives. Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs. & $directives:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyScriptSource':Modify the allowed CSP script sources. Note that you also have to use ContentSecurityPolicyDefaultSource if you want non-script sources to be loaded from whatever you add. & $scriptSrc:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
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 & $options
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
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
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
Allows to change the fields on the form that will be generated $name
this hook is for auditing only or null if authentication failed before getting that far $username
returning false will NOT prevent logging a wrapping ErrorException create2 Corresponds to logging log_action database field and which is displayed in the UI similar to $comment or false if none Defaults to false if not set multiOccurrence Can this option be passed multiple times Defaults to false if not set this hook should only be used to add variables that depend on the current page request
return true to allow those checks to and false if checking is done & $user
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
Interface for configuration instances.
const READ_LOCKING
Constants for object loading bitfield flags (higher => higher QoS)
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
if(!isset( $args[0])) $lang