@@ -233,6 +233,9 @@ |
||
| 233 | 233 | Logger::backgroundJobComplete($this->getDatabase(), $this->getJob()); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | + /** |
|
| 237 | + * @param string $reason |
|
| 238 | + */ |
|
| 236 | 239 | protected function markCancelled($reason = null) |
| 237 | 240 | { |
| 238 | 241 | $this->job->setStatus(JobQueue::STATUS_CANCELLED); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | throw new ApplicationLogicException('Cannot locate request'); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if($this->job->getEmailTemplate() !== null){ |
|
| 180 | + if ($this->job->getEmailTemplate() !== null) { |
|
| 181 | 181 | $this->emailTemplate = EmailTemplate::getById($this->job->getEmailTemplate(), $this->getDatabase()); |
| 182 | 182 | |
| 183 | 183 | if ($this->emailTemplate === false) { |
@@ -188,15 +188,15 @@ discard block |
||
| 188 | 188 | $this->parameters = json_decode($this->job->getParameters()); |
| 189 | 189 | |
| 190 | 190 | if (json_last_error() !== JSON_ERROR_NONE) { |
| 191 | - throw new ApplicationLogicException('JSON decode: ' . json_last_error_msg()); |
|
| 191 | + throw new ApplicationLogicException('JSON decode: '.json_last_error_msg()); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | // Should we wait for a parent job? |
| 195 | - if($this->job->getParent() !== null) { |
|
| 195 | + if ($this->job->getParent() !== null) { |
|
| 196 | 196 | /** @var JobQueue $parentJob */ |
| 197 | 197 | $parentJob = JobQueue::getById($this->job->getParent(), $this->getDatabase()); |
| 198 | 198 | |
| 199 | - if($parentJob === false) { |
|
| 199 | + if ($parentJob === false) { |
|
| 200 | 200 | $this->markFailed("Parent job could not be found"); |
| 201 | 201 | return; |
| 202 | 202 | } |
@@ -105,6 +105,9 @@ discard block |
||
| 105 | 105 | return $this->getMediaWikiHelper()->checkAccountExists($name); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | + /** |
|
| 109 | + * @param string $reason |
|
| 110 | + */ |
|
| 108 | 111 | protected function markFailed($reason = null) |
| 109 | 112 | { |
| 110 | 113 | $this->request->setStatus(RequestStatus::HOSPITAL); |
@@ -116,7 +119,7 @@ discard block |
||
| 116 | 119 | } |
| 117 | 120 | |
| 118 | 121 | /** |
| 119 | - * @param $user |
|
| 122 | + * @param User $user |
|
| 120 | 123 | * |
| 121 | 124 | * @throws ApplicationLogicException |
| 122 | 125 | */ |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | protected abstract function getMediaWikiClient(); |
| 84 | 84 | |
| 85 | - protected function getMediaWikiHelper(){ |
|
| 86 | - if($this->mwHelper === null) { |
|
| 85 | + protected function getMediaWikiHelper() { |
|
| 86 | + if ($this->mwHelper === null) { |
|
| 87 | 87 | $this->mwHelper = new MediaWikiHelper($this->getMediaWikiClient(), $this->getSiteConfiguration()); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | protected function getCreationReason(Request $request, User $user) |
| 94 | 94 | { |
| 95 | - return 'Requested account at [[WP:ACC]], request #' . $request->getId(); |
|
| 95 | + return 'Requested account at [[WP:ACC]], request #'.$request->getId(); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -225,7 +225,7 @@ |
||
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
| 228 | - * @return mixed |
|
| 228 | + * @return string |
|
| 229 | 229 | */ |
| 230 | 230 | public function getError() |
| 231 | 231 | { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | #region properties |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | - * @return mixed |
|
| 86 | + * @return integer |
|
| 87 | 87 | */ |
| 88 | 88 | public function getUserId() |
| 89 | 89 | { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | - * @return mixed |
|
| 102 | + * @return string |
|
| 103 | 103 | */ |
| 104 | 104 | public function getToken() |
| 105 | 105 | { |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | - * @return mixed |
|
| 118 | + * @return string |
|
| 119 | 119 | */ |
| 120 | 120 | public function getSecret() |
| 121 | 121 | { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | - * @return mixed |
|
| 134 | + * @return string |
|
| 135 | 135 | */ |
| 136 | 136 | public function getType() |
| 137 | 137 | { |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | - * @param mixed $type |
|
| 142 | + * @param string $type |
|
| 143 | 143 | */ |
| 144 | 144 | public function setType($type) |
| 145 | 145 | { |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * @param $apiParams |
| 86 | - * @param $method |
|
| 86 | + * @param string $method |
|
| 87 | 87 | * |
| 88 | 88 | * @return mixed |
| 89 | 89 | * @throws ApplicationLogicException |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | if ($data === false) { |
| 107 | - throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
| 107 | + throw new CurlException('Curl error: '.$this->httpHelper->getError()); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $result = json_decode($data); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $response = $this->callApi($tokenParams, 'POST'); |
| 125 | 125 | |
| 126 | 126 | if (isset($response->error)) { |
| 127 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 127 | + throw new MediaWikiApiException($response->error->code.': '.$response->error->info); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | $token = $response->query->tokens->logintoken; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | $loginResponse = $this->callApi($params, 'POST'); |
| 144 | 144 | |
| 145 | - if($loginResponse->login->result == 'Success'){ |
|
| 145 | + if ($loginResponse->login->result == 'Success') { |
|
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -10,5 +10,8 @@ |
||
| 10 | 10 | |
| 11 | 11 | interface IMediaWikiClient |
| 12 | 12 | { |
| 13 | + /** |
|
| 14 | + * @param string $method |
|
| 15 | + */ |
|
| 13 | 16 | function doApiCall($params, $method); |
| 14 | 17 | } |
| 15 | 18 | \ No newline at end of file |
@@ -63,6 +63,10 @@ discard block |
||
| 63 | 63 | private $siteConfiguration; |
| 64 | 64 | |
| 65 | 65 | #region Static methods |
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @param null|string $requestToken |
|
| 69 | + */ |
|
| 66 | 70 | public static function findUserByRequestToken($requestToken, PdoDatabase $database) |
| 67 | 71 | { |
| 68 | 72 | $statement = $database->prepare(<<<'SQL' |
@@ -119,6 +123,11 @@ discard block |
||
| 119 | 123 | } |
| 120 | 124 | } |
| 121 | 125 | |
| 126 | + /** |
|
| 127 | + * @param integer $userId |
|
| 128 | + * @param null|PdoDatabase $database |
|
| 129 | + * @param string $tokenType |
|
| 130 | + */ |
|
| 122 | 131 | private static function runTokenCount($userId, $database, $tokenType) |
| 123 | 132 | { |
| 124 | 133 | if (self::$tokenCountStatement === null) { |
@@ -182,7 +191,7 @@ discard block |
||
| 182 | 191 | /** |
| 183 | 192 | * Attempts to figure out if a user is partially linked to OAuth, and therefore needs to complete the OAuth |
| 184 | 193 | * procedure before configuring. |
| 185 | - * @return bool |
|
| 194 | + * @return boolean|null |
|
| 186 | 195 | */ |
| 187 | 196 | public function isPartiallyLinked() |
| 188 | 197 | { |
@@ -245,6 +254,9 @@ discard block |
||
| 245 | 254 | return $this->oauthProtocolHelper->getAuthoriseUrl($token->key); |
| 246 | 255 | } |
| 247 | 256 | |
| 257 | + /** |
|
| 258 | + * @param null|string $verificationToken |
|
| 259 | + */ |
|
| 248 | 260 | public function completeHandshake($verificationToken) |
| 249 | 261 | { |
| 250 | 262 | $this->getTokenStatement->execute(array(':user' => $this->user->getId(), ':type' => self::TOKEN_REQUEST)); |
@@ -42,6 +42,10 @@ |
||
| 42 | 42 | $this->database = $database; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | + /** |
|
| 46 | + * @param string $data |
|
| 47 | + * @param integer $stage |
|
| 48 | + */ |
|
| 45 | 49 | public function authenticate(User $user, $data, $stage) |
| 46 | 50 | { |
| 47 | 51 | $sql = 'SELECT type FROM credential WHERE user = :user AND factor = :stage'; |
@@ -24,19 +24,19 @@ discard block |
||
| 24 | 24 | public function authenticate(User $user, $data) |
| 25 | 25 | { |
| 26 | 26 | $storedData = $this->getCredentialData($user->getId()); |
| 27 | - if($storedData === null) |
|
| 27 | + if ($storedData === null) |
|
| 28 | 28 | { |
| 29 | 29 | // No available credential matching these parameters |
| 30 | 30 | return false; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if($storedData->getVersion() !== 2) { |
|
| 33 | + if ($storedData->getVersion() !== 2) { |
|
| 34 | 34 | // Non-2 versions are not supported. |
| 35 | 35 | return false; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if(password_verify($data, $storedData->getData())) { |
|
| 39 | - if(password_needs_rehash($storedData->getData(), PASSWORD_BCRYPT, array('cost' => self::PASSWORD_COST))){ |
|
| 38 | + if (password_verify($data, $storedData->getData())) { |
|
| 39 | + if (password_needs_rehash($storedData->getData(), PASSWORD_BCRYPT, array('cost' => self::PASSWORD_COST))) { |
|
| 40 | 40 | $this->setCredential($user, $storedData->getFactor(), $data); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | $storedData = $this->getCredentialData($user->getId()); |
| 52 | 52 | |
| 53 | - if($storedData === null){ |
|
| 53 | + if ($storedData === null) { |
|
| 54 | 54 | $storedData = $this->createNewCredential($user); |
| 55 | 55 | } |
| 56 | 56 | |