Skip to content

Commit ea7e245

Browse files
committed
Merge branch '3.2'
* 3.2: Fix tests that do not trigger any depreciation [HttpFoundation] Fix test ensuring isMethodSafe() checks cacheable [Cache] Mark FilesystemAdapterTrait as internal [FrameworkBundle] Dont rely on any parent definition for "cache.annotations"
2 parents 13265ae + a8c279d commit ea7e245

File tree

8 files changed

+35
-12
lines changed

8 files changed

+35
-12
lines changed

src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
2525
private $skippedFile = false;
2626
private $wasSkipped = array();
2727
private $isSkipped = array();
28-
private $expectedDeprecations;
29-
private $gatheredDeprecations;
28+
private $expectedDeprecations = array();
29+
private $gatheredDeprecations = array();
3030
private $previousErrorHandler;
3131

3232
/**
@@ -181,7 +181,8 @@ public function endTest(\PHPUnit_Framework_Test $test, $time)
181181
$test->getTestResultObject()->addFailure($test, $e, $time);
182182
}
183183

184-
$this->expectedDeprecations = $this->gatheredDeprecations = $this->previousErrorHandler = null;
184+
$this->expectedDeprecations = $this->gatheredDeprecations = array();
185+
$this->previousErrorHandler = null;
185186
}
186187
if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) {
187188
$groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false));

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolClearerPass.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14+
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1415
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Reference;
@@ -38,5 +39,22 @@ public function process(ContainerBuilder $container)
3839
}
3940
}
4041
}
42+
43+
if (!$container->has('cache.annotations')) {
44+
return;
45+
}
46+
$factory = array(AbstractAdapter::class, 'createSystemCache');
47+
$annotationsPool = $container->getDefinition('cache.annotations');
48+
if ($factory !== $annotationsPool->getFactory() || 4 !== count($annotationsPool->getArguments())) {
49+
return;
50+
}
51+
if ($container->has('monolog.logger.cache')) {
52+
$annotationsPool->addArgument(new Reference('monolog.logger.cache'));
53+
} elseif ($container->has('cache.system')) {
54+
$systemPool = $container->getDefinition('cache.system');
55+
if ($factory === $systemPool->getFactory() && 5 <= count($systemArgs = $systemPool->getArguments())) {
56+
$annotationsPool->addArgument($systemArgs[4]);
57+
}
58+
}
4159
}
4260
}

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,7 @@ private function registerPropertyInfoConfiguration(array $config, ContainerBuild
12381238
private function registerCacheConfiguration(array $config, ContainerBuilder $container)
12391239
{
12401240
$version = substr(str_replace('/', '-', base64_encode(hash('sha256', uniqid(mt_rand(), true), true))), 0, 22);
1241+
$container->getDefinition('cache.annotations')->replaceArgument(2, $version);
12411242
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
12421243
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
12431244
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ public function build(ContainerBuilder $container)
9393
$container->addCompilerPass(new SerializerPass());
9494
$container->addCompilerPass(new PropertyInfoPass());
9595
$container->addCompilerPass(new ControllerArgumentValueResolverPass());
96-
$container->addCompilerPass(new CachePoolPass());
96+
$container->addCompilerPass(new CachePoolPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 32);
9797
$container->addCompilerPass(new ValidateWorkflowsPass());
9898
$container->addCompilerPass(new CachePoolClearerPass(), PassConfig::TYPE_AFTER_REMOVING);
9999

100100
if ($container->getParameter('kernel.debug')) {
101-
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1);
101+
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
102102
$container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING);
103103
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
104104
$container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);

src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@
2222
<tag name="cache.pool" />
2323
</service>
2424

25-
<service id="cache.annotations" parent="cache.system" public="false">
26-
<tag name="cache.pool" />
25+
<service id="cache.annotations" class="Symfony\Component\Cache\Adapter\AdapterInterface" public="false">
26+
<factory class="Symfony\Component\Cache\Adapter\AbstractAdapter" method="createSystemCache" />
27+
<tag name="cache.pool" clearer="cache.default_clearer" />
28+
<argument /> <!-- namespace -->
29+
<argument>0</argument> <!-- default lifetime -->
30+
<argument /> <!-- version -->
31+
<argument>%kernel.cache_dir%/pools</argument>
2732
</service>
2833

2934
<service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\AdapterInterface" abstract="true">

src/Symfony/Component/Cache/Adapter/FilesystemAdapterTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
/**
1717
* @author Nicolas Grekas <p@tchwork.com>
18+
*
19+
* @internal
1820
*/
1921
trait FilesystemAdapterTrait
2022
{

src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public function testDefaultLifeTime()
2828
{
2929
if (isset($this->skippedTests[__FUNCTION__])) {
3030
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
31-
32-
return;
3331
}
3432

3533
$cache = $this->createCachePool(2);
@@ -51,8 +49,6 @@ public function testNotUnserializable()
5149
{
5250
if (isset($this->skippedTests[__FUNCTION__])) {
5351
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
54-
55-
return;
5652
}
5753

5854
$cache = $this->createCachePool();

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2020,7 +2020,7 @@ public function methodSafeProvider()
20202020
public function testMethodSafeChecksCacheable()
20212021
{
20222022
$request = new Request();
2023-
$request->setMethod('OPTION');
2023+
$request->setMethod('OPTIONS');
20242024
$this->assertFalse($request->isMethodSafe());
20252025
}
20262026

0 commit comments

Comments
 (0)