diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 468c90ad49d1..53a2faec2f45 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -16,27 +16,27 @@ Symfony is the result of the work of many people who made the code better - Victor Berchet (victor) - Maxime Steinhausser (ogizanagi) - Ryan Weaver (weaverryan) - - Javier Eguiluz (javier.eguiluz) - Grégoire Pineau (lyrixx) - - Jakub Zalas (jakubzalas) + - Javier Eguiluz (javier.eguiluz) - Roland Franssen (ro0) + - Jakub Zalas (jakubzalas) - Johannes S (johannes) - Kris Wallsmith (kriswallsmith) - Yonel Ceruto (yonelceruto) - Hugo Hamon (hhamon) - Abdellatif Ait boudad (aitboudad) - Samuel ROZE (sroze) - - Romain Neutron (romain) + - Thomas Calvet (fancyweb) - Wouter de Jong (wouterj) + - Romain Neutron (romain) - Pascal Borreli (pborreli) - - Thomas Calvet (fancyweb) - Joseph Bielawski (stloyd) - Alexander M. Turek (derrabus) - Karma Dordrak (drak) - Lukas Kahwe Smith (lsmith) - - Martin Hasoň (hason) - - Hamza Amrouche (simperfit) - Jules Pietri (heah) + - Hamza Amrouche (simperfit) + - Martin Hasoň (hason) - Jeremy Mikola (jmikola) - Jérémy DERUSSÉ (jderusse) - Jean-François Simon (jfsimon) @@ -66,17 +66,17 @@ Symfony is the result of the work of many people who made the code better - Saša Stamenković (umpirsky) - Peter Rehm (rpet) - Henrik Bjørnskov (henrikbjorn) - - Miha Vrhovnik - Gabriel Ostrolucký (gadelat) + - Miha Vrhovnik + - David Maicher (dmaicher) - Diego Saint Esteben (dii3g0) - Gábor Egyed (1ed) - Titouan Galopin (tgalopin) - - David Maicher (dmaicher) + - Jan Schädlich (jschaedl) - Konstantin Kudryashov (everzet) - Bilal Amarni (bamarni) - Mathieu Piot (mpiot) - Vladimir Reznichenko (kalessil) - - Jan Schädlich (jschaedl) - Florin Patan (florinpatan) - Jáchym Toušek (enumag) - Andrej Hudec (pulzarraider) @@ -136,6 +136,7 @@ Symfony is the result of the work of many people who made the code better - Joel Wurtz (brouznouf) - Fabien Pennequin (fabienpennequin) - Théo FIDRY (theofidry) + - Przemysław Bogusz (przemyslaw-bogusz) - Eric GELOEN (gelo) - Lars Strojny (lstrojny) - Jannik Zschiesche (apfelbox) @@ -155,6 +156,7 @@ Symfony is the result of the work of many people who made the code better - Sebastian Hörl (blogsh) - Daniel Gomes (danielcsgomes) - Hidenori Goto (hidenorigoto) + - Alessandro Chitolina (alekitto) - Andréia Bohner (andreia) - Yanick Witschi (toflar) - Arnaud Kleinpeter (nanocom) @@ -164,7 +166,6 @@ Symfony is the result of the work of many people who made the code better - Jérémie Augustin (jaugustin) - François-Xavier de Guillebon (de-gui_f) - Oleg Voronkovich - - Alessandro Chitolina (alekitto) - Philipp Wahala (hifi) - Rafael Dohms (rdohms) - jwdeitch @@ -239,8 +240,10 @@ Symfony is the result of the work of many people who made the code better - fivestar - Dominique Bongiraud - Jeremy Livingston (jeremylivingston) + - Laurent VOULLEMIER (lvo) - Michael Lee (zerustech) - Matthieu Auger (matthieuauger) + - Ahmed TAILOULOUTE (ahmedtai) - Leszek Prabucki (l3l0) - Fabien Bourigault (fbourigault) - François Zaninotto (fzaninotto) @@ -248,7 +251,6 @@ Symfony is the result of the work of many people who made the code better - jeff - John Kary (johnkary) - Jan Rosier (rosier) - - Przemysław Bogusz (przemyslaw-bogusz) - Justin Hileman (bobthecow) - Blanchon Vincent (blanchonvincent) - Michele Orselli (orso) @@ -280,7 +282,6 @@ Symfony is the result of the work of many people who made the code better - julien pauli (jpauli) - Lorenz Schori - Sébastien Lavoie (lavoiesl) - - Ahmed TAILOULOUTE (ahmedtai) - Dariusz - Saif (╯°□°)╯ (azjezz) - Dmitrii Poddubnyi (karser) @@ -306,6 +307,7 @@ Symfony is the result of the work of many people who made the code better - Arjen Brouwer (arjenjb) - Katsuhiro OGAWA - Patrick McDougle (patrick-mcdougle) + - Guillaume Pédelagrabe - Alif Rachmawadi - Anton Chernikov (anton_ch1989) - Kristen Gilden (kgilden) @@ -336,6 +338,7 @@ Symfony is the result of the work of many people who made the code better - Wodor Wodorski - Thomas Lallement (raziel057) - Colin O'Dell (colinodell) + - Mathias Arlaud (mtarld) - Giorgio Premi - renanbr - Alex Rock (pierstoval) @@ -398,13 +401,11 @@ Symfony is the result of the work of many people who made the code better - Emanuele Gaspari (inmarelibero) - Dariusz Rumiński - Berny Cantos (xphere81) - - Laurent VOULLEMIER (lvo) - Thierry Thuon (lepiaf) - Ricard Clau (ricardclau) - Mark Challoner (markchalloner) - Philippe Segatori - Gennady Telegin (gtelegin) - - Mathias Arlaud (mtarld) - Erin Millard - Artur Melo (restless) - Matthew Lewinski (lewinski) @@ -433,6 +434,7 @@ Symfony is the result of the work of many people who made the code better - Eric Masoero (eric-masoero) - Denis Brumann (dbrumann) - JhonnyL + - Haralan Dobrev (hkdobrev) - hossein zolfi (ocean) - Clément Gautier (clementgautier) - Bastien Jaillot (bastnic) @@ -486,6 +488,7 @@ Symfony is the result of the work of many people who made the code better - Xavier HAUSHERR - Albert Jessurum (ajessu) - Laszlo Korte + - Jesse Rushlow (geeshoe) - Miha Vrhovnik - Alessandro Desantis - hubert lecorche (hlecorche) @@ -561,6 +564,7 @@ Symfony is the result of the work of many people who made the code better - Gintautas Miselis - Rob Bast - Roberto Espinoza (respinoza) + - HypeMC - Soufian EZ-ZANTAR (soezz) - Zander Baldwin - Gocha Ossinkine (ossinkine) @@ -586,7 +590,6 @@ Symfony is the result of the work of many people who made the code better - Yoshio HANAWA - Jan van Thoor (janvt) - Gladhon - - Haralan Dobrev (hkdobrev) - Sebastian Bergmann - Miroslav Sustek - Pablo Díez (pablodip) @@ -716,6 +719,7 @@ Symfony is the result of the work of many people who made the code better - Stéphane Escandell (sescandell) - Konstantin S. M. Möllers (ksmmoellers) - James Johnston + - Noémi Salaün (noemi-salaun) - Sinan Eldem - BoShurik - Alexandre Dupuy (satchette) @@ -732,6 +736,7 @@ Symfony is the result of the work of many people who made the code better - Stefan Gehrig (sgehrig) - Hany el-Kerdany - Wang Jingyu + - Langlet Vincent (deviling) - Åsmund Garfors - Gunnstein Lye (glye) - Maxime Douailin @@ -802,7 +807,6 @@ Symfony is the result of the work of many people who made the code better - Simon Schick (simonsimcity) - redstar504 - Tristan Roussel - - HypeMC - Cameron Porter - Hossein Bukhamsin - Oliver Hoff @@ -835,6 +839,7 @@ Symfony is the result of the work of many people who made the code better - Richard Quadling - Raphaëll Roussel - Michael Lutz + - Koen Reiniers (koenre) - jochenvdv - Reedy - Arturas Smorgun (asarturas) @@ -883,6 +888,7 @@ Symfony is the result of the work of many people who made the code better - Dennis Hotson - Andrew Tchircoff (andrewtch) - michaelwilliams + - Martin Kirilov - 1emming - Nykopol (nykopol) - Tri Pham (phamuyentri) @@ -951,9 +957,11 @@ Symfony is the result of the work of many people who made the code better - Roy Klutman (royklutman) - Sofiane HADDAG (sofhad) - frost-nzcr4 + - arai - Laurent Bassin (lbassin) - andrey1s - Abhoryo + - Daniel STANCU - Fabian Vogler (fabian) - Korvin Szanto - soyuka @@ -1003,13 +1011,13 @@ Symfony is the result of the work of many people who made the code better - Shin Ohno (ganchiku) - Geert De Deckere (geertdd) - Jan Kramer (jankramer) + - Matthieu Mota (matthieumota) - abdul malik ikhsan (samsonasik) - Henry Snoek (snoek09) - Jérémy M (th3mouk) - Simone Di Maulo (toretto460) - Christian Morgan - Alexander Miehe (engerim) - - Jesse Rushlow (geeshoe) - Morgan Auchede (mauchede) - Sascha Dens (saschadens) - Don Pinkster @@ -1037,6 +1045,7 @@ Symfony is the result of the work of many people who made the code better - Marcos Gómez Vilches (markitosgv) - Matthew Davis (mdavis1982) - Markus S. (staabm) + - Benjamin Morel - Maks - Antoine LA - den @@ -1228,6 +1237,7 @@ Symfony is the result of the work of many people who made the code better - Benjamin Paap (benjaminpaap) - Claus Due (namelesscoder) - Christian + - William Arslett - Denis Golubovskiy (bukashk0zzz) - Sergii Smertin (nfx) - Mikkel Paulson @@ -1309,6 +1319,7 @@ Symfony is the result of the work of many people who made the code better - BRAMILLE Sébastien (oktapodia) - Artem Kolesnikov (tyomo4ka) - Gustavo Adrian + - Jorrit Schippers (jorrit) - Yannick - Vladimir Luchaninov (luchaninov) - spdionis @@ -1346,7 +1357,6 @@ Symfony is the result of the work of many people who made the code better - Oxan van Leeuwen - pkowalczyk - Soner Sayakci - - Koen Reiniers (koenre) - Max Voloshin (maxvoloshin) - Nicolas Fabre (nfabre) - Raul Rodriguez (raul782) @@ -1593,6 +1603,7 @@ Symfony is the result of the work of many people who made the code better - Felipy Tavares Amorim (felipyamorim) - Guillaume Loulier (guikingone) - Klaus Silveira (klaussilveira) + - Pierre Grimaud (pgrimaud) - Thomas Chmielowiec (chmielot) - Jānis Lukss - rkerner @@ -1645,7 +1656,9 @@ Symfony is the result of the work of many people who made the code better - Mephistofeles - Hoffmann András - LubenZA + - Victor Garcia - Olivier + - Denis Yuzhanin - knezmilos13 - Cyril PASCAL - Michael Bessolov @@ -1732,6 +1745,7 @@ Symfony is the result of the work of many people who made the code better - Stefan Hüsges (tronsha) - Jake Bishop (yakobeyak) - Dan Blows + - popnikos - Matt Wells - Sander van der Vlugt - Nicolas Appriou @@ -1828,6 +1842,7 @@ Symfony is the result of the work of many people who made the code better - Aarón Nieves Fernández - Mike Meier - Kirill Saksin + - Reda DAOUDI - Koalabaerchen - michalmarcinkowski - Warwick @@ -1873,7 +1888,6 @@ Symfony is the result of the work of many people who made the code better - ged15 - Daan van Renterghem - Nicole Cordes - - Martin Kirilov - Bálint Szekeres - amcastror - Alexander Li (aweelex) @@ -2174,7 +2188,6 @@ Symfony is the result of the work of many people who made the code better - Karolis - Myke79 - Brian Debuire - - Benjamin Morel - Eric Grimois - Piers Warmers - Sylvain Lorinet @@ -2240,7 +2253,6 @@ Symfony is the result of the work of many people who made the code better - James Michael DuPont - Kasperki - Tammy D - - Daniel STANCU - Ryan Rud - Ondrej Slinták - vlechemin @@ -2267,6 +2279,7 @@ Symfony is the result of the work of many people who made the code better - Abdulkadir N. A. - Adam Klvač - Bruno Nogueira Nascimento Wowk + - jonmldr - Yevgen Kovalienia - Lebnik - nsbx @@ -2385,6 +2398,7 @@ Symfony is the result of the work of many people who made the code better - Jose Manuel Gonzalez (jgonzalez) - Joachim Krempel (jkrempel) - Jorge Maiden (jorgemaiden) + - Joao Paulo V Martins (jpjoao) - Justin Rainbow (jrainbow) - Juan Luis (juanlugb) - JuntaTom (juntatom) @@ -2398,7 +2412,6 @@ Symfony is the result of the work of many people who made the code better - Luís Cobucci (lcobucci) - Jérémy (libertjeremy) - Mehdi Achour (machour) - - Matthieu Mota (matthieumota) - Matthieu Moquet (mattketmo) - Moritz Borgmann (mborgmann) - Michal Čihař (mcihar) @@ -2442,6 +2455,7 @@ Symfony is the result of the work of many people who made the code better - Markus Tacker (tacker) - Tom Newby (tomnewbyau) - Andrew Clark (tqt_andrew_clark) + - Aaron Piotrowski (trowski) - David Lumaye (tux1124) - Roman Tymoshyk (tymoshyk) - Tyler Stroud (tystr) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index a7f348e76d21..3839cbc4ed7e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -383,8 +383,8 @@ private function getArgumentNodes(array $arguments, \DOMDocument $dom): array } elseif (\is_array($argument)) { $argumentXML->setAttribute('type', 'collection'); - foreach ($this->getArgumentNodes($argument, $dom) as $childArgumenXML) { - $argumentXML->appendChild($childArgumenXML); + foreach ($this->getArgumentNodes($argument, $dom) as $childArgumentXML) { + $argumentXML->appendChild($childArgumentXML); } } else { $argumentXML->appendChild(new \DOMText($argument)); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/SessionPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/SessionPass.php new file mode 100644 index 000000000000..0f4950615fbc --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/SessionPass.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +/** + * @internal to be removed in 6.0 + */ +class SessionPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition('session')) { + return; + } + + $bags = [ + 'session.flash_bag' => $container->hasDefinition('session.flash_bag') ? $container->getDefinition('session.flash_bag') : null, + 'session.attribute_bag' => $container->hasDefinition('session.attribute_bag') ? $container->getDefinition('session.attribute_bag') : null, + ]; + + foreach ($container->getDefinition('session')->getArguments() as $v) { + if (!$v instanceof Reference || !isset($bags[$bag = (string) $v]) || !\is_array($factory = $bags[$bag]->getFactory())) { + continue; + } + + if ([0, 1] !== array_keys($factory) || !$factory[0] instanceof Reference || 'session' !== (string) $factory[0]) { + continue; + } + + if ('get'.ucfirst(substr($bag, 8, -4)).'Bag' !== $factory[1]) { + continue; + } + + $bags[$bag]->setFactory(null); + } + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index 931ca33285f1..b505daf131c3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass; +use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SessionPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerRealRefPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerWeakRefPass; @@ -151,6 +152,7 @@ public function build(ContainerBuilder $container) $this->addCompilerPassIfExists($container, AddAutoMappingConfigurationPass::class); $container->addCompilerPass(new RegisterReverseContainerPass(true)); $container->addCompilerPass(new RegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING); + $container->addCompilerPass(new SessionPass()); if ($container->getParameter('kernel.debug')) { $container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SessionPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SessionPassTest.php new file mode 100644 index 000000000000..afc6f9b4b257 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SessionPassTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; + +use PHPUnit\Framework\TestCase; +use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SessionPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +class SessionPassTest extends TestCase +{ + public function testProcess() + { + $arguments = [ + new Reference('session.flash_bag'), + new Reference('session.attribute_bag'), + ]; + $container = new ContainerBuilder(); + $container + ->register('session') + ->setArguments($arguments); + $container + ->register('session.flash_bag') + ->setFactory([new Reference('session'), 'getFlashBag']); + $container + ->register('session.attribute_bag') + ->setFactory([new Reference('session'), 'getAttributeBag']); + + (new SessionPass())->process($container); + + $this->assertSame($arguments, $container->getDefinition('session')->getArguments()); + $this->assertNull($container->getDefinition('session.flash_bag')->getFactory()); + $this->assertNull($container->getDefinition('session.attribute_bag')->getFactory()); + } +} diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php index 14624e9df52c..20c6c0885af4 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php @@ -244,6 +244,8 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto ->children() ->scalarNode('path')->defaultNull()->end() ->scalarNode('domain')->defaultNull()->end() + ->scalarNode('secure')->defaultFalse()->end() + ->scalarNode('samesite')->defaultNull()->end() ->end() ->end() ->end() diff --git a/src/Symfony/Component/Console/Output/StreamOutput.php b/src/Symfony/Component/Console/Output/StreamOutput.php index 312621086542..f39422a57ae2 100644 --- a/src/Symfony/Component/Console/Output/StreamOutput.php +++ b/src/Symfony/Component/Console/Output/StreamOutput.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Console\Output; use Symfony\Component\Console\Exception\InvalidArgumentException; -use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Formatter\OutputFormatterInterface; /** @@ -74,10 +73,7 @@ protected function doWrite($message, $newline) $message .= PHP_EOL; } - if (false === @fwrite($this->stream, $message)) { - // should never happen - throw new RuntimeException('Unable to write output.'); - } + @fwrite($this->stream, $message); fflush($this->stream); } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/stream_output_file.txt b/src/Symfony/Component/Console/Tests/Fixtures/stream_output_file.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php index df4e3384ab8c..8fa9dfd1047c 100644 --- a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php @@ -56,4 +56,12 @@ public function testDoWrite() rewind($output->getStream()); $this->assertEquals('foo'.PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream'); } + + public function testDoWriteOnFailure() + { + $resource = fopen(__DIR__.'/../Fixtures/stream_output_file.txt', 'r', false); + $output = new StreamOutput($resource); + rewind($output->getStream()); + $this->assertEquals('', stream_get_contents($output->getStream())); + } } diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php index f5042749e2eb..395f4ab97add 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php @@ -256,7 +256,7 @@ public function providePrefixTests() // shows that a prefix will always be given the starting slash $tests[] = ['0', '/foo', '/0/foo']; - // spaces are ok, and double slahses at the end are cleaned + // spaces are ok, and double slashes at the end are cleaned $tests[] = ['/ /', '/foo', '/ /foo']; return $tests; diff --git a/src/Symfony/Component/Security/Http/Logout/CookieClearingLogoutHandler.php b/src/Symfony/Component/Security/Http/Logout/CookieClearingLogoutHandler.php index 2aa7c732b976..9367a62b33bd 100644 --- a/src/Symfony/Component/Security/Http/Logout/CookieClearingLogoutHandler.php +++ b/src/Symfony/Component/Security/Http/Logout/CookieClearingLogoutHandler.php @@ -38,7 +38,7 @@ public function __construct(array $cookies) public function logout(Request $request, Response $response, TokenInterface $token) { foreach ($this->cookies as $cookieName => $cookieData) { - $response->headers->clearCookie($cookieName, $cookieData['path'], $cookieData['domain']); + $response->headers->clearCookie($cookieName, $cookieData['path'], $cookieData['domain'], isset($cookieData['secure']) ? $cookieData['secure'] : false, true, isset($cookieData['samesite']) ? $cookieData['samesite'] : null); } } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php index 62d0da695026..c188727bb09b 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php @@ -372,7 +372,7 @@ public function testSwitchUserWithReplacedToken() $this->assertSame($replacedToken, $this->tokenStorage->getToken()); } - public function testSwitchtUserThrowsAuthenticationExceptionIfNoCurrentToken() + public function testSwitchUserThrowsAuthenticationExceptionIfNoCurrentToken() { $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException'); $this->tokenStorage->setToken(null); diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php index 8dcc10338b76..f2407fcb3fdd 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Security\Http\Tests\Logout; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\ResponseHeaderBag; @@ -25,7 +26,7 @@ public function testLogout() $response = new Response(); $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $handler = new CookieClearingLogoutHandler(['foo' => ['path' => '/foo', 'domain' => 'foo.foo'], 'foo2' => ['path' => null, 'domain' => null]]); + $handler = new CookieClearingLogoutHandler(['foo' => ['path' => '/foo', 'domain' => 'foo.foo', 'secure' => true, 'samesite' => Cookie::SAMESITE_STRICT], 'foo2' => ['path' => null, 'domain' => null]]); $cookies = $response->headers->getCookies(); $this->assertCount(0, $cookies); @@ -39,12 +40,16 @@ public function testLogout() $this->assertEquals('foo', $cookie->getName()); $this->assertEquals('/foo', $cookie->getPath()); $this->assertEquals('foo.foo', $cookie->getDomain()); + $this->assertEquals(Cookie::SAMESITE_STRICT, $cookie->getSameSite()); + $this->assertTrue($cookie->isSecure()); $this->assertTrue($cookie->isCleared()); $cookie = $cookies['']['/']['foo2']; $this->assertStringStartsWith('foo2', $cookie->getName()); $this->assertEquals('/', $cookie->getPath()); $this->assertNull($cookie->getDomain()); + $this->assertNull($cookie->getSameSite()); + $this->assertFalse($cookie->isSecure()); $this->assertTrue($cookie->isCleared()); } } diff --git a/src/Symfony/Component/Security/Http/composer.json b/src/Symfony/Component/Security/Http/composer.json index 686b2b9f1ec5..7c9cdb484f10 100644 --- a/src/Symfony/Component/Security/Http/composer.json +++ b/src/Symfony/Component/Security/Http/composer.json @@ -18,7 +18,7 @@ "require": { "php": "^7.1.3", "symfony/security-core": "^4.4", - "symfony/http-foundation": "^3.4|^4.0|^5.0", + "symfony/http-foundation": "^3.4.40|^4.4.7|^5.0.7", "symfony/http-kernel": "^4.4", "symfony/property-access": "^3.4|^4.0|^5.0" }, diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index 5251cd8f005f..5cd3193d4ce8 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -18,7 +18,7 @@ "require": { "php": "^7.1.3", "symfony/event-dispatcher-contracts": "^1.1|^2", - "symfony/http-foundation": "^3.4|^4.0|^5.0", + "symfony/http-foundation": "^3.4.40|^4.4.7|^5.0.7", "symfony/http-kernel": "^4.4", "symfony/property-access": "^3.4|^4.0|^5.0", "symfony/service-contracts": "^1.1|^2" diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf index 7c509b482250..46a649848072 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf @@ -374,6 +374,14 @@ The number of elements in this collection should be a multiple of {{ compared_value }}. يجب أن يكون عدد العناصر في هذه المجموعة مضاعف {{ compared_value }}. + + This value should satisfy at least one of the following constraints: + يجب أن تستوفي هذه القيمة واحدة من القيود التالية: + + + Each element of this collection should satisfy its own set of constraints. + يجب أن يفي كل عنصر من عناصر هذه المجموعة بمجموعة القيود الخاصة به. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf index a546b86c78a9..c5d1fe0cf198 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf @@ -374,6 +374,14 @@ The number of elements in this collection should be a multiple of {{ compared_value }}. Die Anzahl an Elementen in dieser Sammlung sollte ein Vielfaches von {{ compared_value }} sein. + + This value should satisfy at least one of the following constraints: + Dieser Wert sollte eine der folgenden Bedingungen erfüllen: + + + Each element of this collection should satisfy its own set of constraints. + Jedes Element dieser Sammlung sollte seine eigene Menge an Bedingungen erfüllen. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf index e54be35c15cc..c44ade69e071 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf @@ -374,6 +374,14 @@ The number of elements in this collection should be a multiple of {{ compared_value }}. Le nombre d'éléments de cette collection doit être un multiple de {{ compared_value }}. + + This value should satisfy at least one of the following constraints: + Cette valeur doit satisfaire à au moins une des contraintes suivantes : + + + Each element of this collection should satisfy its own set of constraints. + Chaque élément de cette collection doit satisfaire à son propre jeu de contraintes. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf index 96ae6fe54ea6..23ca5618097c 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf @@ -366,6 +366,22 @@ This value should be between {{ min }} and {{ max }}. Ennek az értéknek {{ min }} és {{ max }} között kell lennie. + + This value is not a valid hostname. + Ez az érték nem egy érvényes állomásnév (hosztnév). + + + The number of elements in this collection should be a multiple of {{ compared_value }}. + A gyűjteményben lévő elemek számának oszthatónak kell lennie a következővel: {{ compared_value }}. + + + This value should satisfy at least one of the following constraints: + Ennek az értéknek meg kell felelni legalább egynek a következő feltételek közül: + + + Each element of this collection should satisfy its own set of constraints. + A gyűjtemény minden elemének meg kell felelni a saját feltételeinek. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf index 3ec620ad6d48..9a5768c30ac5 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf @@ -366,6 +366,22 @@ This value should be between {{ min }} and {{ max }}. Questo valore dovrebbe essere compreso tra {{ min }} e {{ max }}. + + This value is not a valid hostname. + Questo valore non è un nome di host valido. + + + The number of elements in this collection should be a multiple of {{ compared_value }}. + Il numero di elementi in questa collezione dovrebbe essere un multiplo di {{ compared_value }}. + + + This value should satisfy at least one of the following constraints: + Questo valore dovrebbe soddisfare almeno uno dei vincoli seguenti: + + + Each element of this collection should satisfy its own set of constraints. + Ciascun elemento di questa collezione dovrebbe soddisfare il suo insieme di vincoli. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf index 2a079aacbf9b..ccb58818c43c 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf @@ -366,6 +366,22 @@ This value should be between {{ min }} and {{ max }}. Ši reikšmė turi būti tarp {{ min }} ir {{ max }}. + + This value is not a valid hostname. + Ši reikšmė nėra tinkamas svetainės adresas. + + + The number of elements in this collection should be a multiple of {{ compared_value }}. + Šio sąrašo elementų skaičius turėtų būti skaičiaus {{ compared_value }} kartotinis. + + + This value should satisfy at least one of the following constraints: + Ši reikšmė turėtų atitikti bent vieną iš šių nurodymų: + + + Each element of this collection should satisfy its own set of constraints. + Kiekvienas šio sąrašo elementas turi atitikti savo nurodymų rinkinį. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf index 301d42f027c8..f4286d25ef44 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf @@ -374,6 +374,14 @@ The number of elements in this collection should be a multiple of {{ compared_value }}. Số lượng các phần tử trong bộ sưu tập này nên là bội số của {{ compared_value }}. + + This value should satisfy at least one of the following constraints: + Giá trị này nên thỏa mãn ít nhất một trong những ràng buộc sau: + + + Each element of this collection should satisfy its own set of constraints. + Mỗi phần tử trong bộ sưu tập này nên thỏa mãn những ràng buộc của nó. + diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php index 4cb354ec4e6d..06f7e8577527 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php @@ -698,4 +698,25 @@ public function testNestedObjectIsValidatedIfGroupInValidConstraintIsValidated() $this->assertCount(2, $violations); } + + public function testNestedObjectIsValidatedInMultipleGroupsIfGroupInValidConstraintIsValidated() + { + $entity = new Entity(); + $entity->firstName = null; + + $reference = new Reference(); + $reference->value = null; + + $entity->childA = $reference; + + $this->metadata->addPropertyConstraint('firstName', new NotBlank()); + $this->metadata->addPropertyConstraint('childA', new Valid(['groups' => ['group1', 'group2']])); + + $this->referenceMetadata->addPropertyConstraint('value', new NotBlank(['groups' => 'group1'])); + $this->referenceMetadata->addPropertyConstraint('value', new NotNull(['groups' => 'group2'])); + + $violations = $this->validator->validate($entity, null, ['Default', 'group1', 'group2']); + + $this->assertCount(3, $violations); + } } diff --git a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php index dc06899ae13b..121ecf236467 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -14,6 +14,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Composite; use Symfony\Component\Validator\Constraints\GroupSequence; +use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; use Symfony\Component\Validator\Context\ExecutionContext; use Symfony\Component\Validator\Context\ExecutionContextInterface; @@ -720,8 +721,9 @@ private function validateInGroup($value, ?string $cacheKey, MetadataInterface $m // that constraints belong to multiple validated groups if (null !== $cacheKey) { $constraintHash = spl_object_hash($constraint); - - if ($constraint instanceof Composite) { + // instanceof Valid: In case of using a Valid constraint with many groups + // it makes a reference object get validated by each group + if ($constraint instanceof Composite || $constraint instanceof Valid) { $constraintHash .= $group; } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 780f9da53bcd..4ed79466e613 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -1900,7 +1900,7 @@ public function testUnsupportedBuiltInTagWithScalar() $this->parser->parse('!!iterator foo'); } - public function testExceptionWhenUsingUnsuportedBuiltInTags() + public function testExceptionWhenUsingUnsupportedBuiltInTags() { $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); $this->expectExceptionMessage('The built-in tag "!!foo" is not implemented at line 1 (near "!!foo").');