Skip to content

Commit

Permalink
Merge branch '4.4' into 5.4
Browse files Browse the repository at this point in the history
* 4.4:
  [PhpUnitBridge] Fix test
  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
  • Loading branch information
nicolas-grekas committed Apr 3, 2022
2 parents cd7fdef + 1ffe8ef commit c9a5155
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 11 deletions.
23 changes: 14 additions & 9 deletions CONTRIBUTORS.md
Expand Up @@ -102,6 +102,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Henrik Westphal (snc)
- Dariusz Górecki (canni)
- Fran Moreno (franmomu)
- HypeMC (hypemc)
- Jérôme Vasseur (jvasseur)
- Mathieu Santostefano (welcomattic)
- Dariusz Ruminski
Expand All @@ -111,19 +112,18 @@ The Symfony Connect username in parenthesis allows to get more information
- Daniel Holmes (dholmes)
- Sebastiaan Stok (sstok)
- Alexandre Daubois (alexandre-daubois)
- HypeMC (hypemc)
- Toni Uebernickel (havvg)
- Bart van den Burg (burgov)
- Jordan Alliot (jalliot)
- John Wards (johnwards)
- Tomas Norkūnas (norkunas)
- Julien Falque (julienfalque)
- Vincent Langlet (deviling)
- Baptiste Clavié (talus)
- Massimiliano Arione (garak)
- Mathias Arlaud (mtarld)
- Antoine Hérault (herzult)
- Paráda József (paradajozsef)
- Vincent Langlet (deviling)
- Arnaud Le Blanc (arnaud-lb)
- Przemysław Bogusz (przemyslaw-bogusz)
- Maxime STEINHAUSSER
Expand Down Expand Up @@ -153,6 +153,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Teoh Han Hui (teohhanhui)
- Colin Frei
- Javier Spagnoletti (phansys)
- Gary PEGEOT (gary-p)
- Ruud Kamphuis (ruudk)
- Joshua Thijssen
- Daniel Wehner (dawehner)
Expand All @@ -161,7 +162,6 @@ The Symfony Connect username in parenthesis allows to get more information
- Gordon Franke (gimler)
- Saif Eddin Gmati (azjezz)
- Richard van Laak (rvanlaak)
- Gary PEGEOT (gary-p)
- Jesse Rushlow (geeshoe)
- Fabien Pennequin (fabienpennequin)
- Olivier Dolbeau (odolbeau)
Expand Down Expand Up @@ -355,6 +355,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Sébastien Lavoie (lavoiesl)
- Dariusz
- Farhad Safarov (safarov)
- Hugo Alliaume (kocal)
- BoShurik
- Thomas Lallement (raziel057)
- Michael Voříšek
Expand Down Expand Up @@ -418,7 +419,6 @@ The Symfony Connect username in parenthesis allows to get more information
- Christopher Davis (chrisguitarguy)
- Dmitriy Mamontov (mamontovdmitriy)
- Ben Ramsey (ramsey)
- Hugo Alliaume (kocal)
- Laurent Masforné (heisenberg)
- Sergey (upyx)
- Giorgio Premi
Expand All @@ -441,6 +441,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Iker Ibarguren (ikerib)
- Bob van de Vijver (bobvandevijver)
- Peter Kruithof (pkruithof)
- Antoine Lamirault
- Michael Holm (hollo)
- Arjen van der Meijden
- Markus Fasselt (digilist)
Expand Down Expand Up @@ -478,6 +479,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Andrey Esaulov (andremaha)
- Grégoire Passault (gregwar)
- Jerzy Zawadzki (jzawadzki)
- Phil Taylor (prazgod)
- Ismael Ambrosi (iambrosi)
- Craig Duncan (duncan3dc)
- Emmanuel BORGES (eborges78)
Expand Down Expand Up @@ -585,8 +587,6 @@ The Symfony Connect username in parenthesis allows to get more information
- Loïc Chardonnet (gnusat)
- Marek Kalnik (marekkalnik)
- Vyacheslav Salakhutdinov (megazoll)
- Antoine Lamirault
- Phil Taylor (prazgod)
- Hassan Amouhzi
- Daniel Gorgan
- Tamas Szijarto
Expand Down Expand Up @@ -618,6 +618,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Xavier HAUSHERR
- Albert Jessurum (ajessu)
- Laszlo Korte
- Jonathan Scheiber (jmsche)
- Miha Vrhovnik
- Alessandro Desantis
- hubert lecorche (hlecorche)
Expand Down Expand Up @@ -688,6 +689,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Boris Vujicic (boris.vujicic)
- Chris Sedlmayr (catchamonkey)
- Indra Gunawan (indragunawan)
- Jérôme Tanghe (deuchnord)
- Mathias STRASSER (roukmoute)
- simon chrzanowski (simonch)
- Kamil Kokot (pamil)
Expand Down Expand Up @@ -831,7 +833,6 @@ The Symfony Connect username in parenthesis allows to get more information
- Stefan Kruppa
- jhonnyL
- sasezaki
- Jonathan Scheiber (jmsche)
- Kristof Van Cauwenbergh (kristofvc)
- Dawid Pakuła (zulusx)
- Marco Lipparini (liarco)
Expand Down Expand Up @@ -1156,6 +1157,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Dominik Ritter (dritter)
- Sebastian Grodzicki (sgrodzicki)
- Florian Caron (shalalalala)
- Eric COURTIAL
- Jeroen van den Enden (stoefke)
- Aurélien Fontaine
- Pascal Helfenstein
Expand Down Expand Up @@ -1220,7 +1222,6 @@ The Symfony Connect username in parenthesis allows to get more information
- Jérémy REYNAUD (babeuloula)
- Mathieu Rochette (mathroc)
- Victor Garcia
- Jérôme Tanghe (deuchnord)
- Marek Víger (freezy)
- Andrew Hilobok (hilobok)
- Noah Heck (myesain)
Expand Down Expand Up @@ -1342,6 +1343,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Matt Robinson (inanimatt)
- Aleksey Podskrebyshev
- Calin Mihai Pristavu
- Gabrielle Langer
- David Marín Carreño (davefx)
- Fabien LUCAS (flucas2)
- Ondrej Machulda (ondram)
Expand Down Expand Up @@ -1763,6 +1765,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Vladimir Luchaninov (luchaninov)
- spdionis
- rchoquet
- rvoisin
- gitlost
- Taras Girnyk
- Dmitry Derepko
Expand Down Expand Up @@ -2342,6 +2345,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Romain Dorgueil
- Christopher Parotat
- Dennis Haarbrink
- Urban Suppiger
- me_shaon
- 蝦米
- Grayson Koonce (breerly)
Expand Down Expand Up @@ -2822,6 +2826,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Ikko Ashimine
- Erwin Dirks
- Brad Jones
- Markus Ramšak
- Billie Thompson
- lol768
- jamogon
Expand Down Expand Up @@ -2898,7 +2903,6 @@ The Symfony Connect username in parenthesis allows to get more information
- bokonet
- Arrilot
- ampaze
- Gabrielle Langer
- Chris McGehee
- Markus Staab
- Pierre-Louis LAUNAY
Expand All @@ -2920,6 +2924,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Lebnik
- nsbx
- Shude
- RTUnreal
- Richard Hodgson
- Sven Fabricius
- Ondřej Führer
Expand Down
Expand Up @@ -4,7 +4,7 @@ Test DeprecationErrorHandler with quiet output
<?php

