8000 Merge branch '5.4' into 6.0 · symfony/symfony@7e13694 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e13694

Browse files
Merge branch '5.4' into 6.0
* 5.4: [PhpUnitBridge] Fix test [RateLimiter] Add typecase to SlidingWindow::getExpirationTime Bump Symfony version to 5.4.8 Update VERSION for 5.4.7 Update CHANGELOG for 5.4.7 Bump Symfony version to 4.4.41 Update VERSION for 4.4.40 Update CONTRIBUTORS for 4.4.40 Update CHANGELOG for 4.4.40 [Messenger] reset connection on worker shutdown reset Twig form theme resources between requests
2 parents ec79614 + c9a5155 commit 7e13694

File tree

8 files changed

+78
-12
lines changed

8 files changed

+78
-12
lines changed

CONTRIBUTORS.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ The Symfony Connect username in parenthesis allows to get more information
102102
- Henrik Westphal (snc)
103103
- Dariusz Górecki (canni)
104104
- Fran Moreno (franmomu)
105+
- HypeMC (hypemc)
105106
- Jérôme Vasseur (jvasseur)
106107
- Mathieu Santostefano (welcomattic)
107108
- Dariusz Ruminski
@@ -111,19 +112,18 @@ The Symfony Connect username in parenthesis allows to get more information
111112
- Daniel Holmes (dholmes)
112113
- Sebastiaan Stok (sstok)
113114
- Alexandre Daubois (alexandre-daubois)
114-
- HypeMC (hypemc)
115115
- Toni Uebernickel (havvg)
116116
- Bart van den Burg (burgov)
117117
- Jordan Alliot (jalliot)
118118
- John Wards (johnwards)
119119
- Tomas Norkūnas (norkunas)
120120
- Julien Falque (julienfalque)
121+
- Vincent Langlet (deviling)
121122
- Baptiste Clavié (talus)
122123
- Massimiliano Arione (garak)
123124
- Mathias Arlaud (mtarld)
124125
- Antoine Hérault (herzult)
125126
- Paráda József (paradajozsef)
126-
- Vincent Langlet (deviling)
127127
- Arnaud Le Blanc (arnaud-lb)
128128
- Przemysław Bogusz (przemyslaw-bogusz)
129129
- Maxime STEINHAUSSER
@@ -153,6 +153,7 @@ The Symfony Connect username in parenthesis allows to get more information
153153
- Teoh Han Hui (teohhanhui)
154154
- Colin Frei
155155
- Javier Spagnoletti (phansys)
156+
- Gary PEGEOT (gary-p)
156157
- Ruud Kamphuis (ruudk)
157158
- Joshua Thijssen
158159
- Daniel Wehner (dawehner)
@@ -161,7 +162,6 @@ The Symfony Connect username in parenthesis allows to get more information
161162
- Gordon Franke (gimler)
162163
- Saif Eddin Gmati (azjezz)
163164
- Richard van Laak (rvanlaak)
164-
- Gary PEGEOT (gary-p)
165165
- Jesse Rushlow (geeshoe)
166166
- Fabien Pennequin (fabienpennequin)
167167
- Olivier Dolbeau (odolbeau)
@@ -355,6 +355,7 @@ The Symfony Connect username in parenthesis allows to get more information
355355
- Sébastien Lavoie (lavoiesl)
356356
- Dariusz
357357
- Farhad Safarov (safarov)
358+
- Hugo Alliaume (kocal)
358359
- BoShurik
359360
- Thomas Lallement (raziel057)
360361
- Michael Voříšek
@@ -418,7 +419,6 @@ The Symfony Connect username in parenthesis allows to get more information
418419
- Christopher Davis (chrisguitarguy)
419420
- Dmitriy Mamontov (mamontovdmitriy)
420421
- Ben Ramsey (ramsey)
421-
- Hugo Alliaume (kocal)
422422
- Laurent Masforné (heisenberg)
423423
- Sergey (upyx)
424424
- Giorgio Premi
@@ -441,6 +441,7 @@ The Symfony Connect username in parenthesis allows to get more information
441441
- Iker Ibarguren (ikerib)
442442
- Bob van de Vijver (bobvandevijver)
443443
- Peter Kruithof (pkruithof)
444+
- Antoine Lamirault
444445
- Michael Holm (hollo)
445446
- Arjen van der Meijden
446447
- Markus Fasselt (digilist)
@@ -478,6 +479,7 @@ The Symfony Connect username in parenthesis allows to get more information
478479
- Andrey Esaulov (andremaha)
479480
- Grégoire Passault (gregwar)
480481
- Jerzy Zawadzki (jzawadzki)
482+
- Phil Taylor (prazgod)
481483
- Ismael Ambrosi (iambrosi)
482484
- Craig Duncan (duncan3dc)
483485
- Emmanuel BORGES (eborges78)
@@ -585,8 +587,6 @@ The Symfony Connect username in parenthesis allows to get more information
585587
- Loïc Chardonnet (gnusat)
586588
- Marek Kalnik (marekkalnik)
587589
- Vyacheslav Salakhutdinov (megazoll)
588-
- Antoine Lamirault
589-
- Phil Taylor (prazgod)
590590
- Hassan Amouhzi
591591
- Daniel Gorgan
592592
- Tamas Szijarto
@@ -618,6 +618,7 @@ The Symfony Connect username in parenthesis allows to get more information
618618
- Xavier HAUSHERR
619619
- Albert Jessurum (ajessu)
620620
- Laszlo Korte
621+
- Jonathan Scheiber (jmsche)
621622
- Miha Vrhovnik
622623
- Alessandro Desantis
623624
- hubert lecorche (hlecorche)
@@ -688,6 +689,7 @@ The Symfony Connect username in parenthesis allows to get more information
688689
- Boris Vujicic (boris.vujicic)
689690
- Chris Sedlmayr (catchamonkey)
690691
- Indra Gunawan (indragunawan)
692+
- Jérôme Tanghe (deuchnord)
691693
- Mathias STRASSER (roukmoute)
692694
- simon chrzanowski (simonch)
693695
- Kamil Kokot (pamil)
@@ -831,7 +833,6 @@ The Symfony Connect username in parenthesis allows to get more information
831833
- Stefan Kruppa
832834
- jhonnyL
833835
- sasezaki
834-
- Jonathan Scheiber (jmsche)
835836
- Kristof Van Cauwenbergh (kristofvc)
836837
- Dawid Pakuła (zulusx)
837838
- Marco Lipparini (liarco)
@@ -1156,6 +1157,7 @@ The Symfony Connect username in parenthesis allows to get more information
11561157
- Dominik Ritter (dritter)
11571158
- Sebastian Grodzicki (sgrodzicki)
11581159
- Florian Caron (shalalalala)
1160+
- Eric COURTIAL
11591161
- Jeroen van den Enden (stoefke)
11601162
- Aurélien Fontaine
11611163
- Pascal Helfenstein
@@ -1220,7 +1222,6 @@ The Symfony Connect username in parenthesis allows to get more information
12201222
- Jérémy REYNAUD (babeuloula)
12211223
- Mathieu Rochette (mathroc)
12221224
- Victor Garcia
1223-
- Jérôme Tanghe (deuchnord)
12241225
- Marek Víger (freezy)
12251226
- Andrew Hilobok (hilobok)
12261227
- Noah Heck (myesain)
@@ -1342,6 +1343,7 @@ The Symfony Connect username in parenthesis allows to get more information
13421343
- Matt Robinson (inanimatt)
13431344
- Aleksey Podskrebyshev
13441345
- Calin Mihai Pristavu
1346+
- Gabrielle Langer
13451347
- David Marín Carreño (davefx)
13461348
- Fabien LUCAS (flucas2)
13471349
- Ondrej Machulda (ondram)
@@ -1763,6 +1765,7 @@ The Symfony Connect username in parenthesis allows to get more information
17631765
- Vladimir Luchaninov (luchaninov)
17641766
- spdionis
17651767
- rchoquet
1768+
- rvoisin
17661769
- gitlost
17671770
- Taras Girnyk
17681771
- Dmitry Derepko
@@ -2342,6 +2345,7 @@ The Symfony Connect username in parenthesis allows to get more information
23422345
- Romain Dorgueil
23432346
- Christopher Parotat
23442347
- Dennis Haarbrink
2348+
- Urban Suppiger
23452349
- me_shaon
23462350
- 蝦米
23472351
- Grayson Koonce (breerly)
@@ -2822,6 +2826,7 @@ The Symfony Connect username in parenthesis allows to get more information
28222826
- Ikko Ashimine
28232827
- Erwin Dirks
28242828
- Brad Jones
2829+
- Markus Ramšak
28252830
- Billie Thompson
28262831
- lol768
28272832
- jamogon
@@ -2898,7 +2903,6 @@ The Symfony Connect username in parenthesis allows to get more information
28982903
- bokonet
28992904
- Arrilot
29002905
- ampaze
2901-
- Gabrielle Langer
29022906
- Chris McGehee
29032907
- Markus Staab
29042908
- Pierre-Louis LAUNAY
@@ -2920,6 +2924,7 @@ The Symfony Connect username in parenthesis allows to get more information
29202924
- Lebnik
29212925
- nsbx
29222926
- Shude
2927+
- RTUnreal
29232928
- Richard Hodgson
29242929
- Sven Fabricius
29252930
- Ondřej Führer

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/quiet.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Test DeprecationErrorHandler with quiet output
44
<?php
55

