Merge branch '5.0'
* 5.0: [FrameworkBundle] Fix session.attribute_bag service definition [Routing] Remove unused properties from the Route annotation [Routing] Add missing _locale requirements Update LdapBindAuthenticationProvider.php Add reproducer to for hit after update expire cacheItem [Cache] fix FilesystemTagAwareAdapter failing when a tag link preexists
This commit is contained in:
commit
7ce2f2401a
@ -48,7 +48,8 @@
|
|||||||
<service id="Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface" alias="session.flash_bag" />
|
<service id="Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface" alias="session.flash_bag" />
|
||||||
|
|
||||||
<service id="session.attribute_bag" class="Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag">
|
<service id="session.attribute_bag" class="Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag">
|
||||||
<factory service="session" method="getAttributeBag" />
|
<factory service="session" method="getBag"/>
|
||||||
|
<argument>attributes</argument>
|
||||||
<deprecated package="symfony/framework-bundle" version="5.1">The "%service_id%" service is deprecated, use "$session->getAttributeBag()" instead.</deprecated>
|
<deprecated package="symfony/framework-bundle" version="5.1">The "%service_id%" service is deprecated, use "$session->getAttributeBag()" instead.</deprecated>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class FilesystemTagAwareAdapter extends AbstractTagAwareAdapter implements Prune
|
|||||||
|
|
||||||
$file = $this->getFile($id);
|
$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);
|
@unlink($file);
|
||||||
$failed[] = $id;
|
$failed[] = $id;
|
||||||
}
|
}
|
||||||
|
@ -141,4 +141,42 @@ trait TagAwareTestTrait
|
|||||||
$i = $pool->getItem('k');
|
$i = $pool->getItem('k');
|
||||||
$this->assertSame(['foo' => 'foo'], $i->getMetadata()[CacheItem::METADATA_TAGS]);
|
$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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,6 @@ class Route
|
|||||||
private $methods = [];
|
private $methods = [];
|
||||||
private $schemes = [];
|
private $schemes = [];
|
||||||
private $condition;
|
private $condition;
|
||||||
private $locale;
|
|
||||||
private $format;
|
|
||||||
private $utf8;
|
|
||||||
private $priority;
|
private $priority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||||
|
|
||||||
use Symfony\Component\Routing\RouteCollection;
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
|
use Symfony\Component\Routing\RouteCompiler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nicolas Grekas <p@tchwork.com>
|
* @author Nicolas Grekas <p@tchwork.com>
|
||||||
|
@ -33,6 +33,7 @@ trait PrefixTrait
|
|||||||
foreach ($prefix as $locale => $localePrefix) {
|
foreach ($prefix as $locale => $localePrefix) {
|
||||||
$localizedRoute = clone $route;
|
$localizedRoute = clone $route;
|
||||||
$localizedRoute->setDefault('_locale', $locale);
|
$localizedRoute->setDefault('_locale', $locale);
|
||||||
|
$localizedRoute->setRequirement('_locale', preg_quote($locale, RouteCompiler::REGEX_DELIMITER));
|
||||||
$localizedRoute->setDefault('_canonical_route', $name);
|
$localizedRoute->setDefault('_canonical_route', $name);
|
||||||
$localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
|
$localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
|
||||||
$routes->add($name.'.'.$locale, $localizedRoute);
|
$routes->add($name.'.'.$locale, $localizedRoute);
|
||||||
|
@ -8,4 +8,6 @@ return function (RoutingConfigurator $routes) {
|
|||||||
|
|
||||||
$add('foo', ['fr' => '/foo']);
|
$add('foo', ['fr' => '/foo']);
|
||||||
$add('bar', ['fr' => '/bar']);
|
$add('bar', ['fr' => '/bar']);
|
||||||
|
|
||||||
|
$routes->add('non_localized', '/non-localized');
|
||||||
};
|
};
|
||||||
|
@ -237,6 +237,7 @@ class PhpFileLoaderTest extends TestCase
|
|||||||
$expectedCollection->add('baz.en', (new Route('/baz'))->setDefaults(['_locale' => 'en', '_canonical_route' => 'baz'])->setRequirement('_locale', 'en'));
|
$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_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('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_sub_i18n.php')));
|
||||||
$expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl_i18n.php')));
|
$expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl_i18n.php')));
|
||||||
|
@ -205,6 +205,9 @@ class XmlFileLoaderTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals('/le-prefix/suffix', $routeCollection->get('imported.fr')->getPath());
|
$this->assertEquals('/le-prefix/suffix', $routeCollection->get('imported.fr')->getPath());
|
||||||
$this->assertEquals('/the-prefix/suffix', $routeCollection->get('imported.en')->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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -338,6 +338,9 @@ class YamlFileLoaderTest extends TestCase
|
|||||||
$this->assertCount(2, $routes);
|
$this->assertCount(2, $routes);
|
||||||
$this->assertEquals('/nl/imported', $routes->get('imported.nl')->getPath());
|
$this->assertEquals('/nl/imported', $routes->get('imported.nl')->getPath());
|
||||||
$this->assertEquals('/en/imported', $routes->get('imported.en')->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()
|
public function testImportingRoutesWithOfficialLocales()
|
||||||
|
@ -82,14 +82,13 @@ class LdapBindAuthenticationProvider extends UserAuthenticationProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$username = $this->ldap->escape($username, '', LdapInterface::ESCAPE_DN);
|
|
||||||
|
|
||||||
if ($this->queryString) {
|
if ($this->queryString) {
|
||||||
if ('' !== $this->searchDn && '' !== $this->searchPassword) {
|
if ('' !== $this->searchDn && '' !== $this->searchPassword) {
|
||||||
$this->ldap->bind($this->searchDn, $this->searchPassword);
|
$this->ldap->bind($this->searchDn, $this->searchPassword);
|
||||||
} else {
|
} else {
|
||||||
throw new LogicException('Using the "query_string" config without using a "search_dn" and a "search_password" is not supported.');
|
throw new LogicException('Using the "query_string" config without using a "search_dn" and a "search_password" is not supported.');
|
||||||
}
|
}
|
||||||
|
$username = $this->ldap->escape($username, '', LdapInterface::ESCAPE_FILTER);
|
||||||
$query = str_replace('{username}', $username, $this->queryString);
|
$query = str_replace('{username}', $username, $this->queryString);
|
||||||
$result = $this->ldap->query($this->dnString, $query)->execute();
|
$result = $this->ldap->query($this->dnString, $query)->execute();
|
||||||
if (1 !== $result->count()) {
|
if (1 !== $result->count()) {
|
||||||
@ -98,6 +97,7 @@ class LdapBindAuthenticationProvider extends UserAuthenticationProvider
|
|||||||
|
|
||||||
$dn = $result[0]->getDn();
|
$dn = $result[0]->getDn();
|
||||||
} else {
|
} else {
|
||||||
|
$username = $this->ldap->escape($username, '', LdapInterface::ESCAPE_DN);
|
||||||
$dn = str_replace('{username}', $username, $this->dnString);
|
$dn = str_replace('{username}', $username, $this->dnString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user