Merge "+Test for Status->CleanParams with a callback"
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogin.php
index d071e75..eca1839 100644 (file)
@@ -318,7 +318,7 @@ class LoginForm extends SpecialPage {
                        # Confirm that the account was created
                        $out->setPageTitle( $this->msg( 'accountcreated' ) );
                        $out->addWikiMsg( 'accountcreatedtext', $u->getName() );
-                       $out->addReturnTo( $this->getTitle() );
+                       $out->addReturnTo( $this->getPageTitle() );
                        wfRunHooks( 'AddNewAccount', array( $u, false ) );
                        $u->addNewUserLogEntry( 'create2', $this->mReason );
                }
@@ -390,7 +390,7 @@ class LoginForm extends SpecialPage {
                }
 
                # Include checks that will include GlobalBlocking (Bug 38333)
-               $permErrors = $this->getTitle()->getUserPermissionsErrors( 'createaccount', $currentUser, true );
+               $permErrors = $this->getPageTitle()->getUserPermissionsErrors( 'createaccount', $currentUser, true );
                if ( count( $permErrors ) ) {
                                throw new PermissionsError( 'createaccount', $permErrors );
                }
@@ -444,12 +444,23 @@ class LoginForm extends SpecialPage {
                $u->setRealName( $this->mRealName );
 
                $abortError = '';
-               if ( !wfRunHooks( 'AbortNewAccount', array( $u, &$abortError ) ) ) {
+               $abortStatus = null;
+               if ( !wfRunHooks( 'AbortNewAccount', array( $u, &$abortError, &$abortStatus ) ) ) {
                        // Hook point to add extra creation throttles and blocks
                        wfDebug( "LoginForm::addNewAccountInternal: a hook blocked creation\n" );
-                       $abortError = new RawMessage( $abortError );
-                       $abortError->text();
-                       return Status::newFatal( $abortError );
+                       if ( $abortStatus === null ) {
+                               // Report back the old string as a raw message status.
+                               // This will report the error back as 'createaccount-hook-aborted'
+                               // with the given string as the message.
+                               // To return a different error code, return a Status object.
+                               $abortError = new Message( 'createaccount-hook-aborted', array( $abortError ) );
+                               $abortError->text();
+                               return Status::newFatal( $abortError );
+                       } else {
+                               // For MediaWiki 1.23+ and updated hooks, return the Status object
+                               // returned from the hook.
+                               return $abortStatus;
+                       }
                }
 
                // Hook point to check for exempt from account creation throttle
@@ -856,7 +867,9 @@ class LoginForm extends SpecialPage {
        function resetLoginForm( $error ) {
                $this->getOutput()->addHTML( Xml::element( 'p', array( 'class' => 'error' ), $error ) );
                $reset = new SpecialChangePassword();
-               $reset->setContext( $this->getContext() );
+               $derivative = new DerivativeContext( $this->getContext() );
+               $derivative->setTitle( $reset->getPageTitle() );
+               $reset->setContext( $derivative );
                $reset->execute( null );
        }
 
@@ -1075,7 +1088,7 @@ class LoginForm extends SpecialPage {
                global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration;
                global $wgSecureLogin, $wgPasswordResetRoutes;
 
-               $titleObj = $this->getTitle();
+               $titleObj = $this->getPageTitle();
                $user = $this->getUser();
                $out = $this->getOutput();
 
@@ -1296,7 +1309,7 @@ class LoginForm extends SpecialPage {
         */
        public static function setLoginToken() {
                global $wgRequest;
-               // Generate a token directly instead of using $user->editToken()
+               // Generate a token directly instead of using $user->getEditToken()
                // because the latter reuses $_SESSION['wsEditToken']
                $wgRequest->setSessionData( 'wsLoginToken', MWCryptRand::generateHex( 32 ) );
        }
@@ -1431,7 +1444,7 @@ class LoginForm extends SpecialPage {
                $attr['lang'] = $attr['hreflang'] = $targetLanguage->getHtmlCode();
 
                return Linker::linkKnown(
-                       $this->getTitle(),
+                       $this->getPageTitle(),
                        htmlspecialchars( $text ),
                        $attr,
                        $query