$k = 'SYMFONY_DEPRECATIONS_HELPER';
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'verbose=0');
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'max[total]=3&verbose=0');
putenv('ANSICON');
putenv('ConEmuANSI');
putenv('TERM');
Expand Down
Expand Up @@ -18,10 +18,12 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Form\AbstractRendererEngine;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Translation\Translator;
use Symfony\Contracts\Service\ResetInterface;
use Twig\Extension\ExtensionInterface;
use Twig\Extension\RuntimeExtensionInterface;
use Twig\Loader\LoaderInterface;
Expand All @@ -45,6 +47,12 @@ public function load(array $configs, ContainerBuilder $container)

if ($container::willBeAvailable('symfony/form', Form::class, ['symfony/twig-bundle'], true)) {
$loader->load('form.php');

if (is_subclass_of(AbstractRendererEngine::class, ResetInterface::class)) {
$container->getDefinition('twig.form.engine')->addTag('kernel.reset', [
'method' => 'reset',
]);
}
}

if ($container::willBeAvailable('symfony/console', Application::class, ['symfony/twig-bundle'], true)) {
Expand Down
12 changes: 11 additions & 1 deletion src/Symfony/Component/Form/AbstractRendererEngine.php
Expand Up @@ -11,12 +11,14 @@

namespace Symfony\Component\Form;

use Symfony\Contracts\Service\ResetInterface;

/**
* Default implementation of {@link FormRendererEngineInterface}.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
abstract class AbstractRendererEngine implements FormRendererEngineInterface
abstract class AbstractRendererEngine implements FormRendererEngineInterface, ResetInterface
{
/**
* The variable in {@link FormView} used as cache key.
Expand Down Expand Up @@ -193,4 +195,12 @@ private function loadResourceForBlockNameHierarchy(string $cacheKey, FormView $v

return false;
}

public function reset(): void
{
$this->themes = [];
$this->useDefaultThemes = [];
$this->resources = [];
$this->resourceHierarchyLevels = [];
}
}
29 changes: 29 additions & 0 deletions src/Symfony/Component/Messenger/Tests/WorkerTest.php
Expand Up @@ -40,6 +40,7 @@
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
use Symfony\Component\Messenger\Worker;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Service\ResetInterface;

/**
* @group time-sensitive
Expand Down Expand Up @@ -98,6 +99,19 @@ public function testHandlingErrorCausesReject()
$this->assertSame(0, $receiver->getAcknowledgeCount());
}

public function testWorkerResetsConnectionIfReceiverIsResettable()
{
$resettableReceiver = new ResettableDummyReceiver([]);

$bus = $this->createMock(MessageBusInterface::class);
$dispatcher = new EventDispatcher();

$worker = new Worker([$resettableReceiver], $bus, $dispatcher);
$worker->stop();
$worker->run();
$this->assertTrue($resettableReceiver->hasBeenReset());
}

public function testWorkerDoesNotSendNullMessagesToTheBus()
{
$receiver = new DummyReceiver([
Expand Down Expand Up @@ -538,3 +552,18 @@ private function process(array $jobs): void
}
}
}

class ResettableDummyReceiver extends DummyReceiver implements ResetInterface
{
private $hasBeenReset = false;

public function reset()
{
$this->hasBeenReset = true;
}

public function hasBeenReset(): bool
{
return $this->hasBeenReset;
}
}
11 changes: 11 additions & 0 deletions src/Symfony/Component/Messenger/Worker.php
Expand Up @@ -31,6 +31,7 @@
use Symfony\Component\Messenger\Transport\Receiver\QueueReceiverInterface;
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Service\ResetInterface;

/**
* @author Samuel Roze <samuel.roze@gmail.com>
Expand Down Expand Up @@ -135,6 +136,7 @@ public function run(array $options = []): void

$this->flush(true);
$this->dispatchEvent(new WorkerStoppedEvent($this));
$this->resetReceiverConnections();
}

private function handleMessage(Envelope $envelope, string $transportName): void
Expand Down Expand Up @@ -258,6 +260,15 @@ public function getMetadata(): WorkerMetadata
return $this->metadata;
}

private function resetReceiverConnections(): void
{
foreach ($this->receivers as $receiver) {
if ($receiver instanceof ResetInterface) {
$receiver->reset();
}
}
}

private function dispatchEvent(object $event): void
{
if (null === $this->eventDispatcher) {
Expand Down

0 comments on commit c9a5155

Please sign in to comment.