@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * @see Tiqr_StateStorage_StateStorageInterface::setValue() |
49 | 49 | */ |
50 | - public function setValue(string $key, $value, int $expire=0): void |
|
50 | + public function setValue(string $key, $value, int $expire = 0): void |
|
51 | 51 | { |
52 | 52 | if (empty($key)) { |
53 | 53 | throw new InvalidArgumentException('Empty key not allowed'); |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | |
110 | 110 | private function getPath(): string |
111 | 111 | { |
112 | - if (substr($this->path, -1)!=="/") { |
|
113 | - return $this->path . "/"; |
|
112 | + if (substr($this->path, -1) !== "/") { |
|
113 | + return $this->path."/"; |
|
114 | 114 | } |
115 | 115 | return $this->path; |
116 | 116 | } |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | // Generate a random key and use it to store a value |
142 | 142 | $key = bin2hex(random_bytes(16)); |
143 | 143 | $this->setValue($key, 'healthcheck', 10); |
144 | - $this->unsetValue($key); // Cleanup |
|
144 | + $this->unsetValue($key); // Cleanup |
|
145 | 145 | } catch (Exception $e) { |
146 | - $statusMessage = 'Tiqr_StateStorage_File: error setting key: ' . $e->getMessage(); |
|
146 | + $statusMessage = 'Tiqr_StateStorage_File: error setting key: '.$e->getMessage(); |
|
147 | 147 | return false; |
148 | 148 | } |
149 | 149 |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | */ |
118 | 118 | private function cleanExpired(): void { |
119 | 119 | try { |
120 | - $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `expire` < ? AND NOT `expire` = 0"); |
|
120 | + $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `expire` < ? AND NOT `expire` = 0"); |
|
121 | 121 | $sth->execute(array(time())); |
122 | - $deletedRows=$sth->rowCount(); |
|
122 | + $deletedRows = $sth->rowCount(); |
|
123 | 123 | $this->logger->notice( |
124 | 124 | sprintf("Deleted %d expired keys", $deletedRows) |
125 | 125 | ); |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | /** |
136 | 136 | * @see Tiqr_StateStorage_StateStorageInterface::setValue() |
137 | 137 | */ |
138 | - public function setValue(string $key, $value, int $expire=0): void |
|
138 | + public function setValue(string $key, $value, int $expire = 0): void |
|
139 | 139 | { |
140 | 140 | if (empty($key)) { |
141 | 141 | throw new InvalidArgumentException('Empty key not allowed'); |
142 | 142 | } |
143 | - if (((float) rand() /(float) getrandmax()) < $this->cleanupProbability) { |
|
143 | + if (((float) rand() / (float) getrandmax()) < $this->cleanupProbability) { |
|
144 | 144 | $this->cleanExpired(); |
145 | 145 | } |
146 | 146 | // REPLACE INTO is mysql dialect. Supported by sqlite as well. |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | // $expire == 0 means never expire |
155 | 155 | if ($expire != 0) { |
156 | - $expire+=time(); // Store unix timestamp after which the key expires |
|
156 | + $expire += time(); // Store unix timestamp after which the key expires |
|
157 | 157 | } |
158 | 158 | try { |
159 | 159 | $sth->execute(array(serialize($value), $expire, $key)); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | throw new InvalidArgumentException('Empty key not allowed'); |
177 | 177 | } |
178 | 178 | try { |
179 | - $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?"); |
|
179 | + $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `key` = ?"); |
|
180 | 180 | $sth->execute(array($key)); |
181 | 181 | } |
182 | 182 | catch (Exception $e) { |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | try { |
209 | - $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
|
209 | + $sth = $this->handle->prepare('SELECT `value` FROM '.$this->tablename.' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
|
210 | 210 | $sth->execute(array($key, time())); |
211 | 211 | } |
212 | 212 | catch (Exception $e) { |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | if (false === $result) { |
221 | 221 | // Occurs normally |
222 | 222 | $this->logger->info(sprintf('getValue: Key "%s" not found in PDO StateStorage', $key)); |
223 | - return NULL; // Key not found |
|
223 | + return NULL; // Key not found |
|
224 | 224 | } |
225 | - $result=unserialize($result, array('allowed_classes' => false)); |
|
225 | + $result = unserialize($result, array('allowed_classes' => false)); |
|
226 | 226 | if (false === $result) { |
227 | 227 | throw new RuntimeException(sprintf('getValue: unserialize error for key "%s" in PDO StateStorage', $key)); |
228 | 228 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | { |
238 | 238 | try { |
239 | 239 | // Retrieve a random row from the table, this checks that the table exists and is readable |
240 | - $sth = $this->handle->prepare('SELECT `value`, `key`, `expire` FROM ' . $this->tablename . ' LIMIT 1'); |
|
240 | + $sth = $this->handle->prepare('SELECT `value`, `key`, `expire` FROM '.$this->tablename.' LIMIT 1'); |
|
241 | 241 | $sth->execute(); |
242 | 242 | } |
243 | 243 | catch (Exception $e) { |
@@ -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 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * The default configuration |
52 | 52 | */ |
53 | 53 | const DEFAULT_HOST = '127.0.0.1'; |
54 | - const DEFAULT_PORT = 11211; |
|
54 | + const DEFAULT_PORT = 11211; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Get the prefix to use for all keys in memcache. |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | /** |
107 | 107 | * @see Tiqr_StateStorage_StateStorageInterface::setValue() |
108 | 108 | */ |
109 | - public function setValue(string $key, $value, int $expire=0): void |
|
109 | + public function setValue(string $key, $value, int $expire = 0): void |
|
110 | 110 | { |
111 | 111 | if (empty($key)) { |
112 | 112 | throw new InvalidArgumentException('Empty key not allowed'); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | if ($result === false) { |
161 | 161 | // Memcache interface does not provide error information, either the key does not exist or |
162 | 162 | // there was an error communicating with the memcache |
163 | - $this->logger->info( sprintf('Unable to get key "%s" from memcache StateStorage', $key) ); |
|
163 | + $this->logger->info(sprintf('Unable to get key "%s" from memcache StateStorage', $key)); |
|
164 | 164 | return null; |
165 | 165 | } |
166 | 166 | return $result; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $key = bin2hex(random_bytes(16)); |
177 | 177 | $this->setValue($key, 'healthcheck', 10); |
178 | 178 | } catch (Exception $e) { |
179 | - $statusMessage = 'Unable to store key in memcache: ' . $e->getMessage(); |
|
179 | + $statusMessage = 'Unable to store key in memcache: '.$e->getMessage(); |
|
180 | 180 | return false; |
181 | 181 | } |
182 | 182 |
@@ -71,6 +71,6 @@ |
||
71 | 71 | */ |
72 | 72 | public function healthCheck(string &$statusMessage = ''): bool |
73 | 73 | { |
74 | - return true; // Health check is always successful when not implemented |
|
74 | + return true; // Health check is always successful when not implemented |
|
75 | 75 | } |
76 | 76 | } |
@@ -98,21 +98,21 @@ discard block |
||
98 | 98 | */ |
99 | 99 | private function _getStringValue(string $columnName, string $userId): string |
100 | 100 | { |
101 | - if ( !in_array($columnName, $this->_allowedStringColumns) ) { |
|
101 | + if (!in_array($columnName, $this->_allowedStringColumns)) { |
|
102 | 102 | throw new InvalidArgumentException('Unsupported column name'); |
103 | 103 | } |
104 | 104 | |
105 | 105 | try { |
106 | - $sth = $this->handle->prepare('SELECT ' . $columnName . ' FROM ' . $this->tablename . ' WHERE userid = ?'); |
|
106 | + $sth = $this->handle->prepare('SELECT '.$columnName.' FROM '.$this->tablename.' WHERE userid = ?'); |
|
107 | 107 | $sth->execute(array($userId)); |
108 | - $res=$sth->fetchColumn(); |
|
108 | + $res = $sth->fetchColumn(); |
|
109 | 109 | if ($res === false) { |
110 | 110 | // No result |
111 | 111 | $this->logger->error(sprintf('No result getting "%s" for user "%s"', $columnName, $userId)); |
112 | 112 | throw new RuntimeException('User not found'); |
113 | 113 | } |
114 | 114 | if ($res === NULL) { |
115 | - return ''; // Value unset |
|
115 | + return ''; // Value unset |
|
116 | 116 | } |
117 | 117 | if (!is_string($res)) { |
118 | 118 | $this->logger->error(sprintf('Expected string type while getting "%s" for user "%s"', $columnName, $userId)); |
@@ -136,28 +136,28 @@ discard block |
||
136 | 136 | */ |
137 | 137 | private function _getIntValue(string $columnName, string $userId): int |
138 | 138 | { |
139 | - if ( !in_array($columnName, $this->_allowedIntColumns) ) { |
|
139 | + if (!in_array($columnName, $this->_allowedIntColumns)) { |
|
140 | 140 | throw new InvalidArgumentException('Unsupported column name'); |
141 | 141 | } |
142 | 142 | |
143 | 143 | try { |
144 | - $sth = $this->handle->prepare('SELECT ' . $columnName . ' FROM ' . $this->tablename . ' WHERE userid = ?'); |
|
144 | + $sth = $this->handle->prepare('SELECT '.$columnName.' FROM '.$this->tablename.' WHERE userid = ?'); |
|
145 | 145 | $sth->execute(array($userId)); |
146 | - $res=$sth->fetchColumn(); |
|
146 | + $res = $sth->fetchColumn(); |
|
147 | 147 | if ($res === false) { |
148 | 148 | // No result |
149 | 149 | $this->logger->error(sprintf('No result getting "%s" for user "%s"', $columnName, $userId)); |
150 | 150 | throw new RuntimeException('User not found'); |
151 | 151 | } |
152 | 152 | if ($res === NULL) { |
153 | - return 0; // Value unset |
|
153 | + return 0; // Value unset |
|
154 | 154 | } |
155 | 155 | // Return type for integers depends on the PDO driver, can be string |
156 | 156 | if (!is_numeric($res)) { |
157 | 157 | $this->logger->error(sprintf('Expected int type while getting "%s" for user "%s"', $columnName, $userId)); |
158 | 158 | throw new RuntimeException('Unexpected return type'); |
159 | 159 | } |
160 | - return (int)$res; |
|
160 | + return (int) $res; |
|
161 | 161 | } |
162 | 162 | catch (Exception $e) { |
163 | 163 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | */ |
175 | 175 | private function _setStringValue(string $columnName, string $userId, string $value): void |
176 | 176 | { |
177 | - if ( !in_array($columnName, $this->_allowedStringColumns) ) { |
|
177 | + if (!in_array($columnName, $this->_allowedStringColumns)) { |
|
178 | 178 | throw new InvalidArgumentException('Unsupported column name'); |
179 | 179 | } |
180 | 180 | try { |
181 | - $sth = $this->handle->prepare('UPDATE ' . $this->tablename . ' SET ' . $columnName . ' = ? WHERE userid = ?'); |
|
181 | + $sth = $this->handle->prepare('UPDATE '.$this->tablename.' SET '.$columnName.' = ? WHERE userid = ?'); |
|
182 | 182 | $sth->execute(array($value, $userId)); |
183 | 183 | if ($sth->rowCount() == 0) { |
184 | 184 | // Required for mysql which only returns the number of rows that were actually updated |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | */ |
203 | 203 | private function _setIntValue(string $columnName, string $userId, int $value): void |
204 | 204 | { |
205 | - if ( !in_array($columnName, $this->_allowedIntColumns) ) { |
|
205 | + if (!in_array($columnName, $this->_allowedIntColumns)) { |
|
206 | 206 | throw new InvalidArgumentException('Unsupported column name'); |
207 | 207 | } |
208 | 208 | try { |
209 | - $sth = $this->handle->prepare('UPDATE ' . $this->tablename . ' SET ' . $columnName . ' = ? WHERE userid = ?'); |
|
209 | + $sth = $this->handle->prepare('UPDATE '.$this->tablename.' SET '.$columnName.' = ? WHERE userid = ?'); |
|
210 | 210 | $sth->execute(array($value, $userId)); |
211 | 211 | if ($sth->rowCount() == 0) { |
212 | 212 | // Required for mysql which only returns the number of rows that were actually updated |
@@ -318,17 +318,17 @@ discard block |
||
318 | 318 | { |
319 | 319 | // Check for blocked |
320 | 320 | if ($this->_getIntValue('blocked', $userId) != 0) { |
321 | - return true; // Blocked |
|
321 | + return true; // Blocked |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | if (0 == $tempBlockDuration) { |
325 | - return false; // No check for temporary block |
|
325 | + return false; // No check for temporary block |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | // Check for temporary block |
329 | 329 | $timestamp = $this->getTemporaryBlockTimestamp($userId); |
330 | 330 | // if no temporary block timestamp is set or if the temporary block is expired, return false |
331 | - if ( 0 == $timestamp || ($timestamp + $tempBlockDuration * 60) < time()) { |
|
331 | + if (0 == $timestamp || ($timestamp + $tempBlockDuration * 60) < time()) { |
|
332 | 332 | return false; |
333 | 333 | } |
334 | 334 | return true; |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | $sth->execute(); |
385 | 385 | } |
386 | 386 | catch (Exception $e) { |
387 | - $statusMessage = "Error reading from UserStorage_PDO: ". $e->getMessage(); |
|
387 | + $statusMessage = "Error reading from UserStorage_PDO: ".$e->getMessage(); |
|
388 | 388 | return false; |
389 | 389 | } |
390 | 390 |
@@ -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 | } |
@@ -51,6 +51,6 @@ |
||
51 | 51 | */ |
52 | 52 | public function healthCheck(string &$statusMessage = ''): bool |
53 | 53 | { |
54 | - return true; // Health check is always successful when not implemented |
|
54 | + return true; // Health check is always successful when not implemented |
|
55 | 55 | } |
56 | 56 | } |
@@ -74,7 +74,7 @@ |
||
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) != "/") return $this->path."/"; |
|
78 | 78 | return $this->path; |
79 | 79 | } |
80 | 80 |
@@ -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 |
@@ -32,7 +32,6 @@ |
||
32 | 32 | * Supported options: |
33 | 33 | * path : Path to the directory where the user data is stored |
34 | 34 | * |
35 | - |
|
36 | 35 | */ |
37 | 36 | class Tiqr_UserSecretStorage_File extends Tiqr_UserSecretStorage_Abstract |
38 | 37 | { |
@@ -80,7 +80,7 @@ |
||
80 | 80 | */ |
81 | 81 | protected function setUserSecret(string $userId, string $secret): void |
82 | 82 | { |
83 | - $data=array(); |
|
83 | + $data = array(); |
|
84 | 84 | if ($this->_userExists($userId)) { |
85 | 85 | $data = $this->_loadUser($userId); |
86 | 86 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | public function userExists(string $userId): bool |
88 | 88 | { |
89 | 89 | try { |
90 | - $sth = $this->handle->prepare('SELECT userid FROM ' . $this->tableName . ' WHERE userid = ?'); |
|
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 | 93 | } |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | protected function getUserSecret(string $userId): string |
108 | 108 | { |
109 | 109 | try { |
110 | - $sth = $this->handle->prepare('SELECT secret FROM ' . $this->tableName . ' WHERE userid = ?'); |
|
110 | + $sth = $this->handle->prepare('SELECT secret FROM '.$this->tableName.' WHERE userid = ?'); |
|
111 | 111 | $sth->execute(array($userId)); |
112 | - $res=$sth->fetchColumn(); |
|
112 | + $res = $sth->fetchColumn(); |
|
113 | 113 | if ($res === false) { |
114 | 114 | // No result |
115 | 115 | $this->logger->error(sprintf('No result getting secret for user "%s"', $userId)); |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | // - The INSERT will fail when displayname has a NOT NULL constraint |
146 | 146 | try { |
147 | 147 | if ($this->userExists($userId)) { |
148 | - $sth = $this->handle->prepare('UPDATE ' . $this->tableName . ' SET secret = ? WHERE userid = ?'); |
|
148 | + $sth = $this->handle->prepare('UPDATE '.$this->tableName.' SET secret = ? WHERE userid = ?'); |
|
149 | 149 | } else { |
150 | - $sth = $this->handle->prepare('INSERT INTO ' . $this->tableName . ' (secret,userid) VALUES (?,?)'); |
|
150 | + $sth = $this->handle->prepare('INSERT INTO '.$this->tableName.' (secret,userid) VALUES (?,?)'); |
|
151 | 151 | } |
152 | 152 | $sth->execute(array($secret, $userId)); |
153 | 153 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $sth->execute(); |
172 | 172 | } |
173 | 173 | catch (Exception $e) { |
174 | - $statusMessage = "UserSecretStorage_PDO error: " . $e->getMessage(); |
|
174 | + $statusMessage = "UserSecretStorage_PDO error: ".$e->getMessage(); |
|
175 | 175 | return false; |
176 | 176 | } |
177 | 177 |
@@ -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 | } |