r62673 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62672‎ | r62673 | r62674 >
Date:14:53, 18 February 2010
Author:ashley
Status:ok
Tags:
Comment:
API login module: coding style cleanup, remove stray semicolon, use proper copyright symbol
Modified paths:
  • /trunk/phase3/includes/api/ApiLogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiLogin.php
@@ -1,11 +1,11 @@
22 <?php
33
4 -/*
 4+/**
55 * Created on Sep 19, 2006
66 *
77 * API for MediaWiki 1.8+
88 *
9 - * Copyright (C) 2006-2007 Yuri Astrakhan <Firstname><Lastname>@gmail.com,
 9+ * Copyright © 2006-2007 Yuri Astrakhan <Firstname><Lastname>@gmail.com,
1010 * Daniel Cannon (cannon dot danielc at gmail dot com)
1111 *
1212 * This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,7 @@
2727
2828 if ( !defined( 'MEDIAWIKI' ) ) {
2929 // Eclipse helper - will be ignored in production
30 - require_once ( 'ApiBase.php' );
 30+ require_once( 'ApiBase.php' );
3131 }
3232
3333 /**
@@ -37,7 +37,7 @@
3838 class ApiLogin extends ApiBase {
3939
4040 public function __construct( $main, $action ) {
41 - parent :: __construct( $main, $action, 'lg' );
 41+ parent::__construct( $main, $action, 'lg' );
4242 }
4343
4444 /**
@@ -48,15 +48,13 @@
4949 * user, or any other reason, the host is cached with an expiry
5050 * and no log-in attempts will be accepted until that expiry
5151 * is reached. The expiry is $this->mLoginThrottle.
52 - *
53 - * @access public
5452 */
5553 public function execute() {
5654 $params = $this->extractRequestParams();
5755
58 - $result = array ();
 56+ $result = array();
5957
60 - $req = new FauxRequest( array (
 58+ $req = new FauxRequest( array(
6159 'wpName' => $params['name'],
6260 'wpPassword' => $params['password'],
6361 'wpDomain' => $params['domain'],
@@ -70,7 +68,7 @@
7169
7270 $loginForm = new LoginForm( $req );
7371 switch ( $authRes = $loginForm->authenticateUserData() ) {
74 - case LoginForm :: SUCCESS :
 72+ case LoginForm::SUCCESS:
7573 global $wgUser, $wgCookiePrefix;
7674
7775 $wgUser->setOption( 'rememberpassword', 1 );
@@ -89,48 +87,48 @@
9088 $result['sessionid'] = session_id();
9189 break;
9290
93 - case LoginForm :: NO_NAME :
 91+ case LoginForm::NO_NAME:
9492 $result['result'] = 'NoName';
9593 break;
9694
97 - case LoginForm :: ILLEGAL :
 95+ case LoginForm::ILLEGAL:
9896 $result['result'] = 'Illegal';
9997 break;
10098
101 - case LoginForm :: WRONG_PLUGIN_PASS :
 99+ case LoginForm::WRONG_PLUGIN_PASS:
102100 $result['result'] = 'WrongPluginPass';
103101 break;
104102
105 - case LoginForm :: NOT_EXISTS :
 103+ case LoginForm::NOT_EXISTS:
106104 $result['result'] = 'NotExists';
107105 break;
108 -
109 - case LoginForm :: RESET_PASS : // bug 20223 - Treat a temporary password as wrong. Per SpecialUserLogin - "The e-mailed temporary password should not be used for actual logins;"
110 - case LoginForm :: WRONG_PASS :
 106+
 107+ case LoginForm::RESET_PASS: // bug 20223 - Treat a temporary password as wrong. Per SpecialUserLogin - "The e-mailed temporary password should not be used for actual logins;"
 108+ case LoginForm::WRONG_PASS:
111109 $result['result'] = 'WrongPass';
112110 break;
113111
114 - case LoginForm :: EMPTY_PASS :
 112+ case LoginForm::EMPTY_PASS:
115113 $result['result'] = 'EmptyPass';
116114 break;
117115
118 - case LoginForm :: CREATE_BLOCKED :
 116+ case LoginForm::CREATE_BLOCKED:
119117 $result['result'] = 'CreateBlocked';
120118 $result['details'] = 'Your IP address is blocked from account creation';
121119 break;
122120
123 - case LoginForm :: THROTTLED :
 121+ case LoginForm::THROTTLED:
124122 global $wgPasswordAttemptThrottle;
125123 $result['result'] = 'Throttled';
126124 $result['wait'] = intval( $wgPasswordAttemptThrottle['seconds'] );
127125 break;
128 -
129 - case LoginForm :: USER_BLOCKED :
 126+
 127+ case LoginForm::USER_BLOCKED:
130128 $result['result'] = 'Blocked';
131129 break;
132130
133 - default :
134 - ApiBase :: dieDebug( __METHOD__, "Unhandled case value: {$authRes}" );
 131+ default:
 132+ ApiBase::dieDebug( __METHOD__, "Unhandled case value: {$authRes}" );
135133 }
136134
137135 $this->getResult()->addValue( null, 'login', $result );
@@ -145,7 +143,7 @@
146144 }
147145
148146 public function getAllowedParams() {
149 - return array (
 147+ return array(
150148 'name' => null,
151149 'password' => null,
152150 'domain' => null
@@ -153,7 +151,7 @@
154152 }
155153
156154 public function getParamDescription() {
157 - return array (
 155+ return array(
158156 'name' => 'User Name',
159157 'password' => 'Password',
160158 'domain' => 'Domain (optional)'
@@ -161,7 +159,7 @@
162160 }
163161
164162 public function getDescription() {
165 - return array (
 163+ return array(
166164 'This module is used to login and get the authentication tokens. ',
167165 'In the event of a successful log-in, a cookie will be attached',
168166 'to your session. In the event of a failed log-in, you will not ',
@@ -169,9 +167,9 @@
170168 'This is to prevent password guessing by automated password crackers.'
171169 );
172170 }
173 -
 171+
174172 public function getPossibleErrors() {
175 - return array_merge( parent::getPossibleErrors(), array (
 173+ return array_merge( parent::getPossibleErrors(), array(
176174 array( 'code' => 'NoName', 'info' => 'You didn\'t set the lgname parameter' ),
177175 array( 'code' => 'Illegal', 'info' => ' You provided an illegal username' ),
178176 array( 'code' => 'NotExists', 'info' => ' The username you provided doesn\'t exist' ),
@@ -181,8 +179,7 @@
182180 array( 'code' => 'CreateBlocked', 'info' => 'The wiki tried to automatically create a new account for you, but your IP address has been blocked from account creation' ),
183181 array( 'code' => 'Throttled', 'info' => 'You\'ve logged in too many times in a short time' ),
184182 array( 'code' => 'Blocked', 'info' => 'User is blocked' ),
185 - ) );
186 -;
 183+ ) );
187184 }
188185
189186 protected function getExamples() {

Status & tagging log