66
$k = 'SYMFONY_DEPRECATIONS_HELPER';
7-
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'verbose=0');
7+
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'max[total]=3&verbose=0');
88
putenv('ANSICON');
99
putenv('ConEmuANSI');
1010
putenv('TERM');

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
use Symfony\Component\DependencyInjection\ContainerBuilder;
1818
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
1919
use Symfony\Component\DependencyInjection\Reference;
20+
use Symfony\Component\Form\AbstractRendererEngine;
2021
use Symfony\Component\Form\Form;
2122
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2223
use Symfony\Component\Mailer\Mailer;
2324
use Symfony\Component\Translation\Translator;
25+
use Symfony\Contracts\Service\ResetInterface;
2426
use Twig\Extension\ExtensionInterface;
2527
use Twig\Extension\RuntimeExtensionInterface;
2628
use Twig\Loader\LoaderInterface;
@@ -40,6 +42,12 @@ public function load(array $configs, ContainerBuilder $container)
4042

4143
if ($container::willBeAvailable('symfony/form', Form::class, ['symfony/twig-bundle'])) {
4244
$loader->load('form.php');
45+
46+
if (is_subclass_of(AbstractRendererEngine::class, ResetInterface::class)) {
47+
$container->getDefinition('twig.form.engine')->addTag('kernel.reset', [
48+
'method' => 'reset',
49+
]);
50+
}
4351
}
4452

