Merge branch '5.2' into 5.x
* 5.2: Stop using deprecated ArrayCache from Doctrine [EventDispatcher] fix registering subscribers twice on edge-case [Intl] fix Locale::getFallback() throwing exception on long $locale
This commit is contained in:
commit
8040f14f04
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Bridge\Doctrine\Test;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Doctrine\ORM\Configuration;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
|
||||
@ -72,8 +71,6 @@ class DoctrineTestHelper
|
||||
$config->setProxyDir(sys_get_temp_dir());
|
||||
$config->setProxyNamespace('SymfonyTests\Doctrine');
|
||||
$config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader()));
|
||||
$config->setQueryCacheImpl(new ArrayCache());
|
||||
$config->setMetadataCacheImpl(new ArrayCache());
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
@ -1493,8 +1493,8 @@ class FrameworkExtension extends Extension
|
||||
}
|
||||
|
||||
$container
|
||||
->getDefinition('annotations.filesystem_cache')
|
||||
->replaceArgument(0, $cacheDir)
|
||||
->getDefinition('annotations.filesystem_cache_adapter')
|
||||
->replaceArgument(2, $cacheDir)
|
||||
;
|
||||
|
||||
$cacheService = 'annotations.filesystem_cache';
|
||||
|
@ -15,9 +15,9 @@ use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
use Doctrine\Common\Annotations\CachedReader;
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Doctrine\Common\Cache\FilesystemCache;
|
||||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
|
||||
use Symfony\Component\Cache\DoctrineProvider;
|
||||
|
||||
@ -35,15 +35,24 @@ return static function (ContainerConfigurator $container) {
|
||||
->set('annotations.cached_reader', CachedReader::class)
|
||||
->args([
|
||||
service('annotations.reader'),
|
||||
inline_service(ArrayCache::class),
|
||||
inline_service(DoctrineProvider::class)->args([
|
||||
inline_service(ArrayAdapter::class)
|
||||
]),
|
||||
abstract_arg('Debug-Flag'),
|
||||
])
|
||||
|
||||
->set('annotations.filesystem_cache', FilesystemCache::class)
|
||||
->set('annotations.filesystem_cache_adapter', FilesystemAdapter::class)
|
||||
->args([
|
||||
'',
|
||||
0,
|
||||
abstract_arg('Cache-Directory'),
|
||||
])
|
||||
|
||||
->set('annotations.filesystem_cache', DoctrineProvider::class)
|
||||
->args([
|
||||
service('annotations.filesystem_cache_adapter'),
|
||||
])
|
||||
|
||||
->set('annotations.cache_warmer', AnnotationsCacheWarmer::class)
|
||||
->args([
|
||||
service('annotations.reader'),
|
||||
|
@ -979,7 +979,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$container->addCompilerPass(new TestAnnotationsPass());
|
||||
$container->compile();
|
||||
|
||||
$this->assertEquals($container->getParameter('kernel.cache_dir').'/annotations', $container->getDefinition('annotations.filesystem_cache')->getArgument(0));
|
||||
$this->assertEquals($container->getParameter('kernel.cache_dir').'/annotations', $container->getDefinition('annotations.filesystem_cache_adapter')->getArgument(2));
|
||||
$this->assertSame('annotations.filesystem_cache', (string) $container->getDefinition('annotation_reader')->getArgument(1));
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ class RegisterListenersPass implements CompilerPassInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
$dispatcherDefinitions[] = $container->getDefinition($attributes['dispatcher']);
|
||||
$dispatcherDefinitions[$attributes['dispatcher']] = $container->getDefinition($attributes['dispatcher']);
|
||||
}
|
||||
|
||||
if (!$dispatcherDefinitions) {
|
||||
|
@ -66,7 +66,8 @@ final class Locale extends \Locale
|
||||
public static function getFallback(string $locale): ?string
|
||||
{
|
||||
if (\function_exists('locale_parse')) {
|
||||
$localeSubTags = locale_parse($locale);
|
||||
$localeSubTags = locale_parse($locale) ?? ['language' => $locale];
|
||||
|
||||
if (1 === \count($localeSubTags)) {
|
||||
if ('root' !== self::$defaultFallback && self::$defaultFallback === $localeSubTags['language']) {
|
||||
return 'root';
|
||||
|
@ -70,4 +70,16 @@ class LocaleTest extends TestCase
|
||||
|
||||
Locale::setDefaultFallback($prev);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires function locale_parse
|
||||
*/
|
||||
public function testLongLocaleFallback()
|
||||
{
|
||||
$locale = 'LC_TYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;'.
|
||||
'LC_MONETARY=fr_FR.UTF-8;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=fr_FR.UTF-8;'.
|
||||
'LC_ADDRESS=fr_FR.UTF-8;LC_TELEPHONE=fr_FR.UTF-8;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=fr_FR.UTF-8';
|
||||
|
||||
$this->assertNull(Locale::getFallback($locale));
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ use Doctrine\Common\Annotations\CachedReader;
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Cache\DoctrineProvider;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextFactory;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
|
||||
@ -266,7 +268,11 @@ class ValidatorBuilder
|
||||
*/
|
||||
public function addDefaultDoctrineAnnotationReader(): self
|
||||
{
|
||||
$this->annotationReader = new CachedReader(new AnnotationReader(), new ArrayCache());
|
||||
if (class_exists(ArrayAdapter::class)) {
|
||||
$this->annotationReader = new CachedReader(new AnnotationReader(), new DoctrineProvider(new ArrayAdapter()));
|
||||
} else {
|
||||
$this->annotationReader = new CachedReader(new AnnotationReader(), new ArrayCache());
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user