8000 minor #27100 [Messenger] Late collect & clone messages (ogizanagi) · symfony/symfony@74aa515 · GitHub
[go: up one dir, main page]

Skip to content

Commit 74aa515

Browse files
committed
minor #27100 [Messenger] Late collect & clone messages (ogizanagi)
This PR was merged into the 4.1-dev branch. Discussion ---------- [Messenger] Late collect & clone messages | Q | A | ------------- | --- | Branch? | master <!-- see below --> | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Commits ------- eb94361 [Messenger] Late collect & clone messages
2 parents e224548 + eb94361 commit 74aa515

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/Symfony/Component/Messenger/DataCollector/MessengerDataCollector.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
use Symfony\Component\HttpFoundation\Request;
1515
use Symfony\Component\HttpFoundation\Response;
1616
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
17+
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
1718
use Symfony\Component\Messenger\TraceableMessageBus;
1819

1920
/**
2021
* @author Samuel Roze <samuel.roze@gmail.com>
2122
*
2223
* @experimental in 4.1
2324
*/
24-
class MessengerDataCollector extends DataCollector
25+
class MessengerDataCollector extends DataCollector implements LateDataCollectorInterface
2526
{
2627
private $traceableBuses = array();
2728

@@ -34,6 +35,14 @@ public function registerBus(string $name, TraceableMessageBus $bus)
3435
* {@inheritdoc}
3536
*/
3637
public function collect(Request $request, Response $response, \Exception $exception = null)
38+
{
39+
// Noop. Everything is collected live by the traceable buses & cloned as late as possible.
40+
}
41+
42+
/**
43+
* {@inheritdoc}
44+
*/
45+
public function lateCollect()
3746
{
3847
$this->data = array('messages' => array());
3948

src/Symfony/Component/Messenger/Tests/DataCollector/MessengerDataCollectorTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Symfony\Component\Messenger\Tests\DataCollector;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\HttpFoundation\Request;
16-
use Symfony\Component\HttpFoundation\Response;
1715
use Symfony\Component\Messenger\DataCollector\MessengerDataCollector;
1816
use Symfony\Component\Messenger\MessageBusInterface;
1917
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
@@ -43,7 +41,7 @@ public function testHandle($returnedValue, $expected)
4341

4442
$bus->dispatch($message);
4543

46-
$collector->collect(Request::create('/'), new Response());
44+
$collector->lateCollect();
4745

4846
$messages = $collector->getMessages();
4947
$this->assertCount(1, $messages);
@@ -120,7 +118,7 @@ public function testHandleWithException()
120118
// Ignore.
121119
}
122120

123-
$collector->collect(Request::create('/'), new Response());
121+
$collector->lateCollect();
124122

125123
$messages = $collector->getMessages();
126124
$this->assertCount(1, $messages);

0 commit comments

Comments
 (0)
0