4553
if ($container::willBeAvailable('symfony/console', Application::class, ['symfony/twig-bundle'])) {

src/Symfony/Component/Form/AbstractRendererEngine.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
namespace Symfony\Component\Form;
1313

14+
use Symfony\Contracts\Service\ResetInterface;
15+
1416
/**
1517
* Default implementation of {@link FormRendererEngineInterface}.
1618
*
1719
* @author Bernhard Schussek <bschussek@gmail.com>
1820
*/
19-
abstract class AbstractRendererEngine implements FormRendererEngineInterface
21+
abstract class AbstractRendererEngine implements FormRendererEngineInterface, ResetInterface
2022
{
2123
/**
2224
* The variable in {@link FormView} used as cache key.
@@ -193,4 +195,12 @@ private function loadResourceForBlockNameHierarchy(string $cacheKey, FormView $v
193195

194196
return false;
195197
}
198+
199+
public function reset(): void
200+
{
201+
$this->themes = [];
202+
$this->useDefaultThemes = [];
203+
$this->resources = [];
204+
$this->resourceHierarchyLevels = [];
205+
}
196206
}

src/Symfony/Component/Messenger/Tests/WorkerTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
4141
use Symfony\Component\Messenger\Worker;
4242
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
43+
use Symfony\Contracts\Service\ResetInterface;
4344

4445
/**
4546
* @group time-sensitive
@@ -98,6 +99,19 @@ public function testHandlingErrorCausesReject()
9899
$this->assertSame(0, $receiver->getAcknowledgeCount());
99100
}
100101

102+
public function testWorkerResetsConnectionIfReceiverIsResettable()
103+
{
104+
$resettableReceiver = new ResettableDummyReceiver([]);
105+
106+
$bus = $this->createMock(MessageBusInterface::class);
107+
$dispatcher = new EventDispatcher();
108+
109+
$worker = new Worker([$resettableReceiver], $bus, $dispatcher);
110+
$worker->stop();
111+
$worker->run();
112+
$this->assertTrue($resettableReceiver->hasBeenReset());
113+
}
114+
101115
public function testWorkerDoesNotSendNullMessagesToTheBus()
102116
{
103117
$receiver = new DummyReceiver([
@@ -538,3 +552,18 @@ private function process(array $jobs): void
538552
}
539553
}
540554
}
555+
556+
class ResettableDummyReceiver extends DummyReceiver implements ResetInterface
557+
{
558+
private $hasBeenReset = false;
559+
560+
public function reset()
561+
{
562+
$this->hasBeenReset = true;
563+
}
564+
565+
public function hasBeenReset(): bool
566+
{
567+
return $this->hasBeenReset;
568+
}
569+
}

src/Symfony/Component/Messenger/Worker.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use Symfony\Component\Messenger\Transport\Receiver\QueueReceiverInterface;
3030
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
3131
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
32+
use Symfony\Contracts\Service\ResetInterface;
3233

3334
/**
3435
* @author Samuel Roze <samuel.roze@gmail.com>
@@ -133,6 +134,7 @@ public function run(array $options = []): void
133134

134135
$this->flush(true);
135136
$this->dispatchEvent(new WorkerStoppedEvent($this));
137+
$this->resetReceiverConnections();
136138
}
137139

138140
private function handleMessage(Envelope $envelope, string $transportName): void
@@ -256,6 +258,15 @@ public function getMetadata(): WorkerMetadata
256258
return $this->metadata;
257259
}
258260

261+
private function resetReceiverConnections(): void
262+
{
263+
foreach ($this->receivers as $receiver) {
264+
if ($receiver instanceof ResetInterface) {
265+
$receiver->reset();
266+
}
267+
}
268+
}
269+
259270
private function dispatchEvent(object $event): void
260271
{
261272
if (null === $this->eventDispatcher) {

src/Symfony/Component/RateLimiter/Policy/SlidingWindow.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getId(): string
6060
*/
6161
public function getExpirationTime(): int
6262
{
63-
return $this->windowEndAt + $this->intervalInSeconds - microtime(true);
63+
return (int) ($this->windowEndAt + $this->intervalInSeconds - microtime(true));
6464
}
6565

6666
public function isExpired(): bool

src/Symfony/Component/RateLimiter/Tests/Policy/SlidingWindowTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public function testGetExpirationTime()
3434

3535
$new = SlidingWindow::createFromPreviousWindow($cachedWindow, 15);
3636
$this->assertSame(2 * 15, $new->getExpirationTime());
37+
38+
usleep(10.1);
39+
$this->assertIsInt($new->getExpirationTime());
3740
}
3841

3942
public function testInvalidInterval()

0 commit comments

Comments
 (0)
0