|
@@ -190,26 +190,8 @@ class MultiExecContext {
|
|
$attemptsLeft = isset($this->_options['retry']) ? (int)$this->_options['retry'] : 0;
|
|
$attemptsLeft = isset($this->_options['retry']) ? (int)$this->_options['retry'] : 0;
|
|
|
|
|
|
do {
|
|
do {
|
|
- $blockException = null;
|
|
|
|
if ($block !== null) {
|
|
if ($block !== null) {
|
|
- $this->flagState(self::STATE_INSIDEBLOCK);
|
|
|
|
- try {
|
|
|
|
- $block($this);
|
|
|
|
- }
|
|
|
|
- catch (CommunicationException $exception) {
|
|
|
|
- $blockException = $exception;
|
|
|
|
- }
|
|
|
|
- catch (ServerException $exception) {
|
|
|
|
- $blockException = $exception;
|
|
|
|
- }
|
|
|
|
- catch (\Exception $exception) {
|
|
|
|
- $blockException = $exception;
|
|
|
|
- $this->discard();
|
|
|
|
- }
|
|
|
|
- $this->unflagState(self::STATE_INSIDEBLOCK);
|
|
|
|
- if ($blockException !== null) {
|
|
|
|
- throw $blockException;
|
|
|
|
- }
|
|
|
|
|
|
+ $this->executeTransactionBlock($block);
|
|
}
|
|
}
|
|
|
|
|
|
if (count($this->_commands) === 0) {
|
|
if (count($this->_commands) === 0) {
|
|
@@ -252,6 +234,28 @@ class MultiExecContext {
|
|
return $returnValues;
|
|
return $returnValues;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private function executeTransactionBlock($block) {
|
|
|
|
+ $blockException = null;
|
|
|
|
+ $this->flagState(self::STATE_INSIDEBLOCK);
|
|
|
|
+ try {
|
|
|
|
+ $block($this);
|
|
|
|
+ }
|
|
|
|
+ catch (CommunicationException $exception) {
|
|
|
|
+ $blockException = $exception;
|
|
|
|
+ }
|
|
|
|
+ catch (ServerException $exception) {
|
|
|
|
+ $blockException = $exception;
|
|
|
|
+ }
|
|
|
|
+ catch (\Exception $exception) {
|
|
|
|
+ $blockException = $exception;
|
|
|
|
+ $this->discard();
|
|
|
|
+ }
|
|
|
|
+ $this->unflagState(self::STATE_INSIDEBLOCK);
|
|
|
|
+ if ($blockException !== null) {
|
|
|
|
+ throw $blockException;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private function onProtocolError($message) {
|
|
private function onProtocolError($message) {
|
|
// Since a MULTI/EXEC block cannot be initialized over a clustered
|
|
// Since a MULTI/EXEC block cannot be initialized over a clustered
|
|
// connection, we can safely assume that Predis\Client::getConnection()
|
|
// connection, we can safely assume that Predis\Client::getConnection()
|