68 abstract protected function isSignup();
76 abstract protected function successfulAction( $direct =
false, $extraMessages = null );
87 parent::__construct(
$name );
90 $wgUseMediaWikiUIEverywhere =
true;
94 parent::setRequest( $data, $wasPosted );
95 $this->mLoadedRequest =
false;
103 if ( $this->mLoadedRequest ) {
106 $this->mLoadedRequest =
true;
109 $this->mPosted =
$request->wasPosted();
110 $this->mIsReturn =
$subPage ===
'return';
111 $this->mAction =
$request->getVal(
'action' );
112 $this->mFromHTTP =
$request->getBool(
'fromhttp',
false )
113 ||
$request->getBool(
'wpFromhttp',
false );
114 $this->mStickHTTPS = ( !$this->mFromHTTP &&
$request->getProtocol() ===
'https' )
115 ||
$request->getBool(
'wpForceHttps',
false );
116 $this->mLanguage =
$request->getText(
'uselang' );
117 $this->mReturnTo =
$request->getVal(
'returnto',
'' );
118 $this->mReturnToQuery =
$request->getVal(
'returntoquery',
'' );
130 if ( $this->mLoaded ) {
133 $this->mLoaded =
true;
138 $securityLevel && AuthManager::singleton()->securitySensitiveOperationStatus(
149 $entryError = $this->
msg(
$request->getVal(
'error',
'' ) );
150 $entryWarning = $this->
msg(
$request->getVal(
'warning',
'' ) );
155 $this->
msg(
'loginreqlink' )->escaped(),
158 'returnto' => $this->mReturnTo,
159 'returntoquery' => $this->mReturnToQuery,
160 'uselang' => $this->mLanguage,
161 'fromhttp' => $wgSecureLogin && $this->mFromHTTP ?
'1' : null,
166 if ( $entryError->exists()
169 $this->mEntryErrorType =
'error';
170 $this->mEntryError = $entryError->rawParams( $loginreqlink )->parse();
172 } elseif ( $entryWarning->exists()
175 $this->mEntryErrorType =
'warning';
176 $this->mEntryError = $entryWarning->rawParams( $loginreqlink )->parse();
179 # 1. When switching accounts, it sucks to get automatically logged out
180 # 2. Do not return to PasswordReset after a successful password change
181 # but goto Wiki start page (Main_Page) instead ( bug 33997 )
183 if ( is_object( $returnToTitle )
184 && ( $returnToTitle->isSpecial(
'Userlogout' )
185 || $returnToTitle->isSpecial(
'PasswordReset' ) )
187 $this->mReturnTo =
'';
188 $this->mReturnToQuery =
'';
195 $params = parent::getPreservedParams( $withToken );
197 'returnto' => $this->mReturnTo ?: null,
198 'returntoquery' => $this->mReturnToQuery ?: null,
200 if ( $wgSecureLogin && !$this->
isSignup() ) {
201 $params[
'fromhttp'] = $this->mFromHTTP ?
'1' : null;
209 return parent::beforeExecute(
$subPage );
216 $authManager = AuthManager::singleton();
217 $session = SessionManager::getGlobalSession();
228 if ( !$this->
isSignup() && !$session->canSetUser() ) {
229 throw new ErrorPageError(
'cannotloginnow-title',
'cannotloginnow-text', [
248 if ( !$this->
isSignup() && !$this->mPosted && !$this->securityLevel &&
249 ( $this->mReturnTo !==
'' || $this->mReturnToQuery !==
'' ) &&
257 if ( $this->
getRequest()->getProtocol() !==
'https' ) {
261 ( $this->mEntryErrorType ===
'error' ?
'error'
262 :
'warning' ) => $this->mEntryError,
265 if ( $wgSecureLogin && !$this->mFromHTTP &&
272 $this->
getOutput()->addVaryHeader(
'X-Forwarded-Proto' );
279 if ( substr( $url, 0, 8 ) ===
'https://' ) {
280 $this->mSecureLoginUrl = $url;
289 $this->
mainLoginForm( [],
'authpage-cannot-' . $this->authAction );
306 case AuthenticationResponse::PASS:
308 $this->proxyAccountCreation = $this->
isSignup() && !$this->
getUser()->isAnon();
312 !$this->proxyAccountCreation
314 && $authManager->canAuthenticateNow()
317 $response2 = $authManager->beginAuthentication( [
$response->loginRequest ],
319 if ( $response2->status !== AuthenticationResponse::PASS ) {
320 LoggerFactory::getInstance(
'login' )
321 ->error(
'Could not log in after account creation' );
327 if ( !$this->proxyAccountCreation ) {
334 case AuthenticationResponse::FAIL:
336 case AuthenticationResponse::RESTART:
337 unset( $this->authForm );
338 if (
$response->status === AuthenticationResponse::FAIL ) {
340 $messageType =
'error';
343 $messageType =
'warning';
349 case AuthenticationResponse::REDIRECT:
350 unset( $this->authForm );
353 case AuthenticationResponse::UI:
354 unset( $this->authForm );
355 $this->authAction = $this->
isSignup() ? AuthManager::ACTION_CREATE_CONTINUE
356 : AuthManager::ACTION_LOGIN_CONTINUE;
357 $this->authRequests =
$response->neededRequests;
375 $type,
$title, $msgname, $injected_html, $extraMessages
382 if ( $extraMessages ) {
384 $out->addWikiText( $extraMessages->getWikiText() );
387 $out->addHTML( $injected_html );
390 $helper->showReturnToPage(
$type, $this->mReturnTo, $this->mReturnToQuery, $this->mStickHTTPS );
464 $this->authForm = null;
465 $requests = AuthManager::singleton()->getAuthenticationRequests( $this->authAction,
$user );
469 $out->addModuleStyles( [
471 'mediawiki.ui.button',
472 'mediawiki.ui.checkbox',
473 'mediawiki.ui.input',
474 'mediawiki.special.userlogin.common.styles'
478 $out->addJsConfigVars(
'wgCreateacctImgcaptchaHelp',
479 $this->
msg(
'createacct-imgcaptcha-help' )->parse() );
483 'mediawiki.special.userlogin.signup.js'
485 $out->addModuleStyles( [
486 'mediawiki.special.userlogin.signup.styles'
490 $out->addModuleStyles( [
491 'mediawiki.special.userlogin.login.styles'
494 $out->disallowUserJs();
496 $form = $this->
getAuthForm( $requests, $this->authAction, $msg, $msgtype );
497 $form->prepareForm();
513 [
'id' =>
'userloginprompt' ], $this->
msg(
'loginprompt' )->parseAsBlock() );
515 $signupStartMsg = $this->
msg(
'signupstart' );
516 $signupStart = ( $this->
isSignup() && !$signupStartMsg->isDisabled() )
517 ?
Html::rawElement(
'div', [
'id' =>
'signupstart' ], $signupStartMsg->parseAsBlock() ) :
'';
518 if ( $languageLinks ) {
524 $benefitsContainer =
'';
532 for ( $benefitIdx = 1; $benefitIdx <= $benefitCount; $benefitIdx++ ) {
533 $headUnescaped = $this->
msg(
"createacct-benefit-head$benefitIdx" )->text();
534 $iconClass = $this->
msg(
"createacct-benefit-icon$benefitIdx" )->escaped();
535 $benefitList .=
Html::rawElement(
'div', [
'class' =>
"mw-number-text $iconClass" ],
537 $this->
msg(
"createacct-benefit-head$benefitIdx" )->escaped()
540 $this->
msg(
"createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped()
544 $benefitsContainer =
Html::rawElement(
'div', [
'class' =>
'mw-createacct-benefits-container' ],
577 if ( isset( $this->authForm ) ) {
581 $usingHTTPS = $this->
getRequest()->getProtocol() ===
'https';
584 $fieldInfo = AuthenticationRequest::mergeFieldInfo( $requests );
588 $formDescriptor = static::fieldInfoToFormDescriptor( $requests, $fieldInfo, $this->authAction );
599 $form->addHiddenField(
'authAction', $this->authAction );
600 if ( $wgLoginLanguageSelector ) {
601 $form->addHiddenField(
'uselang', $this->mLanguage );
603 $form->addHiddenField(
'force', $this->securityLevel );
605 if ( $wgSecureLogin ) {
608 $form->addHiddenField(
'wpForceHttps', (
int)$this->mStickHTTPS );
609 $form->addHiddenField(
'wpFromhttp', $usingHTTPS );
615 $form->setName(
'userlogin' . ( $this->
isSignup() ?
'2' :
'' ) );
617 $form->setId(
'userlogin2' );
630 $statusAreaAttribs = [
'id' =>
'mw-createacct-status-area' ];
632 $form->addHeaderText(
Html::element(
'div', $statusAreaAttribs ) );
641 $signupendMsg = $this->
msg(
'signupend' );
642 $signupendHttpsMsg = $this->
msg(
'signupend-https' );
643 if ( !$signupendMsg->isDisabled() ) {
644 $signupendText = ( $usingHTTPS && !$signupendHttpsMsg->isBlank() )
645 ? $signupendHttpsMsg ->parse() : $signupendMsg->parse();
646 $form->addPostText(
Html::rawElement(
'div', [
'id' =>
'signupend' ], $signupendText ) );
652 $reauthMessage = $this->securityLevel ?
'userlogin-reauth' :
'userlogin-loggedin';
654 $this->
msg( $reauthMessage )->params( $this->
getUser()->
getName() )->parse() ) );
659 if ( $passwordReset->isAllowed( $this->getUser() ) ) {
662 [
'class' =>
'mw-ui-vform-field mw-form-related-link-container' ],
665 $this->
msg(
'userlogin-resetpassword-link' )->escaped()
676 if ( $wgLoginLanguageSelector && $this->mLanguage ) {
679 $createOrLoginHref = $linkTitle->getLocalURL( $linkq );
681 if ( $this->
getUser()->isLoggedIn() ) {
683 [
'class' =>
'mw-ui-vform-field' ],
686 'id' =>
'mw-createaccount-join',
687 'href' => $createOrLoginHref,
691 $this->
msg(
'userlogin-createanother' )->escaped()
696 [
'id' =>
'mw-createaccount-cta',
697 'class' =>
'mw-ui-vform-field' ],
698 $this->
msg(
'userlogin-noaccount' )->escaped()
701 'id' =>
'mw-createaccount-join',
702 'href' => $createOrLoginHref,
703 'class' =>
'mw-ui-button',
706 $this->
msg(
'userlogin-joinproject' )->escaped()
710 $form->addFooterText( $createOrLoginHtml );
714 $form->suppressDefaultSubmit();
716 $this->authForm = $form;
735 'mUsername' =>
$request->getText(
'wpName' ),
736 'mPassword' =>
$request->getText(
'wpPassword' ),
737 'mRetype' =>
$request->getText(
'wpRetype' ),
738 'mEmail' =>
$request->getText(
'wpEmail' ),
739 'mRealName' =>
$request->getText(
'wpRealName' ),
740 'mDomain' =>
$request->getText(
'wpDomain' ),
741 'mReason' =>
$request->getText(
'wpReason' ),
742 'mRemember' =>
$request->getCheck(
'wpRemember' ),
755 if ( $data->mUsername ==
'' && $this->isSignup() ) {
756 if (
$user->isLoggedIn() ) {
757 $data->mUsername =
$user->getName();
759 $data->mUsername = $this->
getRequest()->getSession()->suggestLoginUsername();
767 $q =
'action=submitlogin&type=signup';
768 $linkq =
'type=login';
770 $q =
'action=submitlogin&type=login';
771 $linkq =
'type=signup';
774 if ( $this->mReturnTo !==
'' ) {
775 $returnto =
'&returnto=' .
wfUrlencode( $this->mReturnTo );
776 if ( $this->mReturnToQuery !==
'' ) {
777 $returnto .=
'&returntoquery=' .
784 # Don't show a "create account" link if the user can't.
786 # Pass any language selection on to the mode switch link
787 if ( $wgLoginLanguageSelector && $this->mLanguage ) {
791 $template->set(
'createOrLoginHref', $titleObj->getLocalURL( $linkq ) );
798 : is_array( $wgPasswordResetRoutes )
799 && in_array(
true, array_values( $wgPasswordResetRoutes ),
true );
805 $template->set(
'name', $data->mUsername );
806 $template->set(
'password', $data->mPassword );
807 $template->set(
'retype', $data->mRetype );
808 $template->set(
'createemailset',
false );
809 $template->set(
'email', $data->mEmail );
810 $template->set(
'realname', $data->mRealName );
811 $template->set(
'domain', $data->mDomain );
812 $template->set(
'reason', $data->mReason );
813 $template->set(
'remember', $data->mRemember );
815 $template->set(
'action', $titleObj->getLocalURL( $q ) );
817 $template->set(
'messagetype', $msgType );
818 $template->set(
'createemail', $wgEnableEmail &&
$user->isLoggedIn() );
819 $template->set(
'userealname', !in_array(
'realname', $wgHiddenPrefs,
true ) );
820 $template->set(
'useemail', $wgEnableEmail );
821 $template->set(
'emailrequired', $wgEmailConfirmToEdit );
822 $template->set(
'emailothers', $wgEnableUserEmail );
823 $template->set(
'canreset', $wgAuth->allowPasswordChange() );
824 $template->set(
'resetlink', $resetLink );
826 ->getRememberUserDuration() !== null );
828 $template->set(
'cansecurelogin', ( $wgSecureLogin ) );
829 $template->set(
'stickhttps', (
int)$this->mStickHTTPS );
834 $action = $this->
isSignup() ?
'signup' :
'login';
835 $wgAuth->modifyUITemplate(
$template, $action );
838 $hookName = $this->
isSignup() ?
'UserCreateForm' :
'UserLoginForm';
852 $specialFields = array_merge( [
'extraInput',
'linkcontainer',
'entryError' ],
853 array_keys( $this->fakeTemplate->getExtraInputDefinitions() ) );
856 foreach ( $coreFieldDescriptors
as $fieldName => $coreField ) {
857 $requestField = isset( $formDescriptor[$fieldName] ) ?
858 $formDescriptor[$fieldName] : [];
863 !isset( $fieldInfo[$fieldName] )
865 !isset( $coreField[
'baseField'] )
866 || !isset( $fieldInfo[$coreField[
'baseField']] )
867 ) && !in_array( $fieldName, $specialFields,
true )
868 && ( !isset( $coreField[
'type'] ) || $coreField[
'type'] !==
'submit' )
870 $coreFieldDescriptors[$fieldName] = null;
876 isset( $coreField[
'label'] )
877 || isset( $coreField[
'label-message'] )
878 || isset( $coreField[
'label-raw'] )
880 unset( $requestField[
'label'], $requestField[
'label-message'], $coreField[
'label-raw'] );
883 $coreFieldDescriptors[$fieldName] += $requestField;
886 $formDescriptor = array_filter( $coreFieldDescriptors + $formDescriptor );
907 global $wgEmailConfirmToEdit;
909 $isLoggedIn = $this->
getUser()->isLoggedIn();
910 $continuePart = $this->
isContinued() ?
'continue-' :
'';
911 $anotherPart = $isLoggedIn ?
'another-' :
'';
912 $expiration = $this->
getRequest()->getSession()->getProvider()
913 ->getRememberUserDuration();
914 $expirationDays = ceil( $expiration / ( 3600 * 24 ) );
915 $secureLoginLink =
'';
916 if ( $this->mSecureLoginUrl ) {
918 'href' => $this->mSecureLoginUrl,
919 'class' =>
'mw-ui-flush-right mw-secure',
920 ], $this->
msg(
'userlogin-signwithsecure' )->
text() );
924 $fieldDefinitions = [
926 'label-message' =>
'userlogin-yourname',
928 'help-message' =>
'createacct-helpusername',
930 'placeholder-message' => $isLoggedIn ?
'createacct-another-username-ph'
931 :
'userlogin-yourname-ph',
936 'label-message' =>
'createaccountmail',
937 'name' =>
'wpCreateaccountMail',
938 'id' =>
'wpCreateaccountMail',
941 'id' =>
'wpPassword2',
942 'placeholder-message' =>
'createacct-yourpassword-ph',
943 'hide-if' => [
'===',
'wpCreateaccountMail',
'1' ],
947 'baseField' =>
'password',
948 'type' =>
'password',
949 'label-message' =>
'createacct-yourpasswordagain',
951 'cssclass' =>
'loginPassword',
953 'validation-callback' =>
function (
$value, $alldata ) {
954 if ( empty( $alldata[
'mailpassword'] ) && !empty( $alldata[
'password'] ) ) {
956 return $this->
msg(
'htmlform-required' );
957 } elseif (
$value !== $alldata[
'password'] ) {
958 return $this->
msg(
'badretype' );
963 'hide-if' => [
'===',
'wpCreateaccountMail',
'1' ],
964 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
968 'label-message' => $wgEmailConfirmToEdit ?
'createacct-emailrequired'
969 :
'createacct-emailoptional',
971 'cssclass' =>
'loginText',
974 'required' => $wgEmailConfirmToEdit,
975 'validation-callback' =>
function (
$value, $alldata ) {
976 global $wgEmailConfirmToEdit;
980 if ( !
$value && $wgEmailConfirmToEdit ) {
983 return $this->
msg(
'noemailtitle' );
984 } elseif ( !
$value && !empty( $alldata[
'mailpassword'] ) ) {
986 return $this->
msg(
'noemailcreate' );
988 return $this->
msg(
'invalidemailaddress' );
992 'placeholder-message' =>
'createacct-' . $anotherPart .
'email-ph',
996 'help-message' => $isLoggedIn ?
'createacct-another-realname-tip'
997 :
'prefs-help-realname',
998 'label-message' =>
'createacct-realname',
999 'cssclass' =>
'loginText',
1001 'id' =>
'wpRealName',
1006 'label-message' =>
'createacct-reason',
1007 'cssclass' =>
'loginText',
1010 'placeholder-message' =>
'createacct-reason-ph',
1013 'createaccount' => [
1016 'default' => $this->
msg(
'createacct-' . $anotherPart . $continuePart .
1018 'name' =>
'wpCreateaccount',
1019 'id' =>
'wpCreateaccount',
1024 $fieldDefinitions = [
1026 'label-raw' => $this->
msg(
'userlogin-yourname' )->escaped() . $secureLoginLink,
1028 'placeholder-message' =>
'userlogin-yourname-ph',
1031 'id' =>
'wpPassword1',
1032 'placeholder-message' =>
'userlogin-yourpassword-ph',
1039 'name' =>
'wpRemember',
1040 'label-message' => $this->
msg(
'userlogin-remembermypassword' )
1041 ->numParams( $expirationDays ),
1042 'id' =>
'wpRemember',
1047 'default' => $this->
msg(
'pt-login-' . $continuePart .
'button' )->text(),
1048 'id' =>
'wpLoginAttempt',
1051 'linkcontainer' => [
1054 'cssclass' =>
'mw-form-related-link-container mw-userlogin-help',
1059 ->inContentLanguage()
1061 ], $this->
msg(
'userlogin-helplink2' )->
text() ),
1071 $fieldDefinitions[
'username'] += [
1074 'cssclass' =>
'loginText',
1078 $fieldDefinitions[
'password'] += [
1079 'type' =>
'password',
1081 'name' =>
'wpPassword',
1082 'cssclass' =>
'loginPassword',
1087 if ( $this->mEntryError ) {
1088 $fieldDefinitions[
'entryError'] = [
1090 'default' =>
Html::rawElement(
'div', [
'class' => $this->mEntryErrorType .
'box', ],
1091 $this->mEntryError ),
1099 unset( $fieldDefinitions[
'linkcontainer'] );
1103 $fieldDefinitions = array_filter( $fieldDefinitions );
1105 return $fieldDefinitions;
1115 if (
$template->get(
'usedomain',
false ) ) {
1117 $fieldDefinitions[
'domain'] = [
1119 'label-message' =>
'yourdomainname',
1120 'options' => array_combine(
$template->get(
'domainnames', [] ),
1122 'default' =>
$template->get(
'domain',
'' ),
1123 'name' =>
'wpDomain',
1129 $extraInputPos = array_search(
'extrainput', array_keys( $fieldDefinitions ),
true );
1130 $fieldDefinitions = array_slice( $fieldDefinitions, 0, $extraInputPos,
true )
1132 + array_slice( $fieldDefinitions, $extraInputPos + 1, null,
true );
1134 return $fieldDefinitions;
1149 return $wgDisableCookieCheck || (
1150 $wgInitialSessionId &&
1161 if ( $this->mReturnTo !==
'' ) {
1162 $returnto =
'returnto=' .
wfUrlencode( $this->mReturnTo );
1163 if ( $this->mReturnToQuery !==
'' ) {
1164 $returnto .=
'&returntoquery=' .
wfUrlencode( $this->mReturnToQuery );
1178 } elseif ( $this->
getUser()->isAllowed(
'createaccount' ) ) {
1186 return $this->
isSignup() ?
'wpCreateaccountToken' :
'wpLoginToken';
1196 $msg = $this->
msg(
'loginlanguagelinks' )->inContentLanguage();
1197 if ( $msg->isBlank() ) {
1200 $langs = explode(
"\n", $msg->text() );
1203 $lang = trim( $lang,
'* ' );
1204 $parts = explode(
'|', $lang );
1205 if ( count( $parts ) >= 2 ) {
1210 return count( $links ) > 0 ? $this->
msg(
'loginlanguagelabel' )->rawParams(
1211 $this->
getLanguage()->pipeList( $links ) )->escaped() :
'';
1225 return htmlspecialchars( $text );
1228 if ( $this->mReturnTo !==
'' ) {
1235 $attr[
'lang'] = $attr[
'hreflang'] = $targetLanguage->getHtmlCode();
1239 htmlspecialchars( $text ),
1255 isset( $formDescriptor[
'username'] ) &&
1256 !isset( $formDescriptor[
'username'][
'default'] ) &&
1260 if (
$user->isLoggedIn() ) {
1261 $formDescriptor[
'username'][
'default'] =
$user->getName();
1263 $formDescriptor[
'username'][
'default'] =
1264 $this->
getRequest()->getSession()->suggestLoginUsername();
1271 unset( $formDescriptor[
'createaccount'], $formDescriptor[
'loginattempt'] );
1278 isset( $formDescriptor[
'username'] )
1279 && empty( $formDescriptor[
'username'][
'default'] )
1280 && !$this->
getRequest()->getCheck(
'wpName' )
1282 $formDescriptor[
'username'][
'autofocus'] =
true;
1283 } elseif ( isset( $formDescriptor[
'password'] ) ) {
1284 $formDescriptor[
'password'][
'autofocus'] =
true;
1309 $this->
data[
'extrainput'][] = [
1314 'helptext' => $helptext,
1325 foreach ( $this->
get(
'extrainput', [] )
as $field ) {
1327 'type' => $field[
'type'] ===
'checkbox' ?
'check' : $field[
'type'],
1328 'name' => $field[
'name'],
1329 'value' => $field[
'value'],
1330 'id' => $field[
'name'],
1332 if ( $field[
'msg'] ) {
1333 $definition[
'label-message'] = $this->
getMsg( $field[
'msg'] );
1335 if ( $field[
'helptext'] ) {
1336 $definition[
'help'] = $this->
msgWiki( $field[
'helptext'] );
1341 $name = preg_replace(
'/^wp(?=[A-Z])/',
'', $field[
'name'] );
1342 $definitions[
$name] = $definition;
1345 if ( $this->
haveData(
'extrafields' ) ) {
1346 $definitions[
'extrafields'] = [
1349 'default' => $this->
get(
'extrafields' ),
1353 return $definitions;
1380 self::SUCCESS =>
'success',
1381 self::NO_NAME =>
'no_name',
1382 self::ILLEGAL =>
'illegal',
1383 self::WRONG_PLUGIN_PASS =>
'wrong_plugin_pass',
1384 self::NOT_EXISTS =>
'not_exists',
1386 self::EMPTY_PASS =>
'empty_pass',
1387 self::RESET_PASS =>
'reset_pass',
1388 self::ABORTED =>
'aborted',
1389 self::CREATE_BLOCKED =>
'create_blocked',
1390 self::THROTTLED =>
'throttled',
1391 self::USER_BLOCKED =>
'user_blocked',
1392 self::NEED_TOKEN =>
'need_token',
1393 self::WRONG_TOKEN =>
'wrong_token',
1394 self::USER_MIGRATED =>
'user_migrated',
1402 parent::__construct();
1420 return $throttler->increase(
$username, $wgRequest->getIP(), __METHOD__ );
1429 return is_array(
$res ) ?
true : 0;
1440 return $throttler->clear(
$username, $wgRequest->getIP() );
1449 return $wgRequest->getSession()->getToken(
'',
'login' )->toString();
1465 $wgRequest->getSession()->resetToken(
'login' );
1474 return $wgRequest->getSession()->getToken(
'',
'createaccount' )->toString();
1490 $wgRequest->getSession()->resetToken(
'createaccount' );
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
setSessionUserForCurrentRequest()
Replace some globals to make sure the fact that the user has just been logged in is reflected in the ...
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
FakeAuthTemplate $fakeTemplate
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
the array() calling protocol came about after MediaWiki 1.4rc1.
getAuthForm(array $requests, $action, $msg= '', $msgType= 'error')
Generates a form from the given request.
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
wfCanIPUseHTTPS($ip)
Determine whether the client at a given source IP is likely to be able to access the wiki via HTTPS...
static wrap($sv)
Succinct helper method to wrap a StatusValue.
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
A special page subclass for authentication-related special pages.
getContext()
Gets the context this SpecialPage is executed in.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string & $returnToQuery
makeLanguageSelectorLink($text, $lang)
Create a language selector link for a particular language Links back to this page preserving type and...
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name.
static getCanonicalName($name, $validate= 'valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid...
getFakeTemplate($msg, $msgType)
Temporary B/C method to handle extensions using the UserLoginForm/UserCreateForm hooks.
makeLanguageSelector()
Produce a bar of links which allow the user to select another language during login/registration but ...
needsSubmitButton($formDescriptor)
Returns true if the form has fields which take values.
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
if(!isset($args[0])) $lang
An IContextSource implementation which will inherit context from another source but allow individual ...
hasSessionCookie()
Check if a session cookie is present.
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
New base template for a skin's template extended from QuickTemplate this class features helper method...
getToken()
Returns the CSRF token.
mainLoginForm(array $requests, $msg= '', $msgtype= 'error')
msg()
Wrapper around wfMessage that sets the current context.
User $targetUser
FIXME another flag for passing data.
get($name, $default=null)
Gets the template data requested.
getOutput()
Get the OutputPage being used for this instance.
wfUrlencode($s)
We want some things to be included as literal characters in our title URLs for prettiness, which urlencode encodes by default.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
this hook is for auditing only $response
when a variable name is used in a it is silently declared as a new local masking the global
Holds shared logic for login and account creation pages.
static newFatal($message)
Factory function for fatal errors.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
showExtraInformation()
Show extra information such as password recovery information, link from login to signup, CTA etc? Such information should only be shown on the "landing page", ie.
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
showSuccessPage($type, $title, $msgname, $injected_html, $extraMessages)
Show the success page.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping $template
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
$wgLoginLanguageSelector
Show a bar of language selection links in the user login and user registration forms; edit the "login...
isActionAllowed($action)
Checks whether AuthManager is ready to perform the action.
Parent class for all special pages.
isContinued()
Returns true if this is not the first step of the authentication.
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
getContinueAction($action)
Gets the _CONTINUE version of an action.
static getMain()
Static methods.
getMsg($name)
Get a Message object with its context set.
logAuthResult($success, $status=null)
Logs to the authmanager-stats channel.
addTabIndex(&$formDescriptor)
Adds a sequential tabindex starting from 1 to all form elements.
getExtraInputDefinitions()
Turns addInputItem-style field definitions into HTMLForm field definitions.
wfAppendQuery($url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
An error page which can definitely be safely rendered using the OutputPage.
loadRequestParameters($subPage)
Load basic request parameters for this Special page.
getBCFieldDefinitions($fieldDefinitions, $template)
Adds fields provided via the deprecated UserLoginForm / UserCreateForm hooks.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation 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 unsetoffset-wrap String Wrap the message in html(usually something like"<
B/C class to try handling login/signup template modifications even though login/signup does not actua...
getSkin()
Shortcut to get the skin being used for this instance.
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead.&$feedLinks hooks can tweak the array to change how login etc forms should look $requests
namespace and then decline to actually register it file or subcat img or subcat $title
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
$wgEnableUserEmail
Set to true to enable user-to-user e-mail.
Helper functions for the login form that need to be shared with other special pages (such as CentralA...
getFieldDefinitions($template)
Create a HTMLForm descriptor for the core login fields.
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
loadAuth($subPage, $authAction=null, $reset=false)
Load or initialize $authAction, $authRequests and $subPage.
Helper class for the password reset functionality shared by the web UI and the API.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
setRequest(array $data, $wasPosted=null)
showReturnToPage($type, $returnTo= '', $returnToQuery= '', $stickHTTPS=false)
Add a "return to" link or redirect to it.
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
this hook is for auditing only or null if authentication failed before getting that far $username
error also a ContextSource you ll probably need to make sure the header is varied on $request
getName()
Get the name of this Special Page.
bool $proxyAccountCreation
True if the user if creating an account for someone else.
getPageHtml($formHtml)
Add page elements which are outside the form.
getDefaultAction($subPage)
Get the default action for this special page, if none is given via URL/POST data. ...
getUser()
Shortcut to get the User executing this instance.
getConfig()
Shortcut to get main config object.
this hook is for auditing only WRONG_PASS
static getValidErrorMessages()
Returns an array of all valid error messages.
getLanguage()
Shortcut to get user's language.
load($subPage)
Load data from request.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method.MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances.The"Spi"in MediaWiki\Logger\Spi stands for"service provider interface".An SPI is an API intended to be implemented or extended by a third party.This software design pattern is intended to enable framework extension and replaceable components.It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki.The service provider interface allows the backend logging library to be implemented in multiple ways.The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime.This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance.Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
static makeInternalOrExternalUrl($name)
If url string starts with http, consider as external URL, else internal.
getFullTitle()
Return the full title, including $par.
static validateEmail($addr)
Does a string look like an e-mail address?
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
postProcessFormDescriptor(&$formDescriptor)
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect & $returnTo
static factory($code)
Get a cached or new language object for a given language code.
showCreateAccountLink()
Whether the login/create account form should display a link to the other form (in addition to whateve...
string $subPage
Subpage of the special page.
getPreservedParams($withToken=false)
static element($element, $attribs=[], $contents= '')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
successfulAction($direct=false, $extraMessages=null)
setContext($context)
Sets the context this SpecialPage is executed in.
if(is_null($wgLocalTZoffset)) if(!$wgDBerrorLogTZ) $wgRequest
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
getReturnToQueryStringFragment()
Returns a string that can be appended to the URL (without encoding) to preserve the return target...
addInputItem($name, $value, $type, $msg, $helptext=false)
Extensions (AntiSpoof and TitleBlacklist) call this in response to UserCreateForm hook to add checkbo...
getPageTitle($subpage=false)
Get a self-referential title object.
Allows to change the fields on the form that will be generated $name
trySubmit()
Attempts to do an authentication step with the submitted data.