Index: trunk/phase3/includes/api/ApiLogin.php |
— | — | @@ -72,15 +72,9 @@ |
73 | 73 | $name = $password = $domain = null; |
74 | 74 | extract($this->extractRequestParams()); |
75 | 75 | |
76 | | - $params = new FauxRequest(array ( |
77 | | - 'wpName' => $name, |
78 | | - 'wpPassword' => $password, |
79 | | - 'wpDomain' => $domain, |
80 | | - 'wpRemember' => '' |
81 | | - )); |
82 | | - |
83 | 76 | $result = array (); |
84 | 77 | |
| 78 | + // Make sure noone is trying to guess the password brut-force |
85 | 79 | $nextLoginIn = $this->getNextLoginTimeout(); |
86 | 80 | if ($nextLoginIn > 0) { |
87 | 81 | $result['result'] = 'NeedToWait'; |
— | — | @@ -90,6 +84,13 @@ |
91 | 85 | return; |
92 | 86 | } |
93 | 87 | |
| 88 | + $params = new FauxRequest(array ( |
| 89 | + 'wpName' => $name, |
| 90 | + 'wpPassword' => $password, |
| 91 | + 'wpDomain' => $domain, |
| 92 | + 'wpRemember' => '' |
| 93 | + )); |
| 94 | + |
94 | 95 | $loginForm = new LoginForm($params); |
95 | 96 | switch ($loginForm->authenticateUserData()) { |
96 | 97 | case LoginForm :: SUCCESS : |
— | — | @@ -179,9 +180,8 @@ |
180 | 181 | |
181 | 182 | $elapse = (time() - $val['lastReqTime']) / 1000; // in seconds |
182 | 183 | $canRetryIn = ApiLogin::calculateDelay($val) - $elapse; |
183 | | - $canRetryIn = $canRetryIn < 0 ? 0 : $canRetryIn; |
184 | 184 | |
185 | | - return $canRetryIn; |
| 185 | + return $canRetryIn < 0 ? 0 : $canRetryIn; |
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -179,7 +179,12 @@ |
180 | 180 | |
181 | 181 | // Printer may not be initialized if the extractRequestParams() fails for the main module |
182 | 182 | if (!isset ($this->mPrinter)) { |
183 | | - $this->mPrinter = $this->createPrinterByName(self :: API_DEFAULT_FORMAT); |
| 183 | + // The printer has not been created yet. Try to manually get formatter value. |
| 184 | + $value = $this->getRequest()->getVal('format', self::API_DEFAULT_FORMAT); |
| 185 | + if (!in_array($value, $this->mFormatNames)) |
| 186 | + $value = self::API_DEFAULT_FORMAT; |
| 187 | + |
| 188 | + $this->mPrinter = $this->createPrinterByName($value); |
184 | 189 | if ($this->mPrinter->getNeedsRawData()) |
185 | 190 | $this->getResult()->setRawMode(); |
186 | 191 | } |
— | — | @@ -190,7 +195,10 @@ |
191 | 196 | // |
192 | 197 | $errMessage = array ( |
193 | 198 | 'code' => $e->getCodeString(), 'info' => $e->getMessage()); |
194 | | - ApiResult :: setContent($errMessage, $this->makeHelpMsg()); |
| 199 | + |
| 200 | + // Only print the help message when this is for the developer, not runtime |
| 201 | + if ($this->mPrinter->getIsHtml()) |
| 202 | + ApiResult :: setContent($errMessage, $this->makeHelpMsg()); |
195 | 203 | |
196 | 204 | } else { |
197 | 205 | // |
— | — | @@ -235,9 +243,11 @@ |
236 | 244 | * Execute the actual module, without any error handling |
237 | 245 | */ |
238 | 246 | protected function executeAction() { |
239 | | - $action = $format = $version = null; |
240 | | - extract($this->extractRequestParams()); |
241 | | - $this->mShowVersions = $version; |
| 247 | + |
| 248 | + $params = $this->extractRequestParams(); |
| 249 | + |
| 250 | + $this->mShowVersions = $params['version']; |
| 251 | + $action = $params['action']; |
242 | 252 | |
243 | 253 | // Instantiate the module requested by the user |
244 | 254 | $module = new $this->mModules[$action] ($this, $action); |
— | — | @@ -248,7 +258,7 @@ |
249 | 259 | $this->mPrinter = $module->getCustomPrinter(); |
250 | 260 | if (is_null($this->mPrinter)) { |
251 | 261 | // Create an appropriate printer |
252 | | - $this->mPrinter = $this->createPrinterByName($format); |
| 262 | + $this->mPrinter = $this->createPrinterByName($params['format']); |
253 | 263 | } |
254 | 264 | |
255 | 265 | if ($this->mPrinter->getNeedsRawData()) |