@@ -123,8 +123,7 @@ discard block |
||
| 123 | 123 | $this->logger->notice( |
| 124 | 124 | sprintf("Deleted %d expired keys", $deletedRows) |
| 125 | 125 | ); |
| 126 | - } |
|
| 127 | - catch (Exception $e) { |
|
| 126 | + } catch (Exception $e) { |
|
| 128 | 127 | $this->logger->error( |
| 129 | 128 | sprintf("Deleting expired keys failed: %s", $e->getMessage()), |
| 130 | 129 | array('exception', $e) |
@@ -157,8 +156,7 @@ discard block |
||
| 157 | 156 | } |
| 158 | 157 | try { |
| 159 | 158 | $sth->execute(array(serialize($value), $expire, $key)); |
| 160 | - } |
|
| 161 | - catch (Exception $e) { |
|
| 159 | + } catch (Exception $e) { |
|
| 162 | 160 | $this->logger->error( |
| 163 | 161 | sprintf('Unable to store key "%s" in PDO StateStorage', $key), |
| 164 | 162 | array('exception' => $e) |
@@ -178,8 +176,7 @@ discard block |
||
| 178 | 176 | try { |
| 179 | 177 | $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?"); |
| 180 | 178 | $sth->execute(array($key)); |
| 181 | - } |
|
| 182 | - catch (Exception $e) { |
|
| 179 | + } catch (Exception $e) { |
|
| 183 | 180 | $this->logger->error( |
| 184 | 181 | sprintf('Error deleting key "%s" from PDO StateStorage', $key), |
| 185 | 182 | array('exception' => $e) |
@@ -208,8 +205,7 @@ discard block |
||
| 208 | 205 | try { |
| 209 | 206 | $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
| 210 | 207 | $sth->execute(array($key, time())); |
| 211 | - } |
|
| 212 | - catch (Exception $e) { |
|
| 208 | + } catch (Exception $e) { |
|
| 213 | 209 | $this->logger->error( |
| 214 | 210 | sprintf('Error getting value for key "%s" from PDO StateStorage', $key), |
| 215 | 211 | array('exception' => $e) |
@@ -239,8 +235,7 @@ discard block |
||
| 239 | 235 | // Retrieve a random row from the table, this checks that the table exists and is readable |
| 240 | 236 | $sth = $this->handle->prepare('SELECT `value`, `key`, `expire` FROM ' . $this->tablename . ' LIMIT 1'); |
| 241 | 237 | $sth->execute(); |
| 242 | - } |
|
| 243 | - catch (Exception $e) { |
|
| 238 | + } catch (Exception $e) { |
|
| 244 | 239 | $statusMessage = sprintf('Error performing health check on PDO StateStorage: %s', $e->getMessage()); |
| 245 | 240 | return false; |
| 246 | 241 | } |
@@ -119,8 +119,7 @@ discard block |
||
| 119 | 119 | throw new RuntimeException('Unexpected return type'); |
| 120 | 120 | } |
| 121 | 121 | return $res; |
| 122 | - } |
|
| 123 | - catch (Exception $e) { |
|
| 122 | + } catch (Exception $e) { |
|
| 124 | 123 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
| 125 | 124 | throw ReadWriteException::fromOriginalException($e); |
| 126 | 125 | } |
@@ -158,8 +157,7 @@ discard block |
||
| 158 | 157 | throw new RuntimeException('Unexpected return type'); |
| 159 | 158 | } |
| 160 | 159 | return (int)$res; |
| 161 | - } |
|
| 162 | - catch (Exception $e) { |
|
| 160 | + } catch (Exception $e) { |
|
| 163 | 161 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
| 164 | 162 | throw ReadWriteException::fromOriginalException($e); |
| 165 | 163 | } |
@@ -186,8 +184,7 @@ discard block |
||
| 186 | 184 | throw new RuntimeException('User not found'); |
| 187 | 185 | } |
| 188 | 186 | } |
| 189 | - } |
|
| 190 | - catch (Exception $e) { |
|
| 187 | + } catch (Exception $e) { |
|
| 191 | 188 | $this->logger->error('PDO error updating user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
| 192 | 189 | throw ReadWriteException::fromOriginalException($e); |
| 193 | 190 | } |
@@ -214,8 +211,7 @@ discard block |
||
| 214 | 211 | throw new RuntimeException('User not found'); |
| 215 | 212 | } |
| 216 | 213 | } |
| 217 | - } |
|
| 218 | - catch (Exception $e) { |
|
| 214 | + } catch (Exception $e) { |
|
| 219 | 215 | $this->logger->error('PDO error updating user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
| 220 | 216 | throw ReadWriteException::fromOriginalException($e); |
| 221 | 217 | } |
@@ -232,8 +228,7 @@ discard block |
||
| 232 | 228 | try { |
| 233 | 229 | $sth = $this->handle->prepare("INSERT INTO ".$this->tablename." (displayname,userid) VALUES (?,?)"); |
| 234 | 230 | $sth->execute(array($displayName, $userId)); |
| 235 | - } |
|
| 236 | - catch (Exception $e) { |
|
| 231 | + } catch (Exception $e) { |
|
| 237 | 232 | $this->logger->error(sprintf('Error creating user "%s"', $userId), array('exception'=>$e)); |
| 238 | 233 | throw new ReadWriteException('The user could not be saved in the user storage (PDO)'); |
| 239 | 234 | } |
@@ -248,8 +243,7 @@ discard block |
||
| 248 | 243 | $sth = $this->handle->prepare("SELECT userid FROM ".$this->tablename." WHERE userid = ?"); |
| 249 | 244 | $sth->execute(array($userId)); |
| 250 | 245 | return (false !== $sth->fetchColumn()); |
| 251 | - } |
|
| 252 | - catch (Exception $e) { |
|
| 246 | + } catch (Exception $e) { |
|
| 253 | 247 | $this->logger->error('PDO error checking user exists', array('exception'=>$e, 'userId'=>$userId)); |
| 254 | 248 | throw ReadWriteException::fromOriginalException($e); |
| 255 | 249 | } |
@@ -382,8 +376,7 @@ discard block |
||
| 382 | 376 | try { |
| 383 | 377 | $sth = $this->handle->prepare('SELECT displayname, notificationtype, notificationaddress, loginattempts, tmpblockattempts, blocked, tmpblocktimestamp FROM '.$this->tablename.' LIMIT 1'); |
| 384 | 378 | $sth->execute(); |
| 385 | - } |
|
| 386 | - catch (Exception $e) { |
|
| 379 | + } catch (Exception $e) { |
|
| 387 | 380 | $statusMessage = "Error reading from UserStorage_PDO: ". $e->getMessage(); |
| 388 | 381 | return false; |
| 389 | 382 | } |
@@ -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 | |
@@ -90,8 +90,7 @@ discard block |
||
| 90 | 90 | $sth = $this->handle->prepare('SELECT userid FROM ' . $this->tableName . ' WHERE userid = ?'); |
| 91 | 91 | $sth->execute(array($userId)); |
| 92 | 92 | return (false !== $sth->fetchColumn()); |
| 93 | - } |
|
| 94 | - catch (Exception $e) { |
|
| 93 | + } catch (Exception $e) { |
|
| 95 | 94 | $this->logger->error('PDO error checking user exists', array('exception'=>$e, 'userId'=>$userId)); |
| 96 | 95 | throw ReadWriteException::fromOriginalException($e); |
| 97 | 96 | } |
@@ -115,8 +114,7 @@ discard block |
||
| 115 | 114 | $this->logger->error(sprintf('No result getting secret for user "%s"', $userId)); |
| 116 | 115 | throw new RuntimeException('User not found'); |
| 117 | 116 | } |
| 118 | - } |
|
| 119 | - catch (Exception $e) { |
|
| 117 | + } catch (Exception $e) { |
|
| 120 | 118 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId)); |
| 121 | 119 | throw ReadWriteException::fromOriginalException($e); |
| 122 | 120 | } |
@@ -150,8 +148,7 @@ discard block |
||
| 150 | 148 | $sth = $this->handle->prepare('INSERT INTO ' . $this->tableName . ' (secret,userid) VALUES (?,?)'); |
| 151 | 149 | } |
| 152 | 150 | $sth->execute(array($secret, $userId)); |
| 153 | - } |
|
| 154 | - catch (Exception $e) { |
|
| 151 | + } catch (Exception $e) { |
|
| 155 | 152 | $this->logger->error( |
| 156 | 153 | sprintf('Unable to persist user secret for user "%s" in user secret storage (PDO)', $userId), |
| 157 | 154 | array('exception'=>$e) |
@@ -169,8 +166,7 @@ discard block |
||
| 169 | 166 | try { |
| 170 | 167 | $sth = $this->handle->prepare('SELECT secret FROM '.$this->tableName.' LIMIT 1'); |
| 171 | 168 | $sth->execute(); |
| 172 | - } |
|
| 173 | - catch (Exception $e) { |
|
| 169 | + } catch (Exception $e) { |
|
| 174 | 170 | $statusMessage = "UserSecretStorage_PDO error: " . $e->getMessage(); |
| 175 | 171 | return false; |
| 176 | 172 | } |