@@ -29,8 +29,8 @@ |
||
| 29 | 29 | * @param string $message exception message |
| 30 | 30 | * @param Exception $parent parent exception |
| 31 | 31 | */ |
| 32 | - public function __construct($message, $parent=null) |
|
| 33 | - { |
|
| 34 | - parent::__construct($message, 0, $parent); |
|
| 35 | - } |
|
| 32 | + public function __construct($message, $parent=null) |
|
| 33 | + { |
|
| 34 | + parent::__construct($message, 0, $parent); |
|
| 35 | + } |
|
| 36 | 36 | } |
| 37 | 37 | \ No newline at end of file |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | private static function _hmac(string $crypto, string $keyBytes, string $text) : string |
| 38 | 38 | { |
| 39 | - $hash = hash_hmac($crypto, $text, $keyBytes); |
|
| 40 | - if (false === $hash) { |
|
| 41 | - throw new Exception("calculating hash_hmac failed"); |
|
| 42 | - } |
|
| 43 | - return $hash; |
|
| 39 | + $hash = hash_hmac($crypto, $text, $keyBytes); |
|
| 40 | + if (false === $hash) { |
|
| 41 | + throw new Exception("calculating hash_hmac failed"); |
|
| 42 | + } |
|
| 43 | + return $hash; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | * alternative to "-S064" |
| 100 | 100 | */ |
| 101 | 101 | static function generateOCRA(string $ocraSuite, |
| 102 | - string $key, |
|
| 103 | - string $counter, |
|
| 104 | - string $question, |
|
| 105 | - string $password, |
|
| 106 | - string $sessionInformation, |
|
| 107 | - string $timeStamp) : string |
|
| 102 | + string $key, |
|
| 103 | + string $counter, |
|
| 104 | + string $question, |
|
| 105 | + string $password, |
|
| 106 | + string $sessionInformation, |
|
| 107 | + string $timeStamp) : string |
|
| 108 | 108 | { |
| 109 | 109 | $codeDigits = 0; |
| 110 | 110 | $crypto = ""; |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | $cryptoFunction = $components[1]; |
| 126 | 126 | $dataInput = strtolower($components[2]); // lower here so we can do case insensitive comparisons |
| 127 | 127 | |
| 128 | - if(stripos($cryptoFunction, "hotp-sha1")!==false) |
|
| 129 | - $crypto = "sha1"; |
|
| 130 | - elseif(stripos($cryptoFunction, "hotp-sha256")!==false) |
|
| 131 | - $crypto = "sha256"; |
|
| 132 | - elseif(stripos($cryptoFunction, "hotp-sha512")!==false) |
|
| 133 | - $crypto = "sha512"; |
|
| 134 | - else { |
|
| 128 | + if(stripos($cryptoFunction, "hotp-sha1")!==false) { |
|
| 129 | + $crypto = "sha1"; |
|
| 130 | + } elseif(stripos($cryptoFunction, "hotp-sha256")!==false) { |
|
| 131 | + $crypto = "sha256"; |
|
| 132 | + } elseif(stripos($cryptoFunction, "hotp-sha512")!==false) { |
|
| 133 | + $crypto = "sha512"; |
|
| 134 | + } else { |
|
| 135 | 135 | throw new InvalidArgumentException('Unsupported OCRA CryptoFunction'); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -149,56 +149,65 @@ discard block |
||
| 149 | 149 | // Counter |
| 150 | 150 | if($dataInput[0] == "c" ) { |
| 151 | 151 | // Fix the length of the HEX string |
| 152 | - while(strlen($counter) < 16) |
|
| 153 | - $counter = "0" . $counter; |
|
| 152 | + while(strlen($counter) < 16) { |
|
| 153 | + $counter = "0" . $counter; |
|
| 154 | + } |
|
| 154 | 155 | $counterLength=8; |
| 155 | 156 | } |
| 156 | 157 | // Question |
| 157 | 158 | if($dataInput[0] == "q" || |
| 158 | 159 | stripos($dataInput, "-q")!==false) { |
| 159 | - while(strlen($question) < 256) |
|
| 160 | - $question = $question . "0"; |
|
| 160 | + while(strlen($question) < 256) { |
|
| 161 | + $question = $question . "0"; |
|
| 162 | + } |
|
| 161 | 163 | $questionLength=128; |
| 162 | 164 | } |
| 163 | 165 | |
| 164 | 166 | // Password |
| 165 | 167 | if(stripos($dataInput, "psha1")!==false) { |
| 166 | - while(strlen($password) < 40) |
|
| 167 | - $password = "0" . $password; |
|
| 168 | + while(strlen($password) < 40) { |
|
| 169 | + $password = "0" . $password; |
|
| 170 | + } |
|
| 168 | 171 | $passwordLength=20; |
| 169 | 172 | } |
| 170 | 173 | |
| 171 | 174 | if(stripos($dataInput, "psha256")!==false) { |
| 172 | - while(strlen($password) < 64) |
|
| 173 | - $password = "0" . $password; |
|
| 175 | + while(strlen($password) < 64) { |
|
| 176 | + $password = "0" . $password; |
|
| 177 | + } |
|
| 174 | 178 | $passwordLength=32; |
| 175 | 179 | } |
| 176 | 180 | |
| 177 | 181 | if(stripos($dataInput, "psha512")!==false) { |
| 178 | - while(strlen($password) < 128) |
|
| 179 | - $password = "0" . $password; |
|
| 182 | + while(strlen($password) < 128) { |
|
| 183 | + $password = "0" . $password; |
|
| 184 | + } |
|
| 180 | 185 | $passwordLength=64; |
| 181 | 186 | } |
| 182 | 187 | |
| 183 | 188 | // sessionInformation |
| 184 | 189 | if(stripos($dataInput, "s064") !==false) { |
| 185 | - while(strlen($sessionInformation) < 128) |
|
| 186 | - $sessionInformation = "0" . $sessionInformation; |
|
| 190 | + while(strlen($sessionInformation) < 128) { |
|
| 191 | + $sessionInformation = "0" . $sessionInformation; |
|
| 192 | + } |
|
| 187 | 193 | |
| 188 | 194 | $sessionInformationLength=64; |
| 189 | 195 | } else if(stripos($dataInput, "s128") !==false) { |
| 190 | - while(strlen($sessionInformation) < 256) |
|
| 191 | - $sessionInformation = "0" . $sessionInformation; |
|
| 196 | + while(strlen($sessionInformation) < 256) { |
|
| 197 | + $sessionInformation = "0" . $sessionInformation; |
|
| 198 | + } |
|
| 192 | 199 | |
| 193 | 200 | $sessionInformationLength=128; |
| 194 | 201 | } else if(stripos($dataInput, "s256") !==false) { |
| 195 | - while(strlen($sessionInformation) < 512) |
|
| 196 | - $sessionInformation = "0" . $sessionInformation; |
|
| 202 | + while(strlen($sessionInformation) < 512) { |
|
| 203 | + $sessionInformation = "0" . $sessionInformation; |
|
| 204 | + } |
|
| 197 | 205 | |
| 198 | 206 | $sessionInformationLength=256; |
| 199 | 207 | } else if(stripos($dataInput, "s512") !==false) { |
| 200 | - while(strlen($sessionInformation) < 128) |
|
| 201 | - $sessionInformation = "0" . $sessionInformation; |
|
| 208 | + while(strlen($sessionInformation) < 128) { |
|
| 209 | + $sessionInformation = "0" . $sessionInformation; |
|
| 210 | + } |
|
| 202 | 211 | |
| 203 | 212 | $sessionInformationLength=64; |
| 204 | 213 | } else if (stripos($dataInput, "-s") !== false ) { |
@@ -210,8 +219,9 @@ discard block |
||
| 210 | 219 | // to prevent matching the "s" in the password input e.g. "psha1". |
| 211 | 220 | // [C] | QFxx | [PH | Snnn | TG] : Challenge-Response computation |
| 212 | 221 | // [C] | QFxx | [PH | TG] : Plain Signature computation |
| 213 | - while(strlen($sessionInformation) < 128) |
|
| 214 | - $sessionInformation = "0" . $sessionInformation; |
|
| 222 | + while(strlen($sessionInformation) < 128) { |
|
| 223 | + $sessionInformation = "0" . $sessionInformation; |
|
| 224 | + } |
|
| 215 | 225 | |
| 216 | 226 | $sessionInformationLength=64; |
| 217 | 227 | } |
@@ -221,8 +231,9 @@ discard block |
||
| 221 | 231 | // TimeStamp |
| 222 | 232 | if($dataInput[0] == "t" || |
| 223 | 233 | stripos($dataInput, "-t") !== false) { |
| 224 | - while(strlen($timeStamp) < 16) |
|
| 225 | - $timeStamp = "0" . $timeStamp; |
|
| 234 | + while(strlen($timeStamp) < 16) { |
|
| 235 | + $timeStamp = "0" . $timeStamp; |
|
| 236 | + } |
|
| 226 | 237 | $timeStampLength=8; |
| 227 | 238 | } |
| 228 | 239 | |
@@ -289,10 +300,11 @@ discard block |
||
| 289 | 300 | |
| 290 | 301 | $hash = self::_hmac($crypto, $byteKey, $msg); |
| 291 | 302 | |
| 292 | - if ($codeDigits == 0) |
|
| 293 | - $result = $hash; |
|
| 294 | - else |
|
| 295 | - $result = self::_oath_truncate($hash, $codeDigits); |
|
| 303 | + if ($codeDigits == 0) { |
|
| 304 | + $result = $hash; |
|
| 305 | + } else { |
|
| 306 | + $result = self::_oath_truncate($hash, $codeDigits); |
|
| 307 | + } |
|
| 296 | 308 | |
| 297 | 309 | return $result; |
| 298 | 310 | } |
@@ -86,8 +86,7 @@ discard block |
||
| 86 | 86 | $sth = $this->handle->prepare('SELECT userid FROM ' . $this->tableName . ' WHERE userid = ?'); |
| 87 | 87 | $sth->execute(array($userId)); |
| 88 | 88 | return (false !== $sth->fetchColumn()); |
| 89 | - } |
|
| 90 | - catch (Exception $e) { |
|
| 89 | + } catch (Exception $e) { |
|
| 91 | 90 | $this->logger->error('PDO error checking user exists', array('exception'=>$e, 'userId'=>$userId)); |
| 92 | 91 | throw ReadWriteException::fromOriginalException($e); |
| 93 | 92 | } |
@@ -111,8 +110,7 @@ discard block |
||
| 111 | 110 | $this->logger->error(sprintf('No result getting secret for user "%s"', $userId)); |
| 112 | 111 | throw new RuntimeException('User not found'); |
| 113 | 112 | } |
| 114 | - } |
|
| 115 | - catch (Exception $e) { |
|
| 113 | + } catch (Exception $e) { |
|
| 116 | 114 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId)); |
| 117 | 115 | throw ReadWriteException::fromOriginalException($e); |
| 118 | 116 | } |
@@ -146,8 +144,7 @@ discard block |
||
| 146 | 144 | $sth = $this->handle->prepare('INSERT INTO ' . $this->tableName . ' (secret,userid) VALUES (?,?)'); |
| 147 | 145 | } |
| 148 | 146 | $sth->execute(array($secret, $userId)); |
| 149 | - } |
|
| 150 | - catch (Exception $e) { |
|
| 147 | + } catch (Exception $e) { |
|
| 151 | 148 | $this->logger->error( |
| 152 | 149 | sprintf('Unable to persist user secret for user "%s" in user secret storage (PDO)', $userId), |
| 153 | 150 | array('exception'=>$e) |
@@ -42,7 +42,6 @@ |
||
| 42 | 42 | userid varchar(30) NOT NULL UNIQUE, |
| 43 | 43 | secret varchar(128), |
| 44 | 44 | ); |
| 45 | - |
|
| 46 | 45 | * @see Tiqr_UserSecretStorage::getSecretStorage() |
| 47 | 46 | * @see Tiqr_UserSecretStorage_Interface |
| 48 | 47 | * |
@@ -74,7 +74,9 @@ |
||
| 74 | 74 | */ |
| 75 | 75 | public function getPath(): string |
| 76 | 76 | { |
| 77 | - if (substr($this->path, -1)!="/") return $this->path."/"; |
|
| 77 | + if (substr($this->path, -1)!="/") { |
|
| 78 | + return $this->path."/"; |
|
| 79 | + } |
|
| 78 | 80 | return $this->path; |
| 79 | 81 | } |
| 80 | 82 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | public function createUser(string $userId, string $displayName) : void |
| 61 | 61 | { |
| 62 | 62 | $user = array("userId"=>$userId, |
| 63 | - "displayName"=>$displayName); |
|
| 63 | + "displayName"=>$displayName); |
|
| 64 | 64 | $this->_saveUser($userId, $user); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | if ($data = $this->_loadUser($userId)) { |
| 92 | 92 | if (isset($data["notificationType"])) { |
| 93 | - return $data["notificationType"]; |
|
| 93 | + return $data["notificationType"]; |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | return ''; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | if ($data = $this->_loadUser($userId)) { |
| 115 | 115 | if (isset($data["notificationAddress"])) { |
| 116 | - return $data["notificationAddress"]; |
|
| 116 | + return $data["notificationAddress"]; |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | $this->logger->info('Unable to find notification address for user'); |
@@ -54,8 +54,8 @@ |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $envelope = array("expire"=>$expire, |
| 57 | - "createdAt"=>time(), |
|
| 58 | - "value"=>$value); |
|
| 57 | + "createdAt"=>time(), |
|
| 58 | + "value"=>$value); |
|
| 59 | 59 | $filename = $this->getFilenameByKey($key); |
| 60 | 60 | |
| 61 | 61 | if (!file_put_contents($filename, serialize($envelope))) { |
@@ -36,8 +36,7 @@ |
||
| 36 | 36 | // response as the client calculated. |
| 37 | 37 | try { |
| 38 | 38 | $expected = OCRA::generateOCRA($this->_ocraSuite, $userSecret, "", $challenge, "", $sessionInformation, ""); |
| 39 | - } |
|
| 40 | - catch (Exception $e) { |
|
| 39 | + } catch (Exception $e) { |
|
| 41 | 40 | $this->logger->warning(sprintf('Error calculating OCRA response for user "%s"', $userId), array('exception'=>$e)); |
| 42 | 41 | return false; |
| 43 | 42 | } |
@@ -571,17 +571,17 @@ discard block |
||
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | $metadata = array("service"=> |
| 574 | - array("displayName" => $this->_name, |
|
| 575 | - "identifier" => $this->_identifier, |
|
| 576 | - "logoUrl" => $this->_logoUrl, |
|
| 577 | - "infoUrl" => $this->_infoUrl, |
|
| 578 | - "authenticationUrl" => $authenticationUrl, |
|
| 579 | - "ocraSuite" => $this->_ocraSuite, |
|
| 580 | - "enrollmentUrl" => $enrollmentUrl |
|
| 581 | - ), |
|
| 582 | - "identity"=> |
|
| 583 | - array("identifier" =>$data["userId"], |
|
| 584 | - "displayName"=>$data["displayName"])); |
|
| 574 | + array("displayName" => $this->_name, |
|
| 575 | + "identifier" => $this->_identifier, |
|
| 576 | + "logoUrl" => $this->_logoUrl, |
|
| 577 | + "infoUrl" => $this->_infoUrl, |
|
| 578 | + "authenticationUrl" => $authenticationUrl, |
|
| 579 | + "ocraSuite" => $this->_ocraSuite, |
|
| 580 | + "enrollmentUrl" => $enrollmentUrl |
|
| 581 | + ), |
|
| 582 | + "identity"=> |
|
| 583 | + array("identifier" =>$data["userId"], |
|
| 584 | + "displayName"=>$data["displayName"])); |
|
| 585 | 585 | |
| 586 | 586 | $this->_unsetStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey); |
| 587 | 587 | |
@@ -611,28 +611,28 @@ discard block |
||
| 611 | 611 | */ |
| 612 | 612 | public function getEnrollmentSecret(string $enrollmentKey): string |
| 613 | 613 | { |
| 614 | - $data = $this->_getStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey); |
|
| 615 | - if (!is_array($data)) { |
|
| 616 | - $this->logger->error('getEnrollmentSecret: enrollment key not found'); |
|
| 617 | - throw new RuntimeException('enrollment key not found'); |
|
| 618 | - } |
|
| 619 | - $userId = $data["userId"] ?? NULL; |
|
| 620 | - $sessionId = $data["sessionId"] ?? NULL; |
|
| 621 | - if (!is_string($userId) || !(is_string($sessionId))) { |
|
| 622 | - throw new RuntimeException('getEnrollmentSecret: invalid enrollment data'); |
|
| 623 | - } |
|
| 624 | - $enrollmentData = [ |
|
| 625 | - "userId" => $userId, |
|
| 626 | - "sessionId" => $sessionId |
|
| 627 | - ]; |
|
| 628 | - $enrollmentSecret = $this->_uniqueSessionKey(); |
|
| 629 | - $this->_setStateValue( |
|
| 630 | - self::PREFIX_ENROLLMENT_SECRET, |
|
| 631 | - $enrollmentSecret, |
|
| 632 | - $enrollmentData, |
|
| 633 | - self::ENROLLMENT_EXPIRE |
|
| 634 | - ); |
|
| 635 | - return $enrollmentSecret; |
|
| 614 | + $data = $this->_getStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey); |
|
| 615 | + if (!is_array($data)) { |
|
| 616 | + $this->logger->error('getEnrollmentSecret: enrollment key not found'); |
|
| 617 | + throw new RuntimeException('enrollment key not found'); |
|
| 618 | + } |
|
| 619 | + $userId = $data["userId"] ?? NULL; |
|
| 620 | + $sessionId = $data["sessionId"] ?? NULL; |
|
| 621 | + if (!is_string($userId) || !(is_string($sessionId))) { |
|
| 622 | + throw new RuntimeException('getEnrollmentSecret: invalid enrollment data'); |
|
| 623 | + } |
|
| 624 | + $enrollmentData = [ |
|
| 625 | + "userId" => $userId, |
|
| 626 | + "sessionId" => $sessionId |
|
| 627 | + ]; |
|
| 628 | + $enrollmentSecret = $this->_uniqueSessionKey(); |
|
| 629 | + $this->_setStateValue( |
|
| 630 | + self::PREFIX_ENROLLMENT_SECRET, |
|
| 631 | + $enrollmentSecret, |
|
| 632 | + $enrollmentData, |
|
| 633 | + self::ENROLLMENT_EXPIRE |
|
| 634 | + ); |
|
| 635 | + return $enrollmentSecret; |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | /** |
@@ -287,8 +287,7 @@ discard block |
||
| 287 | 287 | if (isset($options['ocraservice']) && $options['ocraservice']['type'] != 'tiqr') { |
| 288 | 288 | $options['ocraservice']['ocra.suite'] = $this->_ocraSuite; |
| 289 | 289 | $this->_ocraService = Tiqr_OcraService::getOcraService($options['ocraservice']['type'], $options['ocraservice'], $logger); |
| 290 | - } |
|
| 291 | - else { // Create default ocraservice |
|
| 290 | + } else { // Create default ocraservice |
|
| 292 | 291 | $this->_ocraService = Tiqr_OcraService::getOcraService('tiqr', array('ocra.suite' => $this->_ocraSuite), $logger); |
| 293 | 292 | } |
| 294 | 293 | } |
@@ -347,8 +346,9 @@ discard block |
||
| 347 | 346 | case 'APNS': |
| 348 | 347 | case 'APNS_DIRECT': |
| 349 | 348 | $apns_version = $this->_options['apns.version'] ?? 2; |
| 350 | - if ($apns_version !=2) |
|
| 351 | - throw new InvalidArgumentException("Unsupported APNS version '$apns_version'"); |
|
| 349 | + if ($apns_version !=2) { |
|
| 350 | + throw new InvalidArgumentException("Unsupported APNS version '$apns_version'"); |
|
| 351 | + } |
|
| 352 | 352 | $message = new Tiqr_Message_APNS2($this->_options, $this->logger); |
| 353 | 353 | break; |
| 354 | 354 | |
@@ -514,7 +514,9 @@ discard block |
||
| 514 | 514 | $sessionId = session_id(); |
| 515 | 515 | } |
| 516 | 516 | $status = $this->_getStateValue(self::PREFIX_ENROLLMENT_STATUS, $sessionId); |
| 517 | - if (is_null($status)) return self::ENROLLMENT_STATUS_IDLE; |
|
| 517 | + if (is_null($status)) { |
|
| 518 | + return self::ENROLLMENT_STATUS_IDLE; |
|
| 519 | + } |
|
| 518 | 520 | return $status; |
| 519 | 521 | } |
| 520 | 522 | |
@@ -871,8 +873,7 @@ discard block |
||
| 871 | 873 | |
| 872 | 874 | try { |
| 873 | 875 | return $this->_getStateValue("authenticated_", $sessionId); |
| 874 | - } |
|
| 875 | - catch (Exception $e) { |
|
| 876 | + } catch (Exception $e) { |
|
| 876 | 877 | $this->logger->error('getAuthenticatedUser failed', array('exception'=>$e)); |
| 877 | 878 | return NULL; |
| 878 | 879 | } |
@@ -110,8 +110,7 @@ discard block |
||
| 110 | 110 | throw new RuntimeException('Unexpected return type'); |
| 111 | 111 | } |
| 112 | 112 | return $res; |
| 113 | - } |
|
| 114 | - catch (Exception $e) { |
|
| 113 | + } catch (Exception $e) { |
|
| 115 | 114 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
| 116 | 115 | throw ReadWriteException::fromOriginalException($e); |
| 117 | 116 | } |
@@ -149,8 +148,7 @@ discard block |
||
| 149 | 148 | throw new RuntimeException('Unexpected return type'); |
| 150 | 149 | } |
| 151 | 150 | return (int)$res; |
| 152 | - } |
|
| 153 | - catch (Exception $e) { |
|
| 151 | + } catch (Exception $e) { |
|
| 154 | 152 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
| 155 | 153 | throw ReadWriteException::fromOriginalException($e); |
| 156 | 154 | } |
@@ -177,8 +175,7 @@ discard block |
||
| 177 | 175 | throw new RuntimeException('User not found'); |
| 178 | 176 | } |
| 179 | 177 | } |
| 180 | - } |
|
| 181 | - catch (Exception $e) { |
|
| 178 | + } catch (Exception $e) { |
|
| 182 | 179 | $this->logger->error('PDO error updating user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
| 183 | 180 | throw ReadWriteException::fromOriginalException($e); |
| 184 | 181 | } |
@@ -205,8 +202,7 @@ discard block |
||
| 205 | 202 | throw new RuntimeException('User not found'); |
| 206 | 203 | } |
| 207 | 204 | } |
| 208 | - } |
|
| 209 | - catch (Exception $e) { |
|
| 205 | + } catch (Exception $e) { |
|
| 210 | 206 | $this->logger->error('PDO error updating user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
| 211 | 207 | throw ReadWriteException::fromOriginalException($e); |
| 212 | 208 | } |
@@ -223,8 +219,7 @@ discard block |
||
| 223 | 219 | try { |
| 224 | 220 | $sth = $this->handle->prepare("INSERT INTO ".$this->tablename." (displayname,userid) VALUES (?,?)"); |
| 225 | 221 | $sth->execute(array($displayName, $userId)); |
| 226 | - } |
|
| 227 | - catch (Exception $e) { |
|
| 222 | + } catch (Exception $e) { |
|
| 228 | 223 | $this->logger->error(sprintf('Error creating user "%s"', $userId), array('exception'=>$e)); |
| 229 | 224 | throw new ReadWriteException('The user could not be saved in the user storage (PDO)'); |
| 230 | 225 | } |
@@ -239,8 +234,7 @@ discard block |
||
| 239 | 234 | $sth = $this->handle->prepare("SELECT userid FROM ".$this->tablename." WHERE userid = ?"); |
| 240 | 235 | $sth->execute(array($userId)); |
| 241 | 236 | return (false !== $sth->fetchColumn()); |
| 242 | - } |
|
| 243 | - catch (Exception $e) { |
|
| 237 | + } catch (Exception $e) { |
|
| 244 | 238 | $this->logger->error('PDO error checking user exists', array('exception'=>$e, 'userId'=>$userId)); |
| 245 | 239 | throw ReadWriteException::fromOriginalException($e); |
| 246 | 240 | } |
@@ -30,13 +30,11 @@ |
||
| 30 | 30 | notificationtype varchar(10), |
| 31 | 31 | notificationaddress varchar(256) |
| 32 | 32 | ); |
| 33 | - |
|
| 34 | 33 | * |
| 35 | 34 | * In version 3.0 the format of the tmpblocktimestamp was changed from a datetime format to an integer. |
| 36 | 35 | * Because it holds a unix timestamp a 64-bit (8-byte) integer. To upgrade the user table to the new format use: |
| 37 | 36 | |
| 38 | 37 | ALTER TABLE user MODIFY tmpblocktimestamp BIGINT; |
| 39 | - |
|
| 40 | 38 | */ |
| 41 | 39 | |
| 42 | 40 | use Psr\Log\LoggerInterface; |