diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php index cbd864d2ed..9625d6fa4d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php @@ -11,11 +11,9 @@ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; -use Psr\Cache\CacheItemPoolInterface; -use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; +use Symfony\Component\Cache\Adapter\NullAdapter; use Symfony\Component\Cache\Adapter\PhpArrayAdapter; -use Symfony\Component\Cache\Adapter\ProxyAdapter; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; /** @@ -24,19 +22,13 @@ use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; abstract class AbstractPhpFileCacheWarmer implements CacheWarmerInterface { private $phpArrayFile; - private $fallbackPool; /** - * @param string $phpArrayFile The PHP file where metadata are cached - * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached + * @param string $phpArrayFile The PHP file where metadata are cached */ - public function __construct(string $phpArrayFile, CacheItemPoolInterface $fallbackPool) + public function __construct(string $phpArrayFile) { $this->phpArrayFile = $phpArrayFile; - if (!$fallbackPool instanceof AdapterInterface) { - $fallbackPool = new ProxyAdapter($fallbackPool); - } - $this->fallbackPool = $fallbackPool; } /** @@ -68,13 +60,7 @@ abstract class AbstractPhpFileCacheWarmer implements CacheWarmerInterface // so here we un-serialize the values first $values = array_map(function ($val) { return null !== $val ? unserialize($val) : null; }, $arrayAdapter->getValues()); - $this->warmUpPhpArrayAdapter(new PhpArrayAdapter($this->phpArrayFile, $this->fallbackPool), $values); - - foreach ($values as $k => $v) { - $item = $this->fallbackPool->getItem($k); - $this->fallbackPool->saveDeferred($item->set($v)); - } - $this->fallbackPool->commit(); + $this->warmUpPhpArrayAdapter(new PhpArrayAdapter($this->phpArrayFile, new NullAdapter()), $values); } protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values) diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php index db6fe4ba61..f3d6a875e0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php @@ -31,13 +31,18 @@ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer private $debug; /** - * @param Reader $annotationReader - * @param string $phpArrayFile The PHP file where annotations are cached - * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered annotations are cached + * @param string $phpArrayFile The PHP file where annotations are cached + * @param string $excludeRegexp + * @param bool $debug */ - public function __construct(Reader $annotationReader, string $phpArrayFile, CacheItemPoolInterface $fallbackPool, string $excludeRegexp = null, bool $debug = false) + public function __construct(Reader $annotationReader, string $phpArrayFile, $excludeRegexp = null, $debug = false) { - parent::__construct($phpArrayFile, $fallbackPool); + if ($excludeRegexp instanceof CacheItemPoolInterface) { + @trigger_error(sprintf('The CacheItemPoolInterface $fallbackPool argument of "%s()" is deprecated since Symfony 4.2, you should not pass it anymore.', __METHOD__), E_USER_DEPRECATED); + $excludeRegexp = $debug; + $debug = 4 < \func_num_args() && \func_get_arg(4); + } + parent::__construct($phpArrayFile); $this->annotationReader = $annotationReader; $this->excludeRegexp = $excludeRegexp; $this->debug = $debug; diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php index 0b2ede4864..9d752aa21e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php @@ -31,13 +31,15 @@ class SerializerCacheWarmer extends AbstractPhpFileCacheWarmer private $loaders; /** - * @param LoaderInterface[] $loaders The serializer metadata loaders - * @param string $phpArrayFile The PHP file where metadata are cached - * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached + * @param LoaderInterface[] $loaders The serializer metadata loaders + * @param string $phpArrayFile The PHP file where metadata are cached */ - public function __construct(array $loaders, string $phpArrayFile, CacheItemPoolInterface $fallbackPool) + public function __construct(array $loaders, string $phpArrayFile) { - parent::__construct($phpArrayFile, $fallbackPool); + if (2 < \func_num_args() && \func_get_arg(2) instanceof CacheItemPoolInterface) { + @trigger_error(sprintf('The CacheItemPoolInterface $fallbackPool argument of "%s()" is deprecated since Symfony 4.2, you should not pass it anymore.', __METHOD__), E_USER_DEPRECATED); + } + parent::__construct($phpArrayFile); $this->loaders = $loaders; } diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php index 51a965f71b..3779fd9a69 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php @@ -33,13 +33,14 @@ class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer private $validatorBuilder; /** - * @param ValidatorBuilderInterface $validatorBuilder - * @param string $phpArrayFile The PHP file where metadata are cached - * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached + * @param string $phpArrayFile The PHP file where metadata are cached */ - public function __construct(ValidatorBuilderInterface $validatorBuilder, string $phpArrayFile, CacheItemPoolInterface $fallbackPool) + public function __construct(ValidatorBuilderInterface $validatorBuilder, string $phpArrayFile) { - parent::__construct($phpArrayFile, $fallbackPool); + if (2 < \func_num_args() && \func_get_arg(2) instanceof CacheItemPoolInterface) { + @trigger_error(sprintf('The CacheItemPoolInterface $fallbackPool argument of "%s()" is deprecated since Symfony 4.2, you should not pass it anymore.', __METHOD__), E_USER_DEPRECATED); + } + parent::__construct($phpArrayFile); $this->validatorBuilder = $validatorBuilder; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml index 2b4ea42962..807a557dfc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml @@ -36,7 +36,6 @@ %kernel.cache_dir%/annotations.php - #^Symfony\\(?:Component\\HttpKernel\\|Bundle\\FrameworkBundle\\Controller\\(?!AbstractController$|Controller$))# %kernel.debug% diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml index 54b0c484d2..d2ac13fe72 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml @@ -90,7 +90,6 @@ %serializer.mapping.cache.file% - diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml index 9b90ab7c2f..0d406058fb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml @@ -35,7 +35,6 @@ %validator.mapping.cache.file% - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php index b32274e7e7..c1a3e9d9be 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php @@ -7,7 +7,6 @@ use Doctrine\Common\Annotations\CachedReader; use Doctrine\Common\Annotations\Reader; use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; -use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\NullAdapter; use Symfony\Component\Cache\Adapter\PhpArrayAdapter; use Symfony\Component\Cache\DoctrineProvider; @@ -37,13 +36,7 @@ class AnnotationsCacheWarmerTest extends TestCase file_put_contents($this->cacheDir.'/annotations.map', sprintf('cacheDir, __FUNCTION__); $reader = new AnnotationReader(); - $fallbackPool = new ArrayAdapter(); - $warmer = new AnnotationsCacheWarmer( - $reader, - $cacheFile, - $fallbackPool, - null - ); + $warmer = new AnnotationsCacheWarmer($reader, $cacheFile); $warmer->warmUp($this->cacheDir); $this->assertFileExists($cacheFile); @@ -63,14 +56,7 @@ class AnnotationsCacheWarmerTest extends TestCase file_put_contents($this->cacheDir.'/annotations.map', sprintf('cacheDir, __FUNCTION__); $reader = new AnnotationReader(); - $fallbackPool = new ArrayAdapter(); - $warmer = new AnnotationsCacheWarmer( - $reader, - $cacheFile, - $fallbackPool, - null, - true - ); + $warmer = new AnnotationsCacheWarmer($reader, $cacheFile, null, true); $warmer->warmUp($this->cacheDir); $this->assertFileExists($cacheFile); // Assert cache is valid diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php index fdd40d48d6..4c7c1c929a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php @@ -13,7 +13,6 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; use Symfony\Bundle\FrameworkBundle\CacheWarmer\SerializerCacheWarmer; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; -use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\NullAdapter; use Symfony\Component\Cache\Adapter\PhpArrayAdapter; use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory; @@ -36,9 +35,7 @@ class SerializerCacheWarmerTest extends TestCase $file = sys_get_temp_dir().'/cache-serializer.php'; @unlink($file); - $fallbackPool = new ArrayAdapter(); - - $warmer = new SerializerCacheWarmer($loaders, $file, $fallbackPool); + $warmer = new SerializerCacheWarmer($loaders, $file); $warmer->warmUp(\dirname($file)); $this->assertFileExists($file); @@ -47,13 +44,6 @@ class SerializerCacheWarmerTest extends TestCase $this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit()); $this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit()); - - $values = $fallbackPool->getValues(); - - $this->assertInternalType('array', $values); - $this->assertCount(2, $values); - $this->assertArrayHasKey('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person', $values); - $this->assertArrayHasKey('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author', $values); } public function testWarmUpWithoutLoader() @@ -65,16 +55,9 @@ class SerializerCacheWarmerTest extends TestCase $file = sys_get_temp_dir().'/cache-serializer-without-loader.php'; @unlink($file); - $fallbackPool = new ArrayAdapter(); - - $warmer = new SerializerCacheWarmer(array(), $file, $fallbackPool); + $warmer = new SerializerCacheWarmer(array(), $file); $warmer->warmUp(\dirname($file)); $this->assertFileExists($file); - - $values = $fallbackPool->getValues(); - - $this->assertInternalType('array', $values); - $this->assertCount(0, $values); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php index 47c88f1a20..16f4ce4c0a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php @@ -13,7 +13,6 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; use Symfony\Bundle\FrameworkBundle\CacheWarmer\ValidatorCacheWarmer; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; -use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\NullAdapter; use Symfony\Component\Cache\Adapter\PhpArrayAdapter; use Symfony\Component\Validator\Mapping\ClassMetadata; @@ -32,9 +31,7 @@ class ValidatorCacheWarmerTest extends TestCase $file = sys_get_temp_dir().'/cache-validator.php'; @unlink($file); - $fallbackPool = new ArrayAdapter(); - - $warmer = new ValidatorCacheWarmer($validatorBuilder, $file, $fallbackPool); + $warmer = new ValidatorCacheWarmer($validatorBuilder, $file); $warmer->warmUp(\dirname($file)); $this->assertFileExists($file); @@ -43,13 +40,6 @@ class ValidatorCacheWarmerTest extends TestCase $this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit()); $this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit()); - - $values = $fallbackPool->getValues(); - - $this->assertInternalType('array', $values); - $this->assertCount(2, $values); - $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person', $values); - $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author', $values); } public function testWarmUpWithAnnotations() @@ -61,9 +51,7 @@ class ValidatorCacheWarmerTest extends TestCase $file = sys_get_temp_dir().'/cache-validator-with-annotations.php'; @unlink($file); - $fallbackPool = new ArrayAdapter(); - - $warmer = new ValidatorCacheWarmer($validatorBuilder, $file, $fallbackPool); + $warmer = new ValidatorCacheWarmer($validatorBuilder, $file); $warmer->warmUp(\dirname($file)); $this->assertFileExists($file); @@ -74,13 +62,6 @@ class ValidatorCacheWarmerTest extends TestCase $this->assertTrue($item->isHit()); $this->assertInstanceOf(ClassMetadata::class, $item->get()); - - $values = $fallbackPool->getValues(); - - $this->assertInternalType('array', $values); - $this->assertCount(2, $values); - $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category', $values); - $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.SubCategory', $values); } public function testWarmUpWithoutLoader() @@ -90,16 +71,9 @@ class ValidatorCacheWarmerTest extends TestCase $file = sys_get_temp_dir().'/cache-validator-without-loaders.php'; @unlink($file); - $fallbackPool = new ArrayAdapter(); - - $warmer = new ValidatorCacheWarmer($validatorBuilder, $file, $fallbackPool); + $warmer = new ValidatorCacheWarmer($validatorBuilder, $file); $warmer->warmUp(\dirname($file)); $this->assertFileExists($file); - - $values = $fallbackPool->getValues(); - - $this->assertInternalType('array', $values); - $this->assertCount(0, $values); } }