Skip to content

Commit 0992359

Browse files
Merge branch '4.4' into 5.2
* 4.4: Stop using deprecated ArrayCache from Doctrine [Intl] fix Locale::getFallback() throwing exception on long $locale
2 parents d8fd8f8 + 556b38d commit 0992359

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ValidatorBuilder.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Doctrine\Common\Annotations\Reader;
1717
use Doctrine\Common\Cache\ArrayCache;
1818
use Psr\Cache\CacheItemPoolInterface;
19+
use Symfony\Component\Cache\Adapter\ArrayAdapter;
20+
use Symfony\Component\Cache\DoctrineProvider;
1921
use Symfony\Component\Validator\Context\ExecutionContextFactory;
2022
use Symfony\Component\Validator\Exception\ValidatorException;
2123
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
@@ -266,7 +268,11 @@ public function setDoctrineAnnotationReader(?Reader $reader): self
266268
*/
267269
public function addDefaultDoctrineAnnotationReader(): self
268270
{
269-
$this->annotationReader = new CachedReader(new AnnotationReader(), new ArrayCache());
271+
if (class_exists(ArrayAdapter::class)) {
272+
$this->annotationReader = new CachedReader(new AnnotationReader(), new DoctrineProvider(new ArrayAdapter()));
273+
} else {
274+
$this->annotationReader = new CachedReader(new AnnotationReader(), new ArrayCache());
275+
}
270276

271277
return $this;
272278
}

0 commit comments

Comments
 (0)