Awight has uploaded a new change for review.
https://gerrit.wikimedia.org/r/232885
Change subject: Interpret Predis status codes
......................................................................
Interpret Predis status codes
I'm pretty sure we were going to convert "ERR" to trueish, otherwise.
Change-Id: Ic669a7259b5eae03f3c366e812b0039325363678
---
M src/PHPQueue/Backend/Predis.php
1 file changed, 9 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/php-queue
refs/changes/85/232885/1
diff --git a/src/PHPQueue/Backend/Predis.php b/src/PHPQueue/Backend/Predis.php
index 4a46948..1fc30c9 100644
--- a/src/PHPQueue/Backend/Predis.php
+++ b/src/PHPQueue/Backend/Predis.php
@@ -1,6 +1,7 @@
<?php
namespace PHPQueue\Backend;
+use Predis\Response\ResponseInterface;
use Predis\Transaction\MultiExec;
use PHPQueue\Exception\BackendException;
@@ -298,7 +299,7 @@
$status = $this->getConnection()->set($key, $data);
}
}
- if (!$status) {
+ if (!self::boolStatus($status)) {
throw new BackendException("Unable to save data.");
}
} catch (\Exception $ex) {
@@ -311,6 +312,7 @@
*
* @param string $key
* @param array $data
+ * @return Predis\Response\ResponseInterface
*/
protected function addToIndexedFifoQueue($key, $data)
{
@@ -422,7 +424,7 @@
$status = $this->getConnection()->incrby($key, $count);
}
- return $status;
+ return is_int($status);
}
public function decrKey($key, $count=1)
@@ -436,7 +438,7 @@
$status = $this->getConnection()->decrby($key, $count);
}
- return $status;
+ return is_int($status);
}
public function keyExists($key)
@@ -449,4 +451,8 @@
{
return !empty($this->queue_name);
}
+
+ protected static function boolStatus(ResponseInterface $status) {
+ return ($status == 'OK' || $status == 'QUEUED');
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/232885
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic669a7259b5eae03f3c366e812b0039325363678
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/php-queue
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits