$to: Array of MailAddress objects for the recipients
&$returnPath: The return address string
+'LoginFormValidErrorMessages': Called in LoginForm when a function gets valid error
+messages. Allows to add additional error messages (except messages already in
+LoginForm::$validErrorMessages).
+&$messages Already added messages (inclusive messages from LoginForm::$validErrorMessages)
+
'WantedPages::getQueryInfo': Called in WantedPagesPage::getQueryInfo(), can be
used to alter the SQL query which gets the list of wanted pages.
&$wantedPages: WantedPagesPage object
* 'exception-nologin' as a title and 'exception-nologin-text' for the message.
*
* @note In order for this exception to redirect, the error message passed to the
- * constructor has to be explicitly added to LoginForm::validErrorMessages. Otherwise,
- * the user will just be shown the message rather than redirected.
+ * constructor has to be explicitly added to LoginForm::validErrorMessages or with
+ * the LoginFormValidErrorMessages hook. Otherwise, the user will just be shown the message
+ * rather than redirected.
*
* @par Example:
* @code
class UserNotLoggedIn extends ErrorPageError {
/**
- * @note The value of the $reasonMsg parameter must be put into LoginForm::validErrorMessages
+ * @note The value of the $reasonMsg parameter must be put into LoginForm::validErrorMessages or
+ * set with the LoginFormValidErrorMessages Hook.
* if you want the user to be automatically redirected to the login form.
*
* @param string $reasonMsg A message key containing the reason for the error.
public function report() {
// If an unsupported message is used, don't try redirecting to Special:Userlogin,
// since the message may not be compatible.
- if ( !in_array( $this->msg, LoginForm::$validErrorMessages ) ) {
+ if ( !in_array( $this->msg, LoginForm::getValidErrorMessages() ) ) {
parent::report();
}
$wgUseMediaWikiUIEverywhere = true;
}
+ /**
+ * Returns an array of all valid error messages.
+ *
+ * @return array
+ */
+ public static function getValidErrorMessages() {
+ static $messages = null;
+ if ( !$messages ) {
+ $messages = self::$validErrorMessages;
+ wfRunHooks( 'LoginFormValidErrorMessages', array( &$messages ) );
+ }
+
+ return $messages;
+ }
+
/**
* Loader
*/
// Only show valid error or warning messages.
if ( $entryError->exists()
- && in_array( $entryError->getKey(), self::$validErrorMessages )
+ && in_array( $entryError->getKey(), self::getValidErrorMessages() )
) {
$this->mEntryErrorType = 'error';
$this->mEntryError = $entryError->rawParams( $loginreqlink )->escaped();
} elseif ( $entryWarning->exists()
- && in_array( $entryWarning->getKey(), self::$validErrorMessages )
+ && in_array( $entryWarning->getKey(), self::getValidErrorMessages() )
) {
$this->mEntryErrorType = 'warning';
$this->mEntryError = $entryWarning->rawParams( $loginreqlink )->escaped();