Skip to content

Commit 67c7b18

Browse files
authored
Backport the doctrine-cache-bundle changes (see contao#2534)
Description ----------- Backports the changes from contao#1916 to Contao 4.9 to make it compatible with PHP 8 (see contao#2263). Commits ------- ba9d21f Backport the doctrine-cache-bundle changes d1103e9 CS
1 parent 1cc3754 commit 67c7b18

File tree

9 files changed

+35
-47
lines changed

9 files changed

+35
-47
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"contao/manager-plugin": "^2.6.2",
5050
"doctrine/dbal": "^2.10",
5151
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
52-
"doctrine/doctrine-cache-bundle": "^1.3.1",
5352
"doctrine/orm": "^2.6.3",
5453
"dragonmantank/cron-expression": "^2.3",
5554
"friendsofsymfony/http-cache": "^2.6",

core-bundle/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"contao/imagine-svg": "^0.2.3 || ^1.0",
4949
"doctrine/dbal": "^2.10",
5050
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
51-
"doctrine/doctrine-cache-bundle": "^1.3.1",
5251
"doctrine/orm": "^2.6.3",
5352
"dragonmantank/cron-expression": "^2.3",
5453
"friendsofsymfony/http-cache": "^2.6",

core-bundle/src/ContaoManager/Plugin.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
1919
use Contao\ManagerPlugin\Routing\RoutingPluginInterface;
2020
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
21-
use Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle;
2221
use Knp\Bundle\MenuBundle\KnpMenuBundle;
2322
use Knp\Bundle\TimeBundle\KnpTimeBundle;
2423
use Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle;
@@ -59,7 +58,6 @@ public function getBundles(ParserInterface $parser): array
5958
MonologBundle::class,
6059
SwiftmailerBundle::class,
6160
DoctrineBundle::class,
62-
DoctrineCacheBundle::class,
6361
KnpMenuBundle::class,
6462
KnpTimeBundle::class,
6563
LexikMaintenanceBundle::class,

core-bundle/tests/ContaoManager/PluginTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
1818
use Contao\ManagerPlugin\Bundle\Parser\DelegatingParser;
1919
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
20-
use Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle;
2120
use Knp\Bundle\MenuBundle\KnpMenuBundle;
2221
use Knp\Bundle\TimeBundle\KnpTimeBundle;
2322
use Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle;
@@ -76,7 +75,6 @@ public function testReturnsTheBundles(): void
7675
$this->assertSame(
7776
[
7877
DoctrineBundle::class,
79-
DoctrineCacheBundle::class,
8078
KnpMenuBundle::class,
8179
KnpTimeBundle::class,
8280
LexikMaintenanceBundle::class,

manager-bundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
"contao/manager-plugin": "^2.4",
2323
"doctrine/dbal": "^2.10",
2424
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
25-
"doctrine/doctrine-cache-bundle": "^1.3.1",
2625
"friendsofsymfony/http-cache": "^2.6",
2726
"friendsofsymfony/http-cache-bundle": "^2.6",
2827
"lexik/maintenance-bundle": "^2.1.3",
2928
"nelmio/cors-bundle": "^1.5.3 || ^2.0.1",
3029
"nelmio/security-bundle": "^2.2",
3130
"ocramius/proxy-manager": "^2.1",
31+
"symfony/cache": "4.4.*",
3232
"symfony/config": "4.4.*",
3333
"symfony/console": "4.4.*",
3434
"symfony/debug": "4.4.*",

manager-bundle/src/ContaoManager/Plugin.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
use Contao\ManagerPlugin\Dependency\DependentPluginInterface;
3232
use Contao\ManagerPlugin\Routing\RoutingPluginInterface;
3333
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
34-
use Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle;
3534
use Doctrine\DBAL\DriverManager;
3635
use Doctrine\DBAL\Exception\DriverException;
3736
use FOS\HttpCacheBundle\FOSHttpCacheBundle;
@@ -96,7 +95,6 @@ public function getBundles(ParserInterface $parser)
9695
BundleConfig::create(MonologBundle::class),
9796
BundleConfig::create(SwiftmailerBundle::class),
9897
BundleConfig::create(DoctrineBundle::class),
99-
BundleConfig::create(DoctrineCacheBundle::class),
10098
BundleConfig::create(LexikMaintenanceBundle::class),
10199
BundleConfig::create(NelmioCorsBundle::class),
102100
BundleConfig::create(NelmioSecurityBundle::class),

manager-bundle/src/Resources/skeleton/config/config.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
imports:
22
- { resource: parameters.yml }
33
- { resource: security.yml }
4+
- { resource: services.yml }
45

56
# Put parameters here that don't need to change on each machine where the app is deployed
67
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
@@ -24,6 +25,12 @@ framework:
2425
handler_id: ~
2526
cookie_secure: auto
2627
fragments: { path: /_fragment }
28+
cache:
29+
pools:
30+
doctrine.result_cache_pool:
31+
adapter: cache.app
32+
doctrine.system_cache_pool:
33+
adapter: cache.system
2734

2835
# Contao configuration
2936
contao:
@@ -57,29 +64,13 @@ doctrine:
5764
naming_strategy: doctrine.orm.naming_strategy.default
5865
metadata_cache_driver:
5966
type: service
60-
id: doctrine_cache.providers.doctrine_metadata_cache
61-
result_cache_driver:
62-
type: service
63-
id: doctrine_cache.providers.doctrine_result_cache
67+
id: app.doctrine_system_cache_provider
6468
query_cache_driver:
6569
type: service
66-
id: doctrine_cache.providers.doctrine_query_cache
67-
68-
# Doctrine cache configuration
69-
doctrine_cache:
70-
providers:
71-
doctrine_metadata_cache:
72-
file_system:
73-
extension: .cache
74-
directory: '%kernel.cache_dir%/doctrine/metadata'
75-
doctrine_result_cache:
76-
file_system:
77-
extension: .cache
78-
directory: '%kernel.cache_dir%/doctrine/result'
79-
doctrine_query_cache:
80-
file_system:
81-
extension: .cache
82-
directory: '%kernel.cache_dir%/doctrine/query'
70+
id: app.doctrine_system_cache_provider
71+
result_cache_driver:
72+
type: service
73+
id: app.doctrine_result_cache_provider
8374

8475
# SwiftMailer configuration
8576
swiftmailer:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
app.doctrine_result_cache_provider:
3+
class: Symfony\Component\Cache\DoctrineProvider
4+
arguments:
5+
- '@doctrine.result_cache_pool'
6+
7+
app.doctrine_system_cache_provider:
8+
class: Symfony\Component\Cache\DoctrineProvider
9+
arguments:
10+
- '@doctrine.system_cache_pool'

manager-bundle/tests/ContaoManager/PluginTest.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Contao\ManagerPlugin\PluginLoader;
2323
use Contao\TestCase\ContaoTestCase;
2424
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
25-
use Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle;
2625
use Doctrine\DBAL\Connection;
2726
use FOS\HttpCacheBundle\FOSHttpCacheBundle;
2827
use Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle;
@@ -84,7 +83,7 @@ public function testReturnsTheBundles(): void
8483
/** @var array<BundleConfig> $bundles */
8584
$bundles = $plugin->getBundles(new DelegatingParser());
8685

87-
$this->assertCount(14, $bundles);
86+
$this->assertCount(13, $bundles);
8887

8988
$this->assertSame(FrameworkBundle::class, $bundles[0]->getName());
9089
$this->assertSame([], $bundles[0]->getReplace());
@@ -110,39 +109,35 @@ public function testReturnsTheBundles(): void
110109
$this->assertSame([], $bundles[5]->getReplace());
111110
$this->assertSame([], $bundles[5]->getLoadAfter());
112111

113-
$this->assertSame(DoctrineCacheBundle::class, $bundles[6]->getName());
112+
$this->assertSame(LexikMaintenanceBundle::class, $bundles[6]->getName());
114113
$this->assertSame([], $bundles[6]->getReplace());
115114
$this->assertSame([], $bundles[6]->getLoadAfter());
116115

117-
$this->assertSame(LexikMaintenanceBundle::class, $bundles[7]->getName());
116+
$this->assertSame(NelmioCorsBundle::class, $bundles[7]->getName());
118117
$this->assertSame([], $bundles[7]->getReplace());
119118
$this->assertSame([], $bundles[7]->getLoadAfter());
120119

121-
$this->assertSame(NelmioCorsBundle::class, $bundles[8]->getName());
120+
$this->assertSame(NelmioSecurityBundle::class, $bundles[8]->getName());
122121
$this->assertSame([], $bundles[8]->getReplace());
123122
$this->assertSame([], $bundles[8]->getLoadAfter());
124123

125-
$this->assertSame(NelmioSecurityBundle::class, $bundles[9]->getName());
124+
$this->assertSame(FOSHttpCacheBundle::class, $bundles[9]->getName());
126125
$this->assertSame([], $bundles[9]->getReplace());
127126
$this->assertSame([], $bundles[9]->getLoadAfter());
128127

129-
$this->assertSame(FOSHttpCacheBundle::class, $bundles[10]->getName());
128+
$this->assertSame(ContaoManagerBundle::class, $bundles[10]->getName());
130129
$this->assertSame([], $bundles[10]->getReplace());
131-
$this->assertSame([], $bundles[10]->getLoadAfter());
130+
$this->assertSame([ContaoCoreBundle::class], $bundles[10]->getLoadAfter());
132131

133-
$this->assertSame(ContaoManagerBundle::class, $bundles[11]->getName());
132+
$this->assertSame(DebugBundle::class, $bundles[11]->getName());
134133
$this->assertSame([], $bundles[11]->getReplace());
135-
$this->assertSame([ContaoCoreBundle::class], $bundles[11]->getLoadAfter());
134+
$this->assertSame([], $bundles[11]->getLoadAfter());
135+
$this->assertFalse($bundles[11]->loadInProduction());
136136

137-
$this->assertSame(DebugBundle::class, $bundles[12]->getName());
137+
$this->assertSame(WebProfilerBundle::class, $bundles[12]->getName());
138138
$this->assertSame([], $bundles[12]->getReplace());
139139
$this->assertSame([], $bundles[12]->getLoadAfter());
140140
$this->assertFalse($bundles[12]->loadInProduction());
141-
142-
$this->assertSame(WebProfilerBundle::class, $bundles[13]->getName());
143-
$this->assertSame([], $bundles[13]->getReplace());
144-
$this->assertSame([], $bundles[13]->getLoadAfter());
145-
$this->assertFalse($bundles[13]->loadInProduction());
146141
}
147142

148143
public function testRegistersModuleBundles(): void
@@ -167,7 +162,7 @@ static function ($resource): array {
167162
$plugin = new Plugin();
168163
$configs = $plugin->getBundles($parser);
169164

170-
$this->assertCount(16, $configs);
165+
$this->assertCount(15, $configs);
171166
$this->assertContains('foo1', $configs);
172167
$this->assertContains('foo2', $configs);
173168
$this->assertNotContains('foo3', $configs);

0 commit comments

Comments
 (0)