8000 Revert "feature #27549 [Cache] Unconditionally use PhpFilesAdapter fo… · symfony/symfony@dbc1230 · GitHub
[go: up one dir, main page]

Skip to content

Commit dbc1230

Browse files
Revert "feature #27549 [Cache] Unconditionally use PhpFilesAdapter for system pools (nicolas-grekas)"
This reverts commit d4f5d46, reversing changes made to 7e3b7b0.
1 parent 6de1577 commit dbc1230

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
16011601

16021602
$version = new Parameter('container.build_id');
16031603
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
1604+
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
16041605
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);
16051606

16061607
if (isset($config['prefix_seed'])) {

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,15 @@
3535
<tag name="cache.pool" />
3636
</service>
3737

38-
<service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\PhpFilesAdapter" abstract="true">
38+
<service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\AdapterInterface" abstract="true">
39+
<factory class="Symfony\Component\Cache\Adapter\AbstractAdapter" method="createSystemCache" />
3940
<tag name="cache.pool" clearer="cache.system_clearer" />
4041
<tag name="monolog.logger" channel="cache" />
4142
<argument /> <!-- namespace -->
4243
<argument>0</argument> <!-- default lifetime -->
44+
<argument /> <!-- version -->
4345
<argument>%kernel.cache_dir%/pools</argument>
44-
<argument>true</argument>
45-
<call method="setLogger">
46-
<argument type="service" id="logger" on-invalid="ignore" />
47-
</call>
46+
<argument type="service" id="logger" on-invalid="ignore" />
4847
</service>
4948

5049
<service id="cache.adapter.apcu" class="Symfony\Component\Cache\Adapter\ApcuAdapter" abstract="true">

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

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,53 +94,41 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) {
9494
}
9595

9696
/**
97+
* Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise.
98+
*
99+
* Using ApcuAdapter makes system caches compatible with read-only filesystems.
100+
*
97101
* @param string $namespace
98102
* @param int $defaultLifetime
99103
* @param string $version
100104
* @param string $directory
101105
* @param LoggerInterface|null $logger
102106
*
103107
* @return AdapterInterface
104-
*
105-
* @deprecated since Symfony 4.2
106108
*/
107109
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
108110
{
109-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
110-
111111
if (null === self::$apcuSupported) {
112112
self::$apcuSupported = ApcuAdapter::isSupported();
113113
}
114114

115-
if (!self::$apcuSupported && null === self::$phpFilesSupported) {
116-
self::$phpFilesSupported = PhpFilesAdapter::isSupported();
117-
}
118-
119-
if (self::$phpFilesSupported) {
120-
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory);
115+
if (!self::$apcuSupported) {
116+
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true);
121117
if (null !== $logger) {
122118
$opcache->setLogger($logger);
123119
}
124120

125121
return $opcache;
126122
}
127123

128-
$fs = new FilesystemAdapter($namespace, $defaultLifetime, $directory);
129-
if (null !== $logger) {
130-
$fs->setLogger($logger);
131-
}
132-
if (!self::$apcuSupported) {
133-
return $fs;
134-
}
135-
136124
$apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version);
137125
if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) {
138126
$apcu->setLogger(new NullLogger());
139127
} elseif (null !== $logger) {
140128
$apcu->setLogger($logger);
141129
}
142130

143-
return new ChainAdapter(array($apcu, $fs));
131+
return $apcu;
144132
}
145133

146134
public static function createConnection($dsn, array $options = array())

src/Symfony/Component/Cache/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ CHANGELOG
1212
* added automatic table creation when using Doctrine DBAL with PDO-based backends
1313
* throw `LogicException` when `CacheItem::tag()` is called on an item coming from a non tag-aware pool
1414
* deprecated `CacheItem::getPreviousTags()`, use `CacheItem::getMetadata()` instead
15-
* deprecated the `AbstractAdapter::createSystemCache()` method
1615
* deprecated the `AbstractAdapter::unserialize()` and `AbstractCache::unserialize()` methods
1716
* added `CacheCollectorPass` (originally in `FrameworkBundle`)
1817
* added `CachePoolClearerPass` (originally in `FrameworkBundle`)

0 commit comments

Comments
 (0)
0