Merge "Add missing @param and @return documentation"
[lhc/web/wiklou.git] / includes / specialpage / LoginSignupSpecialPage.php
index 0600642..04d391b 100644 (file)
@@ -26,7 +26,9 @@ use MediaWiki\Auth\AuthenticationResponse;
 use MediaWiki\Auth\AuthManager;
 use MediaWiki\Auth\Throttler;
 use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
 use MediaWiki\Session\SessionManager;
+use Wikimedia\ScopedCallback;
 
 /**
  * Holds shared logic for login and account creation pages.
@@ -96,7 +98,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
 
        /**
         * Load basic request parameters for this Special page.
-        * @param $subPage
+        * @param string $subPage
         */
        private function loadRequestParameters( $subPage ) {
                if ( $this->mLoadedRequest ) {
@@ -212,6 +214,15 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
         * @param string|null $subPage
         */
        public function execute( $subPage ) {
+               if ( $this->mPosted ) {
+                       $time = microtime( true );
+                       $profilingScope = new ScopedCallback( function () use ( $time ) {
+                               $time = microtime( true ) - $time;
+                               $statsd = MediaWikiServices::getInstance()->getStatsdDataFactory();
+                               $statsd->timing( "timing.login.ui.{$this->authAction}", $time * 1000 );
+                       } );
+               }
+
                $authManager = AuthManager::singleton();
                $session = SessionManager::getGlobalSession();
 
@@ -1145,7 +1156,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
                        // Don't show a "create account" link if the user can't.
                        if ( $this->showCreateAccountLink() ) {
                                // link to the other action
-                               $linkTitle = $this->getTitleFor( $this->isSignup() ? 'Userlogin' :'CreateAccount' );
+                               $linkTitle = $this->getTitleFor( $this->isSignup() ? 'Userlogin' : 'CreateAccount' );
                                $linkq = $this->getReturnToQueryStringFragment();
                                // Pass any language selection on to the mode switch link
                                if ( $this->mLanguage ) {
@@ -1188,7 +1199,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
 
        /**
         * Adds fields provided via the deprecated UserLoginForm / UserCreateForm hooks
-        * @param $fieldDefinitions array
+        * @param array $fieldDefinitions
         * @param FakeAuthTemplate $template
         * @return array
         */
@@ -1236,6 +1247,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
        /**
         * Returns a string that can be appended to the URL (without encoding) to preserve the
         * return target. Does not include leading '?'/'&'.
+        * @return string
         */
        protected function getReturnToQueryStringFragment() {
                $returnto = '';
@@ -1328,7 +1340,8 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
        }
 
        /**
-        * @param array $formDescriptor
+        * @param array &$formDescriptor
+        * @param array $requests
         */
        protected function postProcessFormDescriptor( &$formDescriptor, $requests ) {
                // Pre-fill username (if not creating an account, T46775).
@@ -1384,6 +1397,11 @@ class FakeAuthTemplate extends BaseTemplate {
        /**
         * Extensions (AntiSpoof and TitleBlacklist) call this in response to
         * UserCreateForm hook to add checkboxes to the create account form.
+        * @param string $name
+        * @param string $value
+        * @param string $type
+        * @param string $msg
+        * @param string|bool $helptext
         */
        public function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
                // use the same indexes as UserCreateForm just in case someone adds an item manually
@@ -1485,6 +1503,7 @@ class LoginForm extends SpecialPage {
 
        /**
         * @deprecated since 1.27 - call LoginHelper::getValidErrorMessages instead.
+        * @return array
         */
        public static function getValidErrorMessages() {
                return LoginHelper::getValidErrorMessages();
@@ -1492,6 +1511,8 @@ class LoginForm extends SpecialPage {
 
        /**
         * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
+        * @param string $username
+        * @return array|false
         */
        public static function incrementLoginThrottle( $username ) {
                wfDeprecated( __METHOD__, "1.27" );
@@ -1503,6 +1524,8 @@ class LoginForm extends SpecialPage {
 
        /**
         * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
+        * @param string $username
+        * @return bool|int
         */
        public static function incLoginThrottle( $username ) {
                wfDeprecated( __METHOD__, "1.27" );
@@ -1512,6 +1535,8 @@ class LoginForm extends SpecialPage {
 
        /**
         * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
+        * @param string $username
+        * @return void
         */
        public static function clearLoginThrottle( $username ) {
                wfDeprecated( __METHOD__, "1.27" );
@@ -1548,6 +1573,7 @@ class LoginForm extends SpecialPage {
 
        /**
         * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
+        * @return string
         */
        public static function getCreateaccountToken() {
                wfDeprecated( __METHOD__, '1.27' );