diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php
index cbd864d2ede3e..9625d6fa4d0fa 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 @@
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 @@ public function warmUp($cacheDir)
// 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 db6fe4ba61026..f3d6a875e0274 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 0b2ede48646a0..9d752aa21eea1 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 51a965f71baa2..3779fd9a695dd 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 2b4ea429628e3..807a557dfc54e 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 54b0c484d20bb..d2ac13fe7279f 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 9b90ab7c2f140..0d406058fb9d1 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 b32274e7e7a80..c1a3e9d9be72f 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\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 @@ public function testAnnotationsCacheWarmerWithDebugDisabled()
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 @@ public function testAnnotationsCacheWarmerWithDebugEnabled()
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 fdd40d48d6fd9..4c7c1c929ad9e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php
@@ -13,7 +13,6 @@
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 @@ public function testWarmUp()
$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 @@ public function testWarmUp()
$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 @@ public function testWarmUpWithoutLoader()
$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 47c88f1a206af..16f4ce4c0a34f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php
@@ -13,7 +13,6 @@
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 @@ public function testWarmUp()
$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 @@ public function testWarmUp()
$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 @@ public function testWarmUpWithAnnotations()
$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 @@ public function testWarmUpWithAnnotations()
$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 @@ public function testWarmUpWithoutLoader()
$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);
}
}