@@ -30,8 +30,7 @@ |
||
| 30 | 30 | public function authenticate(User $user, $data) |
| 31 | 31 | { |
| 32 | 32 | $storedData = $this->getCredentialData($user->getId()); |
| 33 | - if($storedData === null) |
|
| 34 | - { |
|
| 33 | + if($storedData === null) { |
|
| 35 | 34 | // No available credential matching these parameters |
| 36 | 35 | return false; |
| 37 | 36 | } |
@@ -77,14 +77,12 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | if ($this->checkIdentificationCache($onWikiName)) { |
| 79 | 79 | return true; |
| 80 | - } |
|
| 81 | - else { |
|
| 80 | + } else { |
|
| 82 | 81 | if ($this->isIdentifiedOnWiki($onWikiName)) { |
| 83 | 82 | $this->cacheIdentificationStatus($onWikiName); |
| 84 | 83 | |
| 85 | 84 | return true; |
| 86 | - } |
|
| 87 | - else { |
|
| 85 | + } else { |
|
| 88 | 86 | return false; |
| 89 | 87 | } |
| 90 | 88 | } |
@@ -190,7 +188,8 @@ discard block |
||
| 190 | 188 | $endpoint = $this->siteConfiguration->getMetaWikimediaWebServiceEndpoint(); |
| 191 | 189 | $response = $this->httpHelper->get($endpoint, $parameters); |
| 192 | 190 | $response = json_decode($response, true); |
| 193 | - } catch (CurlException $ex) { |
|
| 191 | + } |
|
| 192 | + catch (CurlException $ex) { |
|
| 194 | 193 | // failed getting identification status, so throw a nicer error. |
| 195 | 194 | $message = 'Could not contact metawiki API to determine user\' identification status. ' |
| 196 | 195 | . 'This is probably a transient error, so please try again.'; |
@@ -90,12 +90,10 @@ |
||
| 90 | 90 | |
| 91 | 91 | if ($statement->execute()) { |
| 92 | 92 | $this->id = (int)$this->dbObject->lastInsertId(); |
| 93 | - } |
|
| 94 | - else { |
|
| 93 | + } else { |
|
| 95 | 94 | throw new Exception($statement->errorInfo()); |
| 96 | 95 | } |
| 97 | - } |
|
| 98 | - else { |
|
| 96 | + } else { |
|
| 99 | 97 | $statement = $this->dbObject->prepare(<<<SQL |
| 100 | 98 | UPDATE oauthidentity SET |
| 101 | 99 | iss = :iss |
@@ -130,8 +130,7 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | if ($timeout === null) { |
| 132 | 132 | $this->timeout = null; |
| 133 | - } |
|
| 134 | - else { |
|
| 133 | + } else { |
|
| 135 | 134 | $this->timeout = $timeout->format('Y-m-d H:i:s'); |
| 136 | 135 | } |
| 137 | 136 | } |
@@ -188,12 +187,10 @@ discard block |
||
| 188 | 187 | |
| 189 | 188 | if ($statement->execute()) { |
| 190 | 189 | $this->id = (int)$this->dbObject->lastInsertId(); |
| 191 | - } |
|
| 192 | - else { |
|
| 190 | + } else { |
|
| 193 | 191 | throw new Exception($statement->errorInfo()); |
| 194 | 192 | } |
| 195 | - } |
|
| 196 | - else { |
|
| 193 | + } else { |
|
| 197 | 194 | // update |
| 198 | 195 | $statement = $this->dbObject->prepare(<<<SQL |
| 199 | 196 | UPDATE credential |
@@ -58,7 +58,8 @@ discard block |
||
| 58 | 58 | /** |
| 59 | 59 | * This feels like the least bad place to put this method. |
| 60 | 60 | */ |
| 61 | - public static function getTaskDescriptions() { |
|
| 61 | + public static function getTaskDescriptions() |
|
| 62 | + { |
|
| 62 | 63 | return array( |
| 63 | 64 | BotCreationTask::class => 'Create account (via bot)', |
| 64 | 65 | UserCreationTask::class => 'Create account (via OAuth)', |
@@ -90,12 +91,10 @@ discard block |
||
| 90 | 91 | |
| 91 | 92 | if ($statement->execute()) { |
| 92 | 93 | $this->id = (int)$this->dbObject->lastInsertId(); |
| 93 | - } |
|
| 94 | - else { |
|
| 94 | + } else { |
|
| 95 | 95 | throw new Exception($statement->errorInfo()); |
| 96 | 96 | } |
| 97 | - } |
|
| 98 | - else { |
|
| 97 | + } else { |
|
| 99 | 98 | // update |
| 100 | 99 | $statement = $this->dbObject->prepare(<<<SQL |
| 101 | 100 | UPDATE jobqueue SET |
@@ -42,12 +42,10 @@ |
||
| 42 | 42 | |
| 43 | 43 | if ($statement->execute()) { |
| 44 | 44 | $this->id = (int)$this->dbObject->lastInsertId(); |
| 45 | - } |
|
| 46 | - else { |
|
| 45 | + } else { |
|
| 47 | 46 | throw new Exception($statement->errorInfo()); |
| 48 | 47 | } |
| 49 | - } |
|
| 50 | - else { |
|
| 48 | + } else { |
|
| 51 | 49 | // update |
| 52 | 50 | $statement = $this->dbObject->prepare(<<<SQL |
| 53 | 51 | UPDATE oauthtoken |
@@ -64,12 +64,10 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if ($user === false) { |
| 66 | 66 | self::$currentUser = new CommunityUser(); |
| 67 | - } |
|
| 68 | - else { |
|
| 67 | + } else { |
|
| 69 | 68 | self::$currentUser = $user; |
| 70 | 69 | } |
| 71 | - } |
|
| 72 | - else { |
|
| 70 | + } else { |
|
| 73 | 71 | $anonymousCoward = new CommunityUser(); |
| 74 | 72 | |
| 75 | 73 | self::$currentUser = $anonymousCoward; |
@@ -203,12 +201,10 @@ discard block |
||
| 203 | 201 | |
| 204 | 202 | if ($statement->execute()) { |
| 205 | 203 | $this->id = (int)$this->dbObject->lastInsertId(); |
| 206 | - } |
|
| 207 | - else { |
|
| 204 | + } else { |
|
| 208 | 205 | throw new Exception($statement->errorInfo()); |
| 209 | 206 | } |
| 210 | - } |
|
| 211 | - else { |
|
| 207 | + } else { |
|
| 212 | 208 | // update |
| 213 | 209 | $statement = $this->dbObject->prepare(<<<SQL |
| 214 | 210 | UPDATE `user` SET |
@@ -533,12 +529,10 @@ discard block |
||
| 533 | 529 | if ($this->forceidentified === 0 || $this->forceidentified === "0") { |
| 534 | 530 | // User forced to unidentified in the database. |
| 535 | 531 | return false; |
| 536 | - } |
|
| 537 | - elseif ($this->forceidentified === 1 || $this->forceidentified === "1") { |
|
| 532 | + } elseif ($this->forceidentified === 1 || $this->forceidentified === "1") { |
|
| 538 | 533 | // User forced to identified in the database. |
| 539 | 534 | return true; |
| 540 | - } |
|
| 541 | - else { |
|
| 535 | + } else { |
|
| 542 | 536 | // User not forced to any particular identified status; consult IdentificationVerifier |
| 543 | 537 | return $iv->isUserIdentified($this->getOnWikiName()); |
| 544 | 538 | } |
@@ -549,7 +543,8 @@ discard block |
||
| 549 | 543 | * |
| 550 | 544 | * @return bool|null |
| 551 | 545 | */ |
| 552 | - public function getForceIdentified() { |
|
| 546 | + public function getForceIdentified() |
|
| 547 | + { |
|
| 553 | 548 | return $this->forceidentified; |
| 554 | 549 | } |
| 555 | 550 | |
@@ -46,8 +46,7 @@ discard block |
||
| 46 | 46 | SQL; |
| 47 | 47 | $statement = $database->prepare($query); |
| 48 | 48 | $statement->bindValue(":target", $target); |
| 49 | - } |
|
| 50 | - else { |
|
| 49 | + } else { |
|
| 51 | 50 | $query = <<<SQL |
| 52 | 51 | SELECT * FROM ban |
| 53 | 52 | WHERE (duration > UNIX_TIMESTAMP() OR duration is null) |
@@ -152,12 +151,10 @@ discard block |
||
| 152 | 151 | |
| 153 | 152 | if ($statement->execute()) { |
| 154 | 153 | $this->id = (int)$this->dbObject->lastInsertId(); |
| 155 | - } |
|
| 156 | - else { |
|
| 154 | + } else { |
|
| 157 | 155 | throw new Exception($statement->errorInfo()); |
| 158 | 156 | } |
| 159 | - } |
|
| 160 | - else { |
|
| 157 | + } else { |
|
| 161 | 158 | // update |
| 162 | 159 | $statement = $this->dbObject->prepare(<<<SQL |
| 163 | 160 | UPDATE `ban` |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | return; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if (!$mediaWikiHelper->checkAccountExists($request->getName())){ |
|
| 64 | + if (!$mediaWikiHelper->checkAccountExists($request->getName())) { |
|
| 65 | 65 | $this->markFailed('Account does not exist!'); |
| 66 | 66 | |
| 67 | 67 | return; |