From f815b011c3d02c486e29b682886b6eb8583bd8c8 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 18 Apr 2020 16:27:57 +0200 Subject: [PATCH 1/6] [Cache] fix FilesystemTagAwareAdapter failing when a tag link preexists --- .../Component/Cache/Adapter/FilesystemTagAwareAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php index d9a1ad39ac..2ce9eeb977 100644 --- a/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php @@ -107,7 +107,7 @@ class FilesystemTagAwareAdapter extends AbstractTagAwareAdapter implements Prune $file = $this->getFile($id); - if (!@symlink($file, $this->getFile($id, true, $tagFolder))) { + if (!@symlink($file, $tagLink = $this->getFile($id, true, $tagFolder)) && !is_link($tagLink)) { @unlink($file); $failed[] = $id; } From d082eca7ddde683fd8e0be56f13f4b865dc6294d Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 15 Apr 2020 14:44:16 +0200 Subject: [PATCH 2/6] Add reproducer to for hit after update expire cacheItem --- .../Cache/Tests/Traits/TagAwareTestTrait.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php b/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php index 7f1544af5b..8b687b5a75 100644 --- a/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php +++ b/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php @@ -155,4 +155,42 @@ trait TagAwareTestTrait $i = $pool->getItem('k'); $this->assertSame(['foo' => 'foo'], $i->getMetadata()[CacheItem::METADATA_TAGS]); } + + public function testRefreshAfterExpires() + { + $pool = $this->createCachePool(); + $pool->clear(); + + $cacheItem = $pool->getItem('test'); + + $this->assertFalse($cacheItem->isHit()); + + // write cache with expires + $cacheItem->set('test'); + $cacheItem->tag('1234'); + $cacheItem->expiresAfter(1); + + $pool->save($cacheItem); + + $cacheItem = $pool->getItem('test'); + $this->assertTrue($cacheItem->isHit()); + + // wait until expired + sleep(2); + + // item should not longer be a hit + $cacheItem = $pool->getItem('test'); + $this->assertFalse($cacheItem->isHit()); + + // update expired item + $cacheItem->set('test'); + $cacheItem->tag('1234'); + $cacheItem->expiresAfter(1); + + $pool->save($cacheItem); + + // item should be again a hit + $cacheItem = $pool->getItem('test'); + $this->assertTrue($cacheItem->isHit()); + } } From 4bda68a9a25f2a99addd2e53315f3a1523b25848 Mon Sep 17 00:00:00 2001 From: stoccc Date: Sun, 19 Apr 2020 23:34:01 +0200 Subject: [PATCH 3/6] Update LdapBindAuthenticationProvider.php --- .../Provider/LdapBindAuthenticationProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php index 00092c4313..e68649801b 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php @@ -87,9 +87,8 @@ class LdapBindAuthenticationProvider extends UserAuthenticationProvider } try { - $username = $this->ldap->escape($username, '', LdapInterface::ESCAPE_DN); - if ($this->queryString) { + $username = $this->ldap->escape($username, '', LdapInterface::ESCAPE_FILTER); $query = str_replace('{username}', $username, $this->queryString); $result = $this->ldap->query($this->dnString, $query)->execute(); if (1 !== $result->count()) { @@ -98,6 +97,7 @@ class LdapBindAuthenticationProvider extends UserAuthenticationProvider $dn = $result[0]->getDn(); } else { + $username = $this->ldap->escape($username, '', LdapInterface::ESCAPE_DN); $dn = str_replace('{username}', $username, $this->dnString); } From 9fd62f79fb20ffa660fe99096471437f032ba0e0 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Mon, 20 Apr 2020 14:15:01 +0200 Subject: [PATCH 4/6] [Routing] Add missing _locale requirements Co-authored-by: Nicolas Grekas --- .../Routing/Loader/Configurator/ImportConfigurator.php | 2 ++ src/Symfony/Component/Routing/Loader/XmlFileLoader.php | 1 + src/Symfony/Component/Routing/Loader/YamlFileLoader.php | 1 + .../Component/Routing/Tests/Fixtures/php_dsl_sub_i18n.php | 2 ++ .../Component/Routing/Tests/Loader/PhpFileLoaderTest.php | 1 + .../Component/Routing/Tests/Loader/XmlFileLoaderTest.php | 3 +++ .../Component/Routing/Tests/Loader/YamlFileLoaderTest.php | 3 +++ 7 files changed, 13 insertions(+) diff --git a/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php b/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php index f11b795752..0059a632a1 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Routing\Loader\Configurator; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; +use Symfony\Component\Routing\RouteCompiler; /** * @author Nicolas Grekas @@ -63,6 +64,7 @@ class ImportConfigurator foreach ($prefix as $locale => $localePrefix) { $localizedRoute = clone $route; $localizedRoute->setDefault('_locale', $locale); + $localizedRoute->setRequirement('_locale', preg_quote($locale, RouteCompiler::REGEX_DELIMITER)); $localizedRoute->setDefault('_canonical_route', $name); $localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath())); $this->route->add($name.'.'.$locale, $localizedRoute); diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index 49b552d627..31c614950e 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -211,6 +211,7 @@ class XmlFileLoader extends FileLoader $localizedRoute = clone $route; $localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath())); $localizedRoute->setDefault('_locale', $locale); + $localizedRoute->setRequirement('_locale', preg_quote($locale, RouteCompiler::REGEX_DELIMITER)); $localizedRoute->setDefault('_canonical_route', $name); $subCollection->add($name.'.'.$locale, $localizedRoute); } diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index 868da9bd30..8d4b9abdb1 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -216,6 +216,7 @@ class YamlFileLoader extends FileLoader foreach ($prefix as $locale => $localePrefix) { $localizedRoute = clone $route; $localizedRoute->setDefault('_locale', $locale); + $localizedRoute->setRequirement('_locale', preg_quote($locale, RouteCompiler::REGEX_DELIMITER)); $localizedRoute->setDefault('_canonical_route', $name); $localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath())); $subCollection->add($name.'.'.$locale, $localizedRoute); diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/php_dsl_sub_i18n.php b/src/Symfony/Component/Routing/Tests/Fixtures/php_dsl_sub_i18n.php index e79edc869d..e6d846dd46 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/php_dsl_sub_i18n.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/php_dsl_sub_i18n.php @@ -8,4 +8,6 @@ return function (RoutingConfigurator $routes) { $add('foo', ['fr' => '/foo']); $add('bar', ['fr' => '/bar']); + + $routes->add('non_localized', '/non-localized'); }; diff --git a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php index 789848c660..b84d5ff354 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php @@ -234,6 +234,7 @@ class PhpFileLoaderTest extends TestCase $expectedCollection->add('baz.en', (new Route('/baz'))->setDefaults(['_locale' => 'en', '_canonical_route' => 'baz'])->setRequirement('_locale', 'en')); $expectedCollection->add('c_foo.fr', (new Route('/ench/pub/foo'))->setDefaults(['_locale' => 'fr', '_canonical_route' => 'c_foo'])->setRequirement('_locale', 'fr')); $expectedCollection->add('c_bar.fr', (new Route('/ench/pub/bar'))->setDefaults(['_locale' => 'fr', '_canonical_route' => 'c_bar'])->setRequirement('_locale', 'fr')); + $expectedCollection->add('non_localized.fr', (new Route('/ench/non-localized'))->setDefaults(['_locale' => 'fr', '_canonical_route' => 'non_localized'])->setRequirement('_locale', 'fr')); $expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl_sub_i18n.php'))); $expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl_i18n.php'))); diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index 02e1e14d4a..383cda0176 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -201,6 +201,9 @@ class XmlFileLoaderTest extends TestCase $this->assertEquals('/le-prefix/suffix', $routeCollection->get('imported.fr')->getPath()); $this->assertEquals('/the-prefix/suffix', $routeCollection->get('imported.en')->getPath()); + + $this->assertSame('fr', $routeCollection->get('imported.fr')->getRequirement('_locale')); + $this->assertSame('en', $routeCollection->get('imported.en')->getRequirement('_locale')); } /** diff --git a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php index 3878663e6b..e5571b0b7a 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php @@ -334,6 +334,9 @@ class YamlFileLoaderTest extends TestCase $this->assertCount(2, $routes); $this->assertEquals('/nl/imported', $routes->get('imported.nl')->getPath()); $this->assertEquals('/en/imported', $routes->get('imported.en')->getPath()); + + $this->assertSame('nl', $routes->get('imported.nl')->getRequirement('_locale')); + $this->assertSame('en', $routes->get('imported.en')->getRequirement('_locale')); } public function testImportingRoutesWithOfficialLocales() From 9ac1c76fd52464af7b851c7fc34c6c34242ec90d Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Mon, 20 Apr 2020 16:41:27 +0200 Subject: [PATCH 5/6] [Routing] Remove unused properties from the Route annotation --- src/Symfony/Component/Routing/Annotation/Route.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Symfony/Component/Routing/Annotation/Route.php b/src/Symfony/Component/Routing/Annotation/Route.php index 8183b6fc55..52b208c41b 100644 --- a/src/Symfony/Component/Routing/Annotation/Route.php +++ b/src/Symfony/Component/Routing/Annotation/Route.php @@ -31,9 +31,6 @@ class Route private $methods = []; private $schemes = []; private $condition; - private $locale; - private $format; - private $utf8; /** * @param array $data An array of key/value parameters From 76072c6424840a137bd9cad609db3d7a79ce7ab0 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Mon, 20 Apr 2020 18:08:44 +0200 Subject: [PATCH 6/6] [FrameworkBundle] Fix session.attribute_bag service definition --- .../Bundle/FrameworkBundle/Resources/config/session.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml index 9f3a5b78c1..9080af9379 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml @@ -41,7 +41,8 @@ - + + attributes