Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 687a3d6

Browse filesBrowse files
committed
Separate message provider id and description
1 parent b6ae3aa commit 687a3d6
Copy full SHA for 687a3d6

File tree

7 files changed

+31
-11
lines changed
Filter options

7 files changed

+31
-11
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Messenger/DummyTask.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Messenger/DummyTask.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#[AsCronTask(expression: '0 * * * *', timezone: 'Europe/Berlin', arguments: ['2'], schedule: 'dummy_task', method: 'method2')]
1010
#[AsPeriodicTask(frequency: 5, arguments: [3], schedule: 'dummy_task')]
1111
#[AsPeriodicTask(frequency: '1 day', from: '2023-10-25 09:59:00Z', jitter: 60, arguments: ['4'], schedule: 'dummy_task', method: 'method4')]
12+
#[AsPeriodicTask(frequency: '1 day', from: '2023-10-25 09:59:00Z', arguments: ['9'], schedule: 'dummy_task', method: 'method5')]
13+
#[AsPeriodicTask(frequency: '1 day', from: '2023-10-25 09:59:00Z', arguments: ['9b'], schedule: 'dummy_task', method: 'method5')]
14+
#[AsPeriodicTask(frequency: '1 day', from: '2023-10-25 09:59:00Z', arguments: ['named' => '9'], schedule: 'dummy_task', method: 'method5')]
1215
class DummyTask
1316
{
1417
public static array $calls = [];

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SchedulerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SchedulerTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function testAutoconfiguredScheduler()
8484
$this->assertCount(779, $calls['__invoke']);
8585
$this->assertSame([['2']], $calls['method2']);
8686
$this->assertSame([['4']], $calls['method4']);
87+
$this->assertSame([['9'], ['9b'], ['named' => '9']], $calls['method5']);
8788
$this->assertSame([['5', 6], ['7', 8]], $calls['attributesOnMethod']);
8889
}
8990

‎src/Symfony/Component/Scheduler/Command/DebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Scheduler/Command/DebugCommand.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ private static function renderRecurringMessage(RecurringMessage $recurringMessag
114114
return null;
115115
}
116116

117-
return [(string) $trigger, $recurringMessage->getProvider()->getId(), $next];
117+
$provider = $recurringMessage->getProvider();
118+
$description = $provider instanceof \Stringable ? (string) $provider : $provider->getId();
119+
120+
return [(string) $trigger, $description, $next];
118121
}
119122
}

‎src/Symfony/Component/Scheduler/RecurringMessage.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Scheduler/RecurringMessage.php
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ public static function trigger(TriggerInterface $trigger, object $message): self
7575
return new self($trigger, $message);
7676
}
7777

78-
$description = '';
79-
try {
80-
$description = $message instanceof \Stringable ? (string) $message : serialize($message);
81-
} catch (\Exception) {
78+
$description = $message::class;
79+
if ($message instanceof \Stringable) {
80+
try {
81+
$description .= "($message)";
82+
} catch (\Exception) {
83+
}
8284
}
83-
$description = sprintf('%s(%s)', $message::class, $description);
8485

85-
return new self($trigger, new StaticMessageProvider([$message], $description));
86+
return new self($trigger, new StaticMessageProvider([$message], hash('crc32c', serialize($message)), $description));
8687
}
8788

8889
public function withJitter(int $maxSeconds = 60): self

‎src/Symfony/Component/Scheduler/Tests/Trigger/CallbackMessageProviderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Scheduler/Tests/Trigger/CallbackMessageProviderTest.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ public function testToString()
2929
$this->assertEquals([new \stdClass()], $messageProvider->getMessages($context));
3030
$this->assertSame('', $messageProvider->getId());
3131

32-
$messageProvider = new CallbackMessageProvider(fn () => yield new \stdClass(), 'foo');
32+
$messageProvider = new CallbackMessageProvider(fn () => yield new \stdClass(), 'foo', 'bar');
3333
$this->assertInstanceOf(\Generator::class, $messageProvider->getMessages($context));
3434
$this->assertSame('foo', $messageProvider->getId());
35+
$this->assertSame('bar', (string) $messageProvider);
3536
}
3637
}

‎src/Symfony/Component/Scheduler/Trigger/CallbackMessageProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Scheduler/Trigger/CallbackMessageProvider.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
use Symfony\Component\Scheduler\Generator\MessageContext;
1515

16-
final class CallbackMessageProvider implements MessageProviderInterface
16+
final class CallbackMessageProvider implements MessageProviderInterface, \Stringable
1717
{
1818
private \Closure $callback;
1919

2020
/**
2121
* @param callable(MessageContext): iterable<object> $callback
2222
*/
23-
public function __construct(callable $callback, private string $id = '')
23+
public function __construct(callable $callback, private string $id = '', private string $description = '')
2424
{
2525
$this->callback = $callback(...);
2626
}
@@ -34,4 +34,9 @@ public function getId(): string
3434
{
3535
return $this->id;
3636
}
37+
38+
public function __toString(): string
39+
{
40+
return $this->description ?: $this->id;
41+
}
3742
}

‎src/Symfony/Component/Scheduler/Trigger/StaticMessageProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Scheduler/Trigger/StaticMessageProvider.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313

1414
use Symfony\Component\Scheduler\Generator\MessageContext;
1515

16-
final class StaticMessageProvider implements MessageProviderInterface
16+
final class StaticMessageProvider implements MessageProviderInterface, \Stringable
1717
{
1818
/**
1919
* @param array<object> $messages
2020
*/
2121
public function __construct(
2222
private array $messages,
2323
private string $id = '',
24+
private string $description = '',
2425
) {
2526
}
2627

@@ -33,4 +34,9 @@ public function getId(): string
3334
{
3435
return $this->id;
3536
}
37+
38+
public function __toString(): string
39+
{
40+
return $this->description ?: $this->id;
41+
}
3642
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.