8000 bug #59160 [BeanstalkMessenger] Round delay to an integer to avoid de… · rch7/symfony@c78a9ec · GitHub
[go: up one dir, main page]

Skip to content

Commit c78a9ec

Browse files
committed
bug symfony#59160 [BeanstalkMessenger] Round delay to an integer to avoid deprecation warning (plantas)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [BeanstalkMessenger] Round delay to an integer to avoid deprecation warning | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | - | License | MIT https://github.com/pheanstalk/pheanstalk/blob/1459f2f62dddfe28902e0584708417dddd79bd70/src/Pheanstalk.php#L223-L228 The `Pheanstalk::put()` method expects the `$delay` parameter to be an integer. However, during the conversion from milliseconds to seconds, it is passed as a float. This triggers a deprecation warning: 'Deprecated: Implicit conversion from float to int loses precision.' Commits ------- 99aae50 [BeanstalkMessenger] Round delay to an integer to avoid deprecation warning
2 parents c439a58 + 99aae50 commit c78a9ec

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Symfony/Component/Messenger/Bridge/Beanstalkd/Tests/Transport/ConnectionTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,25 @@ public function testSendWhenABeanstalkdExceptionOccurs()
330330

331331
$connection->send($body, $headers, $delay);
332332
}
333+
334+
public function testSendWithRoundedDelay()
335+
{
336+
$tube = 'xyz';
337+
$body = 'foo';
338+
$headers = ['test' => 'bar'];
339+
$delay = 920;
340+
$expectedDelay = 0;
341+
342+
$client = $this->createMock(PheanstalkInterface::class);
343+
$client->expects($this->once())->method('useTube')->with($tube)->willReturn($client);
344+
$client->expects($this->once())->method('put')->with(
345+
$this->anything(),
346+
$this->anything(),
347+
$expectedDelay,
348+
$this->anything(),
349+
);
350+
351+
$connection = new Connection(['tube_name' => $tube], $client);
352+
$connection->send($body, $headers, $delay);
353+
}
333354
}

src/Symfony/Component/Messenger/Bridge/Beanstalkd/Transport/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function send(string $body, array $headers, int $delay = 0): string
123123
$job = $this->client->useTube($this->tube)->put(
124124
$message,
125125
PheanstalkInterface::DEFAULT_PRIORITY,
126-
$delay / 1000,
126+
(int) ($delay / 1000),
127127
$this->ttr
128128
);
129129
} catch (Exception $exception) {

0 commit comments

Comments
 (0)
0