@@ -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 | } |
@@ -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) |