28use Psr\Log\LoggerAwareInterface;
29use Psr\Log\LoggerInterface;
34use Wikimedia\ObjectFactory;
148 if ( self::$instance ===
null ) {
149 self::$instance =
new self(
150 \RequestContext::getMain()->getRequest(),
188 $this->logger->warning(
"Overriding AuthManager primary authn because $why" );
190 if ( $this->primaryAuthenticationProviders !==
null ) {
191 $this->logger->warning(
192 'PrimaryAuthenticationProviders have already been accessed! I hope nothing breaks.'
195 $this->allAuthenticationProviders = array_diff_key(
196 $this->allAuthenticationProviders,
197 $this->primaryAuthenticationProviders
199 $session = $this->request->getSession();
200 $session->remove(
'AuthManager::authnState' );
201 $session->remove(
'AuthManager::accountCreationState' );
202 $session->remove(
'AuthManager::accountLinkState' );
203 $this->createdAccountAuthenticationRequests = [];
206 $this->primaryAuthenticationProviders = [];
207 foreach ( $providers as $provider ) {
209 throw new \RuntimeException(
210 'Expected instance of MediaWiki\\Auth\\PrimaryAuthenticationProvider, got ' .
211 get_class( $provider )
214 $provider->setLogger( $this->logger );
215 $provider->setManager( $this );
216 $provider->setConfig( $this->config );
217 $id = $provider->getUniqueId();
218 if ( isset( $this->allAuthenticationProviders[$id] ) ) {
219 throw new \RuntimeException(
220 "Duplicate specifications for id $id (classes " .
221 get_class( $provider ) .
' and ' .
222 get_class( $this->allAuthenticationProviders[$id] ) .
')'
225 $this->allAuthenticationProviders[$id] = $provider;
226 $this->primaryAuthenticationProviders[$id] = $provider;
263 return $this->request->getSession()->canSetUser();
285 $session = $this->request->getSession();
286 if ( !$session->canSetUser() ) {
288 $session->remove(
'AuthManager::authnState' );
289 throw new \LogicException(
'Authentication is not possible now' );
292 $guessUserName =
null;
293 foreach ( $reqs as
$req ) {
294 $req->returnToUrl = $returnToUrl;
296 if (
$req->username !==
null &&
$req->username !==
'' ) {
297 if ( $guessUserName ===
null ) {
298 $guessUserName =
$req->username;
299 } elseif ( $guessUserName !==
$req->username ) {
300 $guessUserName =
null;
309 $reqs, CreatedAccountAuthenticationRequest::class
312 if ( !in_array(
$req, $this->createdAccountAuthenticationRequests,
true ) ) {
313 throw new \LogicException(
314 'CreatedAccountAuthenticationRequests are only valid on ' .
315 'the same AuthManager that created the account'
322 throw new \UnexpectedValueException(
323 "CreatedAccountAuthenticationRequest had invalid username \"{$req->username}\""
325 } elseif ( $user->getId() !=
$req->id ) {
326 throw new \UnexpectedValueException(
327 "ID for \"{$req->username}\" was {$user->getId()}, expected {$req->id}"
332 $this->logger->info(
'Logging in {user} after account creation', [
333 'user' => $user->getName(),
338 $session->remove(
'AuthManager::authnState' );
339 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$ret, $user, $user->getName() ] );
346 $status = $provider->testForAuthentication( $reqs );
348 $this->logger->debug(
'Login failed in pre-authentication by ' . $provider->getUniqueId() );
350 Status::wrap(
$status )->getMessage()
355 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$ret,
null, $guessUserName ] );
362 'returnToUrl' => $returnToUrl,
363 'guessUserName' => $guessUserName,
365 'primaryResponse' =>
null,
368 'continueRequests' => [],
373 $reqs, CreateFromLoginAuthenticationRequest::class
376 $state[
'maybeLink'] =
$req->maybeLink;
379 $session = $this->request->getSession();
380 $session->setSecret(
'AuthManager::authnState', $state );
409 $session = $this->request->getSession();
411 if ( !$session->canSetUser() ) {
414 throw new \LogicException(
'Authentication is not possible now' );
418 $state = $session->getSecret(
'AuthManager::authnState' );
419 if ( !is_array( $state ) ) {
421 wfMessage(
'authmanager-authn-not-in-progress' )
424 $state[
'continueRequests'] = [];
426 $guessUserName = $state[
'guessUserName'];
428 foreach ( $reqs as
$req ) {
429 $req->returnToUrl = $state[
'returnToUrl'];
434 if ( $state[
'primary'] ===
null ) {
437 $guessUserName =
null;
438 foreach ( $reqs as
$req ) {
439 if (
$req->username !==
null &&
$req->username !==
'' ) {
440 if ( $guessUserName ===
null ) {
441 $guessUserName =
$req->username;
442 } elseif ( $guessUserName !==
$req->username ) {
443 $guessUserName =
null;
448 $state[
'guessUserName'] = $guessUserName;
450 $state[
'reqs'] = $reqs;
453 $res = $provider->beginPrimaryAuthentication( $reqs );
454 switch (
$res->status ) {
456 $state[
'primary'] = $id;
457 $state[
'primaryResponse'] =
$res;
458 $this->logger->debug(
"Primary login with $id succeeded" );
461 $this->logger->debug(
"Login failed in primary authentication by $id" );
462 if (
$res->createRequest || $state[
'maybeLink'] ) {
464 $res->createRequest, $state[
'maybeLink']
470 $session->remove(
'AuthManager::authnState' );
471 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$res,
null, $guessUserName ] );
478 $this->logger->debug(
"Primary login with $id returned $res->status" );
479 $this->
fillRequests(
$res->neededRequests, self::ACTION_LOGIN, $guessUserName );
480 $state[
'primary'] = $id;
481 $state[
'continueRequests'] =
$res->neededRequests;
482 $session->setSecret(
'AuthManager::authnState', $state );
487 throw new \DomainException(
488 get_class( $provider ) .
"::beginPrimaryAuthentication() returned $res->status"
493 if ( $state[
'primary'] ===
null ) {
494 $this->logger->debug(
'Login failed in primary authentication because no provider accepted' );
496 wfMessage(
'authmanager-authn-no-primary' )
501 $session->remove(
'AuthManager::authnState' );
504 } elseif ( $state[
'primaryResponse'] ===
null ) {
510 wfMessage(
'authmanager-authn-not-in-progress' )
515 $session->remove(
'AuthManager::authnState' );
519 $id = $provider->getUniqueId();
520 $res = $provider->continuePrimaryAuthentication( $reqs );
521 switch (
$res->status ) {
523 $state[
'primaryResponse'] =
$res;
524 $this->logger->debug(
"Primary login with $id succeeded" );
527 $this->logger->debug(
"Login failed in primary authentication by $id" );
528 if (
$res->createRequest || $state[
'maybeLink'] ) {
530 $res->createRequest, $state[
'maybeLink']
536 $session->remove(
'AuthManager::authnState' );
537 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$res,
null, $guessUserName ] );
541 $this->logger->debug(
"Primary login with $id returned $res->status" );
542 $this->
fillRequests(
$res->neededRequests, self::ACTION_LOGIN, $guessUserName );
543 $state[
'continueRequests'] =
$res->neededRequests;
544 $session->setSecret(
'AuthManager::authnState', $state );
547 throw new \DomainException(
548 get_class( $provider ) .
"::continuePrimaryAuthentication() returned $res->status"
553 $res = $state[
'primaryResponse'];
554 if (
$res->username ===
null ) {
560 wfMessage(
'authmanager-authn-not-in-progress' )
565 $session->remove(
'AuthManager::authnState' );
575 $state[
'maybeLink'][
$res->linkRequest->getUniqueId()] =
$res->linkRequest;
576 $msg =
'authmanager-authn-no-local-user-link';
578 $msg =
'authmanager-authn-no-local-user';
580 $this->logger->debug(
581 "Primary login with {$provider->getUniqueId()} succeeded, but returned no user"
589 if (
$res->createRequest || $state[
'maybeLink'] ) {
591 $res->createRequest, $state[
'maybeLink']
593 $ret->neededRequests[] =
$ret->createRequest;
595 $this->
fillRequests(
$ret->neededRequests, self::ACTION_LOGIN,
null,
true );
596 $session->setSecret(
'AuthManager::authnState', [
599 'primaryResponse' =>
null,
601 'continueRequests' =>
$ret->neededRequests,
612 throw new \DomainException(
613 get_class( $provider ) .
" returned an invalid username: {$res->username}"
616 if ( $user->getId() === 0 ) {
618 $this->logger->info(
'Auto-creating {user} on login', [
619 'user' => $user->getName(),
624 Status::wrap(
$status )->getMessage(
'authmanager-authn-autocreate-failed' )
627 $session->remove(
'AuthManager::authnState' );
628 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$ret, $user, $user->getName() ] );
635 $beginReqs = $state[
'reqs'];
638 if ( !isset( $state[
'secondary'][$id] ) ) {
642 $func =
'beginSecondaryAuthentication';
643 $res = $provider->beginSecondaryAuthentication( $user, $beginReqs );
644 } elseif ( !$state[
'secondary'][$id] ) {
645 $func =
'continueSecondaryAuthentication';
646 $res = $provider->continueSecondaryAuthentication( $user, $reqs );
650 switch (
$res->status ) {
652 $this->logger->debug(
"Secondary login with $id succeeded" );
655 $state[
'secondary'][$id] =
true;
658 $this->logger->debug(
"Login failed in secondary authentication by $id" );
660 $session->remove(
'AuthManager::authnState' );
661 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$res, $user, $user->getName() ] );
665 $this->logger->debug(
"Secondary login with $id returned " .
$res->status );
666 $this->
fillRequests(
$res->neededRequests, self::ACTION_LOGIN, $user->getName() );
667 $state[
'secondary'][$id] =
false;
668 $state[
'continueRequests'] =
$res->neededRequests;
669 $session->setSecret(
'AuthManager::authnState', $state );
674 throw new \DomainException(
675 get_class( $provider ) .
"::{$func}() returned $res->status"
684 $this->logger->info(
'Login for {user} succeeded from {clientip}', [
685 'user' => $user->getName(),
686 'clientip' => $this->request->getIP(),
690 $beginReqs, RememberMeAuthenticationRequest::class
695 $session->remove(
'AuthManager::authnState' );
697 \Hooks::run(
'AuthManagerLoginAuthenticateAudit', [
$ret, $user, $user->getName() ] );
699 }
catch ( \Exception $ex ) {
700 $session->remove(
'AuthManager::authnState' );
719 $this->logger->debug( __METHOD__ .
": Checking $operation" );
721 $session = $this->request->getSession();
722 $aId = $session->getUser()->getId();
726 $this->logger->info( __METHOD__ .
": Not logged in! $operation is $status" );
730 if ( $session->canSetUser() ) {
731 $id = $session->get(
'AuthManager:lastAuthId' );
732 $last = $session->get(
'AuthManager:lastAuthTimestamp' );
733 if ( $id !== $aId ||
$last ===
null ) {
734 $timeSinceLogin = PHP_INT_MAX;
736 $timeSinceLogin = max( 0, time() -
$last );
739 $thresholds = $this->config->get(
'ReauthenticateTime' );
740 if ( isset( $thresholds[$operation] ) ) {
741 $threshold = $thresholds[$operation];
742 } elseif ( isset( $thresholds[
'default'] ) ) {
743 $threshold = $thresholds[
'default'];
745 throw new \UnexpectedValueException(
'$wgReauthenticateTime lacks a default' );
748 if ( $threshold >= 0 && $timeSinceLogin > $threshold ) {
752 $timeSinceLogin = -1;
754 $pass = $this->config->get(
'AllowSecuritySensitiveOperationIfCannotReauthenticate' );
755 if ( isset( $pass[$operation] ) ) {
757 } elseif ( isset( $pass[
'default'] ) ) {
760 throw new \UnexpectedValueException(
761 '$wgAllowSecuritySensitiveOperationIfCannotReauthenticate lacks a default'
766 \Hooks::run(
'SecuritySensitiveOperationStatus', [
767 &
$status, $operation, $session, $timeSinceLogin
775 $this->logger->info( __METHOD__ .
": $operation is $status for '{user}'",
777 'user' => $session->getUser()->getName(),
778 'clientip' => $this->getRequest()->getIP(),
796 if ( $provider->testUserCanAuthenticate(
$username ) ) {
820 $normalized = $provider->providerNormalizeUsername(
$username );
821 if ( $normalized !==
null ) {
822 $ret[$normalized] =
true;
825 return array_keys(
$ret );
843 $this->logger->info(
'Revoking access for {user}', [
862 foreach ( $providers as $provider ) {
863 $status = $provider->providerAllowsAuthenticationDataChange(
$req, $checkData );
865 return Status::wrap(
$status );
867 $any = $any ||
$status->value !==
'ignored';
870 $status = Status::newGood(
'ignored' );
871 $status->warning(
'authmanager-change-not-supported' );
874 return Status::newGood();
895 $this->logger->info(
'Changing authentication data for {user} class {what}', [
896 'user' => is_string(
$req->username ) ?
$req->username :
'<no name>',
897 'what' => get_class(
$req ),
904 if ( !$isAddition ) {
905 \BotPassword::invalidateAllPasswordsForUser(
$req->username );
922 switch ( $provider->accountCreationType() ) {
945 'flags' => User::READ_NORMAL,
951 return Status::newFatal(
'authmanager-create-disabled' );
955 return Status::newFatal(
'userexists' );
959 if ( !is_object( $user ) ) {
960 return Status::newFatal(
'noname' );
962 $user->load( $flags );
963 if ( $user->getId() !== 0 ) {
964 return Status::newFatal(
'userexists' );
972 foreach ( $providers as $provider ) {
975 return Status::wrap(
$status );
979 return Status::newGood();
994 $permErrors = \SpecialPage::getTitleFor(
'CreateAccount' )
995 ->getUserPermissionsErrors(
'createaccount', $creator,
'secure' );
998 foreach ( $permErrors as
$args ) {
1004 $block = $creator->isBlockedFromCreateAccount();
1007 $block->getTarget(),
1008 $block->mReason ?:
wfMessage(
'blockednoreason' )->text(),
1013 $errorMessage =
'cantcreateaccount-range-text';
1014 $errorParams[] = $this->
getRequest()->getIP();
1016 $errorMessage =
'cantcreateaccount-text';
1019 return Status::newFatal(
wfMessage( $errorMessage, $errorParams ) );
1024 return Status::newFatal(
'sorbs_create_account_reason' );
1027 return Status::newGood();
1050 $session = $this->request->getSession();
1053 $session->remove(
'AuthManager::accountCreationState' );
1054 throw new \LogicException(
'Account creation is not possible' );
1059 }
catch ( \UnexpectedValueException $ex ) {
1063 $this->logger->debug( __METHOD__ .
': No username provided' );
1070 $this->logger->debug( __METHOD__ .
': {creator} cannot create users: {reason}', [
1072 'creator' => $creator->getName(),
1073 'reason' =>
$status->getWikiText(
null,
null,
'en' )
1082 $this->logger->debug( __METHOD__ .
': {user} cannot be created: {reason}', [
1084 'creator' => $creator->getName(),
1085 'reason' =>
$status->getWikiText(
null,
null,
'en' )
1091 foreach ( $reqs as
$req ) {
1093 $req->returnToUrl = $returnToUrl;
1098 $session->remove(
'AuthManager::accountCreationState' );
1099 $this->logger->debug( __METHOD__ .
': UserData is invalid: {reason}', [
1100 'user' => $user->getName(),
1101 'creator' => $creator->getName(),
1102 'reason' =>
$status->getWikiText(
null,
null,
'en' ),
1114 'creatorid' => $creator->getId(),
1115 'creatorname' => $creator->getName(),
1117 'returnToUrl' => $returnToUrl,
1119 'primaryResponse' =>
null,
1121 'continueRequests' => [],
1123 'ranPreTests' =>
false,
1128 $reqs, CreateFromLoginAuthenticationRequest::class
1131 $state[
'maybeLink'] =
$req->maybeLink;
1133 if (
$req->createRequest ) {
1134 $reqs[] =
$req->createRequest;
1135 $state[
'reqs'][] =
$req->createRequest;
1139 $session->setSecret(
'AuthManager::accountCreationState', $state );
1140 $session->persist();
1151 $session = $this->request->getSession();
1155 $session->remove(
'AuthManager::accountCreationState' );
1156 throw new \LogicException(
'Account creation is not possible' );
1159 $state = $session->getSecret(
'AuthManager::accountCreationState' );
1160 if ( !is_array( $state ) ) {
1162 wfMessage(
'authmanager-create-not-in-progress' )
1165 $state[
'continueRequests'] = [];
1170 if ( !is_object( $user ) ) {
1171 $session->remove(
'AuthManager::accountCreationState' );
1172 $this->logger->debug( __METHOD__ .
': Invalid username', [
1173 'user' => $state[
'username'],
1178 if ( $state[
'creatorid'] ) {
1181 $creator =
new User;
1182 $creator->
setName( $state[
'creatorname'] );
1186 $cache = \ObjectCache::getLocalClusterInstance();
1187 $lock =
$cache->getScopedLock(
$cache->makeGlobalKey(
'account', md5( $user->getName() ) ) );
1191 $this->logger->debug( __METHOD__ .
': Could not acquire account creation lock', [
1192 'user' => $user->getName(),
1193 'creator' => $creator->getName(),
1201 $this->logger->debug( __METHOD__ .
': {creator} cannot create users: {reason}', [
1202 'user' => $user->getName(),
1203 'creator' => $creator->getName(),
1204 'reason' =>
$status->getWikiText(
null,
null,
'en' )
1208 $session->remove(
'AuthManager::accountCreationState' );
1215 if ( $state[
'userid'] === 0 ) {
1216 if ( $user->getId() != 0 ) {
1217 $this->logger->debug( __METHOD__ .
': User exists locally', [
1218 'user' => $user->getName(),
1219 'creator' => $creator->getName(),
1223 $session->remove(
'AuthManager::accountCreationState' );
1227 if ( $user->getId() == 0 ) {
1228 $this->logger->debug( __METHOD__ .
': User does not exist locally when it should', [
1229 'user' => $user->getName(),
1230 'creator' => $creator->getName(),
1231 'expected_id' => $state[
'userid'],
1233 throw new \UnexpectedValueException(
1234 "User \"{$state['username']}\" should exist now, but doesn't!"
1237 if ( $user->getId() != $state[
'userid'] ) {
1238 $this->logger->debug( __METHOD__ .
': User ID/name mismatch', [
1239 'user' => $user->getName(),
1240 'creator' => $creator->getName(),
1241 'expected_id' => $state[
'userid'],
1242 'actual_id' => $user->getId(),
1244 throw new \UnexpectedValueException(
1245 "User \"{$state['username']}\" exists, but " .
1246 "ID {$user->getId()} != {$state['userid']}!"
1250 foreach ( $state[
'reqs'] as
$req ) {
1256 $this->logger->debug( __METHOD__ .
': UserData is invalid: {reason}', [
1257 'user' => $user->getName(),
1258 'creator' => $creator->getName(),
1259 'reason' =>
$status->getWikiText(
null,
null,
'en' ),
1263 $session->remove(
'AuthManager::accountCreationState' );
1269 foreach ( $reqs as
$req ) {
1270 $req->returnToUrl = $state[
'returnToUrl'];
1271 $req->username = $state[
'username'];
1275 if ( !$state[
'ranPreTests'] ) {
1279 foreach ( $providers as $id => $provider ) {
1280 $status = $provider->testForAccountCreation( $user, $creator, $reqs );
1282 $this->logger->debug( __METHOD__ .
": Fail in pre-authentication by $id", [
1283 'user' => $user->getName(),
1284 'creator' => $creator->getName(),
1287 Status::wrap(
$status )->getMessage()
1290 $session->remove(
'AuthManager::accountCreationState' );
1295 $state[
'ranPreTests'] =
true;
1300 if ( $state[
'primary'] ===
null ) {
1306 $res = $provider->beginPrimaryAccountCreation( $user, $creator, $reqs );
1307 switch (
$res->status ) {
1309 $this->logger->debug( __METHOD__ .
": Primary creation passed by $id", [
1310 'user' => $user->getName(),
1311 'creator' => $creator->getName(),
1313 $state[
'primary'] = $id;
1314 $state[
'primaryResponse'] =
$res;
1317 $this->logger->debug( __METHOD__ .
": Primary creation failed by $id", [
1318 'user' => $user->getName(),
1319 'creator' => $creator->getName(),
1322 $session->remove(
'AuthManager::accountCreationState' );
1329 $this->logger->debug( __METHOD__ .
": Primary creation $res->status by $id", [
1330 'user' => $user->getName(),
1331 'creator' => $creator->getName(),
1334 $state[
'primary'] = $id;
1335 $state[
'continueRequests'] =
$res->neededRequests;
1336 $session->setSecret(
'AuthManager::accountCreationState', $state );
1341 throw new \DomainException(
1342 get_class( $provider ) .
"::beginPrimaryAccountCreation() returned $res->status"
1347 if ( $state[
'primary'] ===
null ) {
1348 $this->logger->debug( __METHOD__ .
': Primary creation failed because no provider accepted', [
1349 'user' => $user->getName(),
1350 'creator' => $creator->getName(),
1353 wfMessage(
'authmanager-create-no-primary' )
1356 $session->remove(
'AuthManager::accountCreationState' );
1359 } elseif ( $state[
'primaryResponse'] ===
null ) {
1365 wfMessage(
'authmanager-create-not-in-progress' )
1368 $session->remove(
'AuthManager::accountCreationState' );
1372 $id = $provider->getUniqueId();
1373 $res = $provider->continuePrimaryAccountCreation( $user, $creator, $reqs );
1374 switch (
$res->status ) {
1376 $this->logger->debug( __METHOD__ .
": Primary creation passed by $id", [
1377 'user' => $user->getName(),
1378 'creator' => $creator->getName(),
1380 $state[
'primaryResponse'] =
$res;
1383 $this->logger->debug( __METHOD__ .
": Primary creation failed by $id", [
1384 'user' => $user->getName(),
1385 'creator' => $creator->getName(),
1388 $session->remove(
'AuthManager::accountCreationState' );
1392 $this->logger->debug( __METHOD__ .
": Primary creation $res->status by $id", [
1393 'user' => $user->getName(),
1394 'creator' => $creator->getName(),
1397 $state[
'continueRequests'] =
$res->neededRequests;
1398 $session->setSecret(
'AuthManager::accountCreationState', $state );
1401 throw new \DomainException(
1402 get_class( $provider ) .
"::continuePrimaryAccountCreation() returned $res->status"
1410 if ( $state[
'userid'] === 0 ) {
1411 $this->logger->info(
'Creating user {user} during account creation', [
1412 'user' => $user->getName(),
1413 'creator' => $creator->getName(),
1415 $status = $user->addToDatabase();
1420 $session->remove(
'AuthManager::accountCreationState' );
1425 \Hooks::run(
'LocalUserCreated', [ $user,
false ] );
1426 $user->saveSettings();
1427 $state[
'userid'] = $user->getId();
1430 \DeferredUpdates::addUpdate( \SiteStatsUpdate::factory( [
'users' => 1 ] ) );
1436 $logSubtype = $provider->finishAccountCreation( $user, $creator, $state[
'primaryResponse'] );
1439 if ( $this->config->get(
'NewUserLog' ) ) {
1440 $isAnon = $creator->isAnon();
1441 $logEntry = new \ManualLogEntry(
1443 $logSubtype ?: ( $isAnon ?
'create' :
'create2' )
1445 $logEntry->setPerformer( $isAnon ? $user : $creator );
1446 $logEntry->setTarget( $user->getUserPage() );
1449 $state[
'reqs'], CreationReasonAuthenticationRequest::class
1451 $logEntry->setComment(
$req ?
$req->reason :
'' );
1452 $logEntry->setParameters( [
1453 '4::userid' => $user->getId(),
1455 $logid = $logEntry->insert();
1456 $logEntry->publish( $logid );
1462 $beginReqs = $state[
'reqs'];
1465 if ( !isset( $state[
'secondary'][$id] ) ) {
1469 $func =
'beginSecondaryAccountCreation';
1470 $res = $provider->beginSecondaryAccountCreation( $user, $creator, $beginReqs );
1471 } elseif ( !$state[
'secondary'][$id] ) {
1472 $func =
'continueSecondaryAccountCreation';
1473 $res = $provider->continueSecondaryAccountCreation( $user, $creator, $reqs );
1477 switch (
$res->status ) {
1479 $this->logger->debug( __METHOD__ .
": Secondary creation passed by $id", [
1480 'user' => $user->getName(),
1481 'creator' => $creator->getName(),
1485 $state[
'secondary'][$id] =
true;
1489 $this->logger->debug( __METHOD__ .
": Secondary creation $res->status by $id", [
1490 'user' => $user->getName(),
1491 'creator' => $creator->getName(),
1494 $state[
'secondary'][$id] =
false;
1495 $state[
'continueRequests'] =
$res->neededRequests;
1496 $session->setSecret(
'AuthManager::accountCreationState', $state );
1499 throw new \DomainException(
1500 get_class( $provider ) .
"::{$func}() returned $res->status." .
1501 ' Secondary providers are not allowed to fail account creation, that' .
1502 ' should have been done via testForAccountCreation().'
1506 throw new \DomainException(
1507 get_class( $provider ) .
"::{$func}() returned $res->status"
1513 $id = $user->getId();
1514 $name = $user->getName();
1518 $this->createdAccountAuthenticationRequests[] =
$req;
1520 $this->logger->info( __METHOD__ .
': Account creation succeeded for {user}', [
1521 'user' => $user->getName(),
1522 'creator' => $creator->getName(),
1526 $session->remove(
'AuthManager::accountCreationState' );
1529 }
catch ( \Exception $ex ) {
1530 $session->remove(
'AuthManager::accountCreationState' );
1551 if (
$source !== self::AUTOCREATE_SOURCE_SESSION &&
1554 throw new \InvalidArgumentException(
"Unknown auto-creation source: $source" );
1561 $flags = User::READ_NORMAL;
1571 $flags = User::READ_LATEST;
1576 $this->logger->debug( __METHOD__ .
': {username} already exists locally', [
1579 $user->setId( $localId );
1580 $user->loadFromId( $flags );
1585 $status->warning(
'userexists' );
1591 $this->logger->debug( __METHOD__ .
': denied by wfReadOnly(): {reason}', [
1596 $user->loadFromId();
1602 $session = $this->request->getSession();
1603 if ( $session->get(
'AuthManager::AutoCreateBlacklist' ) ) {
1604 $this->logger->debug( __METHOD__ .
': blacklisted in session {sessionid}', [
1606 'sessionid' => $session->getId(),
1609 $user->loadFromId();
1610 $reason = $session->get(
'AuthManager::AutoCreateBlacklist' );
1612 return Status::wrap( $reason );
1614 return Status::newFatal( $reason );
1620 $this->logger->debug( __METHOD__ .
': name "{username}" is not creatable', [
1623 $session->set(
'AuthManager::AutoCreateBlacklist',
'noname' );
1625 $user->loadFromId();
1626 return Status::newFatal(
'noname' );
1631 if ( !$anon->isAllowedAny(
'createaccount',
'autocreateaccount' ) ) {
1632 $this->logger->debug( __METHOD__ .
': IP lacks the ability to create or autocreate accounts', [
1634 'ip' => $anon->getName(),
1636 $session->set(
'AuthManager::AutoCreateBlacklist',
'authmanager-autocreate-noperm' );
1637 $session->persist();
1639 $user->loadFromId();
1640 return Status::newFatal(
'authmanager-autocreate-noperm' );
1644 $cache = \ObjectCache::getLocalClusterInstance();
1647 $this->logger->debug( __METHOD__ .
': Could not acquire account creation lock', [
1651 $user->loadFromId();
1652 return Status::newFatal(
'usernameinprogress' );
1657 'flags' => User::READ_LATEST,
1663 foreach ( $providers as $provider ) {
1667 $this->logger->debug( __METHOD__ .
': Provider denied creation of {username}: {reason}', [
1669 'reason' =>
$ret->getWikiText(
null,
null,
'en' ),
1671 $session->set(
'AuthManager::AutoCreateBlacklist',
$status );
1673 $user->loadFromId();
1678 $backoffKey =
$cache->makeKey(
'AuthManager',
'autocreate-failed', md5(
$username ) );
1679 if (
$cache->get( $backoffKey ) ) {
1680 $this->logger->debug( __METHOD__ .
': {username} denied by prior creation attempt failures', [
1684 $user->loadFromId();
1685 return Status::newFatal(
'authmanager-autocreate-exception' );
1689 $from = $_SERVER[
'REQUEST_URI'] ??
'CLI';
1690 $this->logger->info( __METHOD__ .
': creating new user ({username}) - from: {from}', [
1696 $trxProfiler = \Profiler::instance()->getTransactionProfiler();
1697 $old = $trxProfiler->setSilenced(
true );
1699 $status = $user->addToDatabase();
1703 if ( $user->getId() ) {
1704 $this->logger->info( __METHOD__ .
': {username} already exists locally (race)', [
1711 $status->warning(
'userexists' );
1713 $this->logger->error( __METHOD__ .
': {username} failed with message {msg}', [
1715 'msg' =>
$status->getWikiText(
null,
null,
'en' )
1718 $user->loadFromId();
1722 }
catch ( \Exception $ex ) {
1723 $trxProfiler->setSilenced( $old );
1724 $this->logger->error( __METHOD__ .
': {username} failed with exception {exception}', [
1729 $cache->set( $backoffKey, 1, 600 );
1739 \Hooks::run(
'AuthPluginAutoCreate', [ $user ],
'1.27' );
1740 \Hooks::run(
'LocalUserCreated', [ $user,
true ] );
1741 $user->saveSettings();
1744 \DeferredUpdates::addUpdate( \SiteStatsUpdate::factory( [
'users' => 1 ] ) );
1746 \DeferredUpdates::addCallableUpdate(
function () use ( $user ) {
1751 if ( $this->config->get(
'NewUserLog' ) ) {
1752 $logEntry = new \ManualLogEntry(
'newusers',
'autocreate' );
1753 $logEntry->setPerformer( $user );
1754 $logEntry->setTarget( $user->getUserPage() );
1755 $logEntry->setComment(
'' );
1756 $logEntry->setParameters( [
1757 '4::userid' => $user->getId(),
1759 $logEntry->insert();
1762 $trxProfiler->setSilenced( $old );
1768 return Status::newGood();
1801 $session = $this->request->getSession();
1802 $session->remove(
'AuthManager::accountLinkState' );
1806 throw new \LogicException(
'Account linking is not possible' );
1809 if ( $user->getId() === 0 ) {
1813 $msg =
wfMessage(
'authmanager-userdoesnotexist', $user->getName() );
1817 foreach ( $reqs as
$req ) {
1818 $req->username = $user->getName();
1819 $req->returnToUrl = $returnToUrl;
1825 foreach ( $providers as $id => $provider ) {
1826 $status = $provider->testForAccountLink( $user );
1828 $this->logger->debug( __METHOD__ .
": Account linking pre-check failed by $id", [
1829 'user' => $user->getName(),
1832 Status::wrap(
$status )->getMessage()
1840 'username' => $user->getName(),
1841 'userid' => $user->getId(),
1842 'returnToUrl' => $returnToUrl,
1844 'continueRequests' => [],
1848 foreach ( $providers as $id => $provider ) {
1853 $res = $provider->beginPrimaryAccountLink( $user, $reqs );
1854 switch (
$res->status ) {
1856 $this->logger->info(
"Account linked to {user} by $id", [
1857 'user' => $user->getName(),
1863 $this->logger->debug( __METHOD__ .
": Account linking failed by $id", [
1864 'user' => $user->getName(),
1875 $this->logger->debug( __METHOD__ .
": Account linking $res->status by $id", [
1876 'user' => $user->getName(),
1878 $this->
fillRequests(
$res->neededRequests, self::ACTION_LINK, $user->getName() );
1879 $state[
'primary'] = $id;
1880 $state[
'continueRequests'] =
$res->neededRequests;
1881 $session->setSecret(
'AuthManager::accountLinkState', $state );
1882 $session->persist();
1887 throw new \DomainException(
1888 get_class( $provider ) .
"::beginPrimaryAccountLink() returned $res->status"
1894 $this->logger->debug( __METHOD__ .
': Account linking failed because no provider accepted', [
1895 'user' => $user->getName(),
1898 wfMessage(
'authmanager-link-no-primary' )
1910 $session = $this->request->getSession();
1914 $session->remove(
'AuthManager::accountLinkState' );
1915 throw new \LogicException(
'Account linking is not possible' );
1918 $state = $session->getSecret(
'AuthManager::accountLinkState' );
1919 if ( !is_array( $state ) ) {
1921 wfMessage(
'authmanager-link-not-in-progress' )
1924 $state[
'continueRequests'] = [];
1929 if ( !is_object( $user ) ) {
1930 $session->remove(
'AuthManager::accountLinkState' );
1933 if ( $user->getId() != $state[
'userid'] ) {
1934 throw new \UnexpectedValueException(
1935 "User \"{$state['username']}\" is valid, but " .
1936 "ID {$user->getId()} != {$state['userid']}!"
1940 foreach ( $reqs as
$req ) {
1941 $req->username = $state[
'username'];
1942 $req->returnToUrl = $state[
'returnToUrl'];
1952 wfMessage(
'authmanager-link-not-in-progress' )
1955 $session->remove(
'AuthManager::accountLinkState' );
1959 $id = $provider->getUniqueId();
1960 $res = $provider->continuePrimaryAccountLink( $user, $reqs );
1961 switch (
$res->status ) {
1963 $this->logger->info(
"Account linked to {user} by $id", [
1964 'user' => $user->getName(),
1967 $session->remove(
'AuthManager::accountLinkState' );
1970 $this->logger->debug( __METHOD__ .
": Account linking failed by $id", [
1971 'user' => $user->getName(),
1974 $session->remove(
'AuthManager::accountLinkState' );
1978 $this->logger->debug( __METHOD__ .
": Account linking $res->status by $id", [
1979 'user' => $user->getName(),
1981 $this->
fillRequests(
$res->neededRequests, self::ACTION_LINK, $user->getName() );
1982 $state[
'continueRequests'] =
$res->neededRequests;
1983 $session->setSecret(
'AuthManager::accountLinkState', $state );
1986 throw new \DomainException(
1987 get_class( $provider ) .
"::continuePrimaryAccountLink() returned $res->status"
1990 }
catch ( \Exception $ex ) {
1991 $session->remove(
'AuthManager::accountLinkState' );
2023 $providerAction = $action;
2026 switch ( $action ) {
2035 $state = $this->request->getSession()->getSecret(
'AuthManager::authnState' );
2036 return is_array( $state ) ? $state[
'continueRequests'] : [];
2039 $state = $this->request->getSession()->getSecret(
'AuthManager::accountCreationState' );
2040 return is_array( $state ) ? $state[
'continueRequests'] : [];
2058 $state = $this->request->getSession()->getSecret(
'AuthManager::accountLinkState' );
2059 return is_array( $state ) ? $state[
'continueRequests'] : [];
2069 throw new \DomainException( __METHOD__ .
": Invalid action \"$action\"" );
2088 $user = $user ?: \RequestContext::getMain()->getUser();
2089 $options[
'username'] = $user->isAnon() ? null : $user->getName();
2093 foreach ( $providers as $provider ) {
2095 foreach ( $provider->getAuthenticationRequests( $providerAction,
$options ) as
$req ) {
2096 $id =
$req->getUniqueId();
2100 if (
$req->required ) {
2106 !isset( $reqs[$id] )
2116 switch ( $providerAction ) {
2124 if (
$options[
'username'] !==
null ) {
2135 if ( $providerAction === self::ACTION_CHANGE || $providerAction === self::ACTION_REMOVE ) {
2136 $reqs = array_filter( $reqs,
function (
$req ) {
2141 return array_values( $reqs );
2152 foreach ( $reqs as
$req ) {
2153 if ( !
$req->action || $forceAction ) {
2154 $req->action = $action;
2156 if (
$req->username ===
null ) {
2170 if ( $provider->testUserExists(
$username, $flags ) ) {
2192 foreach ( $providers as $provider ) {
2193 if ( !$provider->providerAllowsPropertyChange(
$property ) ) {
2210 if ( isset( $this->allAuthenticationProviders[$id] ) ) {
2211 return $this->allAuthenticationProviders[$id];
2216 if ( isset( $providers[$id] ) ) {
2217 return $providers[$id];
2220 if ( isset( $providers[$id] ) ) {
2221 return $providers[$id];
2224 if ( isset( $providers[$id] ) ) {
2225 return $providers[$id];
2245 $session = $this->request->getSession();
2246 $arr = $session->getSecret(
'authData' );
2247 if ( !is_array( $arr ) ) {
2251 $session->setSecret(
'authData', $arr );
2262 $arr = $this->request->getSession()->getSecret(
'authData' );
2263 if ( is_array( $arr ) && array_key_exists( $key, $arr ) ) {
2276 $session = $this->request->getSession();
2277 if ( $key ===
null ) {
2278 $session->remove(
'authData' );
2280 $arr = $session->getSecret(
'authData' );
2281 if ( is_array( $arr ) && array_key_exists( $key, $arr ) ) {
2282 unset( $arr[$key] );
2283 $session->setSecret(
'authData', $arr );
2296 foreach ( $specs as &$spec ) {
2297 $spec = [
'sort2' => $i++ ] + $spec + [
'sort' => 0 ];
2301 usort( $specs,
function ( $a, $b ) {
2302 return $a[
'sort'] <=> $b[
'sort']
2303 ?: $a[
'sort2'] <=> $b[
'sort2'];
2307 foreach ( $specs as $spec ) {
2308 $provider = ObjectFactory::getObjectFromSpec( $spec );
2309 if ( !$provider instanceof $class ) {
2310 throw new \RuntimeException(
2311 "Expected instance of $class, got " . get_class( $provider )
2314 $provider->setLogger( $this->logger );
2315 $provider->setManager( $this );
2316 $provider->setConfig( $this->config );
2317 $id = $provider->getUniqueId();
2318 if ( isset( $this->allAuthenticationProviders[$id] ) ) {
2319 throw new \RuntimeException(
2320 "Duplicate specifications for id $id (classes " .
2321 get_class( $provider ) .
' and ' .
2322 get_class( $this->allAuthenticationProviders[$id] ) .
')'
2325 $this->allAuthenticationProviders[$id] = $provider;
2326 $ret[$id] = $provider;
2336 return $this->config->get(
'AuthManagerConfig' ) ?: $this->config->get(
'AuthManagerAutoConfig' );
2344 if ( $this->preAuthenticationProviders ===
null ) {
2347 PreAuthenticationProvider::class, $conf[
'preauth']
2358 if ( $this->primaryAuthenticationProviders ===
null ) {
2361 PrimaryAuthenticationProvider::class, $conf[
'primaryauth']
2372 if ( $this->secondaryAuthenticationProviders ===
null ) {
2375 SecondaryAuthenticationProvider::class, $conf[
'secondaryauth']
2387 $session = $this->request->getSession();
2388 $delay = $session->delaySave();
2390 $session->resetId();
2391 $session->resetAllTokens();
2392 if ( $session->canSetUser() ) {
2393 $session->setUser( $user );
2395 if ( $remember !==
null ) {
2396 $session->setRememberUser( $remember );
2398 $session->set(
'AuthManager:lastAuthId', $user->getId() );
2399 $session->set(
'AuthManager:lastAuthTimestamp', time() );
2400 $session->persist();
2402 \Wikimedia\ScopedCallback::consume( $delay );
2404 \Hooks::run(
'UserLoggedIn', [ $user ] );
2416 $lang = $useContextLang ? \RequestContext::getMain()->getLanguage() : $contLang;
2417 $user->setOption(
'language',
$lang->getPreferredVariant() );
2419 if ( $contLang->hasVariants() ) {
2420 $user->setOption(
'variant', $contLang->getPreferredVariant() );
2440 foreach ( $providers as $provider ) {
2441 $provider->$method( ...
$args );
2450 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
2452 throw new \MWException( __METHOD__ .
' may only be called from unit tests!' );
2456 self::$instance =
null;
$wgAuth $wgAuth
Authentication plugin.
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.
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,...
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.
static newFromId( $id)
Static factory method for creation from a given user ID.
setId( $v)
Set the user and reload all fields according to a given ID.
static isUsableName( $name)
Usernames which fail to pass this function will be blocked from user login and new account registrati...
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 hook is for auditing only $req
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
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
this hook is for auditing only or null if authentication failed before getting that far $username
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
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