Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit08ff65f

Browse files
committed
bug#37611 [Mailer] Fix failover transport (fabpot)
This PR was merged into the 5.1 branch.Discussion----------[Mailer] Fix failover transport| Q | A| ------------- | ---| Branch? | 5.1 <!-- see below -->| Bug fix? | yes| New feature? | no <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets |Fix#37593 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->| License | MIT| Doc PR | n/aThis fixes a regression in 5.1.Commits-------8b673f5 [Mailer] Fix failover transport
2 parents28e072a +8b673f5 commit08ff65f

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

‎src/Symfony/Component/Mailer/Tests/Transport/FailoverTransportTest.php‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ public function testSendFirstWork()
4646
$t2 =$this->createMock(TransportInterface::class);
4747
$t2->expects($this->never())->method('send');
4848
$t =newFailoverTransport([$t1,$t2]);
49-
$p =new \ReflectionProperty(RoundRobinTransport::class,'cursor');
50-
$p->setAccessible(true);
51-
$p->setValue($t,0);
5249
$t->send(newRawMessage(''));
5350
$this->assertTransports($t,1, []);
5451
$t->send(newRawMessage(''));
@@ -77,9 +74,6 @@ public function testSendOneDead()
7774
$t2 =$this->createMock(TransportInterface::class);
7875
$t2->expects($this->exactly(3))->method('send');
7976
$t =newFailoverTransport([$t1,$t2]);
80-
$p =new \ReflectionProperty(RoundRobinTransport::class,'cursor');
81-
$p->setAccessible(true);
82-
$p->setValue($t,0);
8377
$t->send(newRawMessage(''));
8478
$this->assertTransports($t,0, [$t1]);
8579
$t->send(newRawMessage(''));
@@ -99,9 +93,6 @@ public function testSendOneDeadAndRecoveryWithinRetryPeriod()
9993
$t2->expects($this->at(2))->method('send');
10094
$t2->expects($this->at(3))->method('send')->will($this->throwException(newTransportException()));
10195
$t =newFailoverTransport([$t1,$t2],6);
102-
$p =new \ReflectionProperty(RoundRobinTransport::class,'cursor');
103-
$p->setAccessible(true);
104-
$p->setValue($t,0);
10596
$t->send(newRawMessage(''));// t1>fail - t2>sent
10697
$this->assertTransports($t,0, [$t1]);
10798
sleep(4);
@@ -148,9 +139,6 @@ public function testSendOneDeadButRecover()
148139
$t2->expects($this->at(1))->method('send');
149140
$t2->expects($this->at(2))->method('send')->will($this->throwException(newTransportException()));
150141
$t =newFailoverTransport([$t1,$t2],1);
151-
$p =new \ReflectionProperty(RoundRobinTransport::class,'cursor');
152-
$p->setAccessible(true);
153-
$p->setValue($t,0);
154142
$t->send(newRawMessage(''));
155143
sleep(1);
156144
$t->send(newRawMessage(''));

‎src/Symfony/Component/Mailer/Transport/FailoverTransport.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ protected function getNextTransport(): ?TransportInterface
2929
return$this->currentTransport;
3030
}
3131

32+
protectedfunctiongetInitialCursor():int
33+
{
34+
return0;
35+
}
36+
3237
protectedfunctiongetNameSymbol():string
3338
{
3439
return'failover';

‎src/Symfony/Component/Mailer/Transport/RoundRobinTransport.php‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ public function __toString(): string
6767
protectedfunctiongetNextTransport(): ?TransportInterface
6868
{
6969
if (-1 ===$this->cursor) {
70-
// the cursor initial value is randomized so that
71-
// when are not in a daemon, we are still rotating the transports
72-
$this->cursor =mt_rand(0,\count($this->transports) -1);
70+
$this->cursor =$this->getInitialCursor();
7371
}
7472

7573
$cursor =$this->cursor;
@@ -101,6 +99,13 @@ protected function isTransportDead(TransportInterface $transport): bool
10199
return$this->deadTransports->contains($transport);
102100
}
103101

102+
protectedfunctiongetInitialCursor():int
103+
{
104+
// the cursor initial value is randomized so that
105+
// when are not in a daemon, we are still rotating the transports
106+
returnmt_rand(0,\count($this->transports) -1);
107+
}
108+
104109
protectedfunctiongetNameSymbol():string
105110
{
106111
return'roundrobin';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp