Skip to content

Commit 4c91e72

Browse files
committed
Merge branch 'v5.4'
2 parents aa076f7 + 543248a commit 4c91e72

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/RabbitMQQueue.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ public function pushRaw($payload, $queue = null, array $options = [])
101101
{
102102
try {
103103
$queue = $this->getQueueName($queue);
104-
$this->declareQueue($queue);
105104
if (isset($options['delay']) && $options['delay'] > 0) {
106105
list($queue, $exchange) = $this->declareDelayedQueue($queue, $options['delay']);
107106
} else {
@@ -113,7 +112,7 @@ public function pushRaw($payload, $queue = null, array $options = [])
113112
'delivery_mode' => 2,
114113
];
115114

116-
if (isset($this->retryAfter) === true) {
115+
if ($this->retryAfter !== null) {
117116
$headers['application_headers'] = [self::ATTEMPT_COUNT_HEADERS_KEY => ['I', $this->retryAfter]];
118117
}
119118

@@ -201,7 +200,7 @@ private function declareQueue($name)
201200
$name = $this->getQueueName($name);
202201
$exchange = $this->configExchange['name'] ?: $name;
203202

204-
if ($this->declareExchange && !in_array($exchange, $this->declaredExchanges)) {
203+
if ($this->declareExchange && !in_array($exchange, $this->declaredExchanges, true)) {
205204
// declare exchange
206205
$this->channel->exchange_declare(
207206
$exchange,
@@ -214,7 +213,7 @@ private function declareQueue($name)
214213
$this->declaredExchanges[] = $exchange;
215214
}
216215

217-
if ($this->declareBindQueue && !in_array($name, $this->declaredQueues)) {
216+
if ($this->declareBindQueue && !in_array($name, $this->declaredQueues, true)) {
218217
// declare queue
219218
$this->channel->queue_declare(
220219
$name,
@@ -237,7 +236,7 @@ private function declareQueue($name)
237236
* @param string $destination
238237
* @param DateTime|int $delay
239238
*
240-
* @return string
239+
* @return array
241240
*/
242241
private function declareDelayedQueue($destination, $delay)
243242
{
@@ -248,7 +247,7 @@ private function declareDelayedQueue($destination, $delay)
248247
$exchange = $this->configExchange['name'] ?: $destination;
249248

250249
// declare exchange
251-
if (!in_array($exchange, $this->declaredExchanges)) {
250+
if (!in_array($exchange, $this->declaredExchanges, true)) {
252251
$this->channel->exchange_declare(
253252
$exchange,
254253
$this->configExchange['type'],
@@ -259,7 +258,7 @@ private function declareDelayedQueue($destination, $delay)
259258
}
260259

261260
// declare queue
262-
if (!in_array($name, $this->declaredQueues)) {
261+
if (!in_array($name, $this->declaredQueues, true)) {
263262
$this->channel->queue_declare(
264263
$name,
265264
$this->configQueue['passive'],
@@ -312,7 +311,7 @@ public function setCorrelationId($id)
312311
*/
313312
public function getCorrelationId()
314313
{
315-
return $this->correlationId ?: uniqid();
314+
return $this->correlationId ?: uniqid('', true);
316315
}
317316

318317
/**

tests/RabbitMQQueueTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function test_push()
8282

8383
$correlationId = $this->queue->push($job, $data);
8484

85-
$this->assertEquals(13, strlen($correlationId));
85+
$this->assertEquals(23, strlen($correlationId));
8686
}
8787

8888
public function test_later()
@@ -119,7 +119,7 @@ public function test_later()
119119

120120
$correlationId = $this->queue->later($delay, $job, $data);
121121

122-
$this->assertEquals(13, strlen($correlationId));
122+
$this->assertEquals(23, strlen($correlationId));
123123
}
124124

125125
public function test_pop()

0 commit comments

Comments
 (0)