+
+ /**
+ * Redirect to Special:Userlogin if the specified message is compatible. Otherwise,
+ * show an error page as usual.
+ */
+ 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::getValidErrorMessages() ) ) {
+ parent::report();
+ }
+
+ // Message is valid. Redirec to Special:Userlogin
+
+ $context = RequestContext::getMain();
+
+ $output = $context->getOutput();
+ $query = $context->getRequest()->getValues();
+ // Title will be overridden by returnto
+ unset( $query['title'] );
+ // Redirect to Special:Userlogin
+ $output->redirect( SpecialPage::getTitleFor( 'Userlogin' )->getFullURL( array(
+ // Return to this page when the user logs in
+ 'returnto' => $context->getTitle()->getFullText(),
+ 'returntoquery' => wfArrayToCgi( $query ),
+ 'warning' => $this->msg,
+ ) ) );
+
+ $output->output();
+ }