@@ -74,8 +74,7 @@ |
||
74 | 74 | $credentials['ssl'], |
75 | 75 | $credentials['options'] |
76 | 76 | ); |
77 | - } |
|
78 | - else { |
|
77 | + } else { |
|
79 | 78 | $connection = new AMQPStreamConnection( |
80 | 79 | $credentials['host'], |
81 | 80 | $credentials['port'], |
@@ -27,8 +27,7 @@ |
||
27 | 27 | try { |
28 | 28 | /** @var \Drupal\rabbitmq\Queue\Queue $backend */ |
29 | 29 | $backend = \Drupal::queue('queue.rabbitmq'); |
30 | - } |
|
31 | - catch (\ErrorException $e) { |
|
30 | + } catch (\ErrorException $e) { |
|
32 | 31 | $build = [ |
33 | 32 | '#markup' => $this->t('<h2>Error</h2><p>Could not access the queue. Check the <a href=":url">status page</a>.</p>', [ |
34 | 33 | ':url' => Url::fromRoute('system.status')->toString(), |
@@ -144,8 +144,7 @@ discard block |
||
144 | 144 | public function decode($data) { |
145 | 145 | if (isset($this->decoder)) { |
146 | 146 | return $this->decoder($data); |
147 | - } |
|
148 | - else { |
|
147 | + } else { |
|
149 | 148 | return json_decode($data, TRUE); |
150 | 149 | } |
151 | 150 | } |
@@ -177,8 +176,7 @@ discard block |
||
177 | 176 | if ($maxIterations > 0) { |
178 | 177 | $readyMessage = "RabbitMQ worker ready to receive up to @count messages."; |
179 | 178 | $readyArgs = ['@count' => $maxIterations]; |
180 | - } |
|
181 | - else { |
|
179 | + } else { |
|
182 | 180 | $readyMessage = "RabbitMQ worker ready to receive an unlimited number of messages."; |
183 | 181 | $readyArgs = []; |
184 | 182 | } |
@@ -261,15 +259,12 @@ discard block |
||
261 | 259 | } |
262 | 260 | } |
263 | 261 | $this->stopListening(); |
264 | - } |
|
265 | - catch (AMQPIOWaitException $e) { |
|
262 | + } catch (AMQPIOWaitException $e) { |
|
266 | 263 | $this->stopListening(); |
267 | 264 | $channel->close(); |
268 | - } |
|
269 | - catch (AMQPTimeoutException $e) { |
|
265 | + } catch (AMQPTimeoutException $e) { |
|
270 | 266 | $this->startListening(); |
271 | - } |
|
272 | - catch (Exception $e) { |
|
267 | + } catch (Exception $e) { |
|
273 | 268 | throw new Exception('Could not obtain channel for queue.', 0, $e); |
274 | 269 | } |
275 | 270 | } |
@@ -304,8 +299,7 @@ discard block |
||
304 | 299 | $timeout = $this->getOption(self::OPTION_TIMEOUT); |
305 | 300 | if (!empty($timeout)) { |
306 | 301 | pcntl_signal(SIGALRM, [$this, 'onTimeout']); |
307 | - } |
|
308 | - else { |
|
302 | + } else { |
|
309 | 303 | $timeout = 0; |
310 | 304 | } |
311 | 305 | |
@@ -317,8 +311,7 @@ discard block |
||
317 | 311 | pcntl_alarm($timeout); |
318 | 312 | $item = $queue->claimItem(); |
319 | 313 | pcntl_alarm(0); |
320 | - } |
|
321 | - else { |
|
314 | + } else { |
|
322 | 315 | $item = $queue->claimItem(); |
323 | 316 | } |
324 | 317 | |
@@ -335,8 +328,7 @@ discard block |
||
335 | 328 | // Only loop if the current continuous wait did not exceed timeout. |
336 | 329 | if ($currentTime > $startTime + $timeout) { |
337 | 330 | break; |
338 | - } |
|
339 | - else { |
|
331 | + } else { |
|
340 | 332 | continue; |
341 | 333 | } |
342 | 334 | } |
@@ -427,8 +419,7 @@ discard block |
||
427 | 419 | '@id' => $item->id, |
428 | 420 | '@queue' => $queueName, |
429 | 421 | ]); |
430 | - } |
|
431 | - catch (Exception $e) { |
|
422 | + } catch (Exception $e) { |
|
432 | 423 | watchdog_exception('rabbitmq', $e); |
433 | 424 | $msg->delivery_info['channel']->basic_reject($msg->delivery_info['delivery_tag'], |
434 | 425 | TRUE); |
@@ -563,8 +554,7 @@ discard block |
||
563 | 554 | if (!extension_loaded(static::EXTENSION_PCNTL)) { |
564 | 555 | $req[$key]['description'] = t('Extension <a href=":ext">PCNTL</a> not present in PHP. Option %option is not available in the RabbitMQ consumer.', $options); |
565 | 556 | $req[$key]['severity'] = REQUIREMENT_WARNING; |
566 | - } |
|
567 | - else { |
|
557 | + } else { |
|
568 | 558 | $req[$key]['description'] = t('Extension <a href=":ext">PCNTL</a> is present in PHP. Option %option is available in the RabbitMQ consumer.', $options); |
569 | 559 | $req[$key]['severity'] = REQUIREMENT_OK; |
570 | 560 | } |
@@ -170,8 +170,7 @@ |
||
170 | 170 | $actualOptions['arguments'] ?? NULL, |
171 | 171 | $actualOptions['ticket'] ?? NULL |
172 | 172 | ); |
173 | - } |
|
174 | - catch (AMQPProtocolChannelException $e) { |
|
173 | + } catch (AMQPProtocolChannelException $e) { |
|
175 | 174 | return NULL; |
176 | 175 | } |
177 | 176 |
@@ -49,8 +49,7 @@ |
||
49 | 49 | $channel->basic_publish($item, $exchange, $routing_key); |
50 | 50 | $this->logger->debug('Item sent to queue %queue', $logger_args); |
51 | 51 | $result = TRUE; |
52 | - } |
|
53 | - catch (\Exception $e) { |
|
52 | + } catch (\Exception $e) { |
|
54 | 53 | $this->logger->error('Failed to send item to queue %queue: @message', $logger_args + [ |
55 | 54 | '@message' => $e->getMessage(), |
56 | 55 | ]); |
@@ -116,14 +116,11 @@ |
||
116 | 116 | try { |
117 | 117 | $consumer->logStart(); |
118 | 118 | $consumer->consumeQueueApi($queueName); |
119 | - } |
|
120 | - catch (InvalidWorkerException $e) { |
|
119 | + } catch (InvalidWorkerException $e) { |
|
121 | 120 | return drush_set_error(dt("Worker for queue @name does not implement the worker interface.", $queueArgs)); |
122 | - } |
|
123 | - catch (RabbitMqInvalidArgumentException $e) { |
|
121 | + } catch (RabbitMqInvalidArgumentException $e) { |
|
124 | 122 | return drush_set_error($e->getMessage()); |
125 | - } |
|
126 | - catch (RabbitMqException $e) { |
|
123 | + } catch (RabbitMqException $e) { |
|
127 | 124 | return drush_set_error(dt("Could not obtain channel for queue.", $queueArgs)); |
128 | 125 | } |
129 | 126 |