@@ -80,8 +80,7 @@ discard block |
||
80 | 80 | $sth = $this->handle->prepare('SELECT `key` FROM ' . $this->tablename . ' WHERE `key` = ?'); |
81 | 81 | $sth->execute(array($key)); |
82 | 82 | return $sth->fetchColumn() !== false; |
83 | - } |
|
84 | - catch (Exception $e) { |
|
83 | + } catch (Exception $e) { |
|
85 | 84 | $this->logger->error( |
86 | 85 | sprintf('Error checking for key "%s" in PDO StateStorage', $key), |
87 | 86 | array('exception' => $e) |
@@ -103,8 +102,7 @@ discard block |
||
103 | 102 | $this->logger->notice( |
104 | 103 | sprintf("Deleted %d expired keys", $deletedRows) |
105 | 104 | ); |
106 | - } |
|
107 | - catch (Exception $e) { |
|
105 | + } catch (Exception $e) { |
|
108 | 106 | $this->logger->error( |
109 | 107 | sprintf("Deleting expired keys failed: %s", $e->getMessage()), |
110 | 108 | array('exception', $e) |
@@ -134,8 +132,7 @@ discard block |
||
134 | 132 | } |
135 | 133 | try { |
136 | 134 | $sth->execute(array(serialize($value), $expire, $key)); |
137 | - } |
|
138 | - catch (Exception $e) { |
|
135 | + } catch (Exception $e) { |
|
139 | 136 | $this->logger->error( |
140 | 137 | sprintf('Unable to store key "%s" in PDO StateStorage', $key), |
141 | 138 | array('exception' => $e) |
@@ -155,8 +152,7 @@ discard block |
||
155 | 152 | try { |
156 | 153 | $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?"); |
157 | 154 | $sth->execute(array($key)); |
158 | - } |
|
159 | - catch (Exception $e) { |
|
155 | + } catch (Exception $e) { |
|
160 | 156 | $this->logger->error( |
161 | 157 | sprintf('Error deleting key "%s" from PDO StateStorage', $key), |
162 | 158 | array('exception' => $e) |
@@ -185,8 +181,7 @@ discard block |
||
185 | 181 | try { |
186 | 182 | $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
187 | 183 | $sth->execute(array($key, time())); |
188 | - } |
|
189 | - catch (Exception $e) { |
|
184 | + } catch (Exception $e) { |
|
190 | 185 | $this->logger->error( |
191 | 186 | sprintf('Error getting value for key "%s" from PDO StateStorage', $key), |
192 | 187 | array('exception' => $e) |
@@ -59,7 +59,6 @@ |
||
59 | 59 | ); |
60 | 60 | |
61 | 61 | CREATE INDEX IF NOT EXISTS index_tiqrstate_expire ON tiqrstate (expire); |
62 | - |
|
63 | 62 | * @see Tiqr_StateStorage::getStorage() |
64 | 63 | * @see Tiqr_StateStorage_StateStorageInterface |
65 | 64 | * |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | throw new InvalidArgumentException('Empty key not allowed'); |
122 | 122 | } |
123 | 123 | try { |
124 | - $sth = $this->handle->prepare('SELECT `key` FROM ' . $this->tablename . ' WHERE `key` = ?'); |
|
124 | + $sth = $this->handle->prepare('SELECT `key` FROM '.$this->tablename.' WHERE `key` = ?'); |
|
125 | 125 | $sth->execute(array($key)); |
126 | 126 | return $sth->fetchColumn() !== false; |
127 | 127 | } |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | */ |
142 | 142 | private function cleanExpired(): void { |
143 | 143 | try { |
144 | - $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `expire` < ? AND NOT `expire` = 0"); |
|
144 | + $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `expire` < ? AND NOT `expire` = 0"); |
|
145 | 145 | $sth->execute(array(time())); |
146 | - $deletedRows=$sth->rowCount(); |
|
146 | + $deletedRows = $sth->rowCount(); |
|
147 | 147 | $this->logger->notice( |
148 | 148 | sprintf("Deleted %d expired keys", $deletedRows) |
149 | 149 | ); |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | /** |
160 | 160 | * @see Tiqr_StateStorage_StateStorageInterface::setValue() |
161 | 161 | */ |
162 | - public function setValue(string $key, $value, int $expire=0): void |
|
162 | + public function setValue(string $key, $value, int $expire = 0): void |
|
163 | 163 | { |
164 | 164 | if (empty($key)) { |
165 | 165 | throw new InvalidArgumentException('Empty key not allowed'); |
166 | 166 | } |
167 | - if (((float) rand() /(float) getrandmax()) < $this->cleanupProbability) { |
|
167 | + if (((float) rand() / (float) getrandmax()) < $this->cleanupProbability) { |
|
168 | 168 | $this->cleanExpired(); |
169 | 169 | } |
170 | 170 | if ($this->keyExists($key)) { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | } |
175 | 175 | // $expire == 0 means never expire |
176 | 176 | if ($expire != 0) { |
177 | - $expire+=time(); // Store unix timestamp after which the key expires |
|
177 | + $expire += time(); // Store unix timestamp after which the key expires |
|
178 | 178 | } |
179 | 179 | try { |
180 | 180 | $sth->execute(array(serialize($value), $expire, $key)); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | throw new InvalidArgumentException('Empty key not allowed'); |
198 | 198 | } |
199 | 199 | try { |
200 | - $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?"); |
|
200 | + $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `key` = ?"); |
|
201 | 201 | $sth->execute(array($key)); |
202 | 202 | } |
203 | 203 | catch (Exception $e) { |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | try { |
230 | - $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
|
230 | + $sth = $this->handle->prepare('SELECT `value` FROM '.$this->tablename.' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
|
231 | 231 | $sth->execute(array($key, time())); |
232 | 232 | } |
233 | 233 | catch (Exception $e) { |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | if (false === $result) { |
242 | 242 | // Occurs normally |
243 | 243 | $this->logger->info(sprintf('getValue: Key "%s" not found in PDO StateStorage', $key)); |
244 | - return NULL; // Key not found |
|
244 | + return NULL; // Key not found |
|
245 | 245 | } |
246 | - $result=unserialize($result, array('allowed_classes' => false)); |
|
246 | + $result = unserialize($result, array('allowed_classes' => false)); |
|
247 | 247 | if (false === $result) { |
248 | 248 | throw new RuntimeException(sprintf('getValue: unserialize error for key "%s" in PDO StateStorage', $key)); |
249 | 249 | } |
@@ -35,7 +35,6 @@ |
||
35 | 35 | * Supported options: |
36 | 36 | * path : Path to the directory where the user data is stored |
37 | 37 | * |
38 | - |
|
39 | 38 | */ |
40 | 39 | class Tiqr_UserSecretStorage_File implements Tiqr_UserSecretStorage_Interface |
41 | 40 | { |
@@ -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 | * |