bug #28805 Revert "feature #27549 [Cache] Unconditionally use PhpFilesAdapter for system pools" (nicolas-grekas)
This PR was merged into the 4.2-dev branch. Discussion ---------- Revert "feature #27549 [Cache] Unconditionally use PhpFilesAdapter for system pools" This reverts commitd4f5d46b13
, reversing changes made to7e3b7b0b50
. | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Reading #28800, I've just realized that #27549 breaks using system caches with read-only filesystem. Using ApcuAdapter makes system caches compatible with read-only filesystems. Note that this affects only non-warmed up pools, as the warmed-up ones use a faster `PhpArrayAdapter` in front. Commits -------dbc1230735
Revert "feature #27549 [Cache] Unconditionally use PhpFilesAdapter for system pools (nicolas-grekas)"
This commit is contained in:
commit
9a37ba4ab1
@ -1601,6 +1601,7 @@ class FrameworkExtension extends Extension
|
||||
|
||||
$version = new Parameter('container.build_id');
|
||||
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
|
||||
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
|
||||
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);
|
||||
|
||||
if (isset($config['prefix_seed'])) {
|
||||
|
@ -35,16 +35,15 @@
|
||||
<tag name="cache.pool" />
|
||||
</service>
|
||||
|
||||
<service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\PhpFilesAdapter" abstract="true">
|
||||
<service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\AdapterInterface" abstract="true">
|
||||
<factory class="Symfony\Component\Cache\Adapter\AbstractAdapter" method="createSystemCache" />
|
||||
<tag name="cache.pool" clearer="cache.system_clearer" />
|
||||
<tag name="monolog.logger" channel="cache" />
|
||||
<argument /> <!-- namespace -->
|
||||
<argument>0</argument> <!-- default lifetime -->
|
||||
<argument /> <!-- version -->
|
||||
<argument>%kernel.cache_dir%/pools</argument>
|
||||
<argument>true</argument>
|
||||
<call method="setLogger">
|
||||
<argument type="service" id="logger" on-invalid="ignore" />
|
||||
</call>
|
||||
</service>
|
||||
|
||||
<service id="cache.adapter.apcu" class="Symfony\Component\Cache\Adapter\ApcuAdapter" abstract="true">
|
||||
|
@ -94,6 +94,10 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise.
|
||||
*
|
||||
* Using ApcuAdapter makes system caches compatible with read-only filesystems.
|
||||
*
|
||||
* @param string $namespace
|
||||
* @param int $defaultLifetime
|
||||
* @param string $version
|
||||
@ -101,23 +105,15 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
||||
* @param LoggerInterface|null $logger
|
||||
*
|
||||
* @return AdapterInterface
|
||||
*
|
||||
* @deprecated since Symfony 4.2
|
||||
*/
|
||||
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
if (null === self::$apcuSupported) {
|
||||
self::$apcuSupported = ApcuAdapter::isSupported();
|
||||
}
|
||||
|
||||
if (!self::$apcuSupported && null === self::$phpFilesSupported) {
|
||||
self::$phpFilesSupported = PhpFilesAdapter::isSupported();
|
||||
}
|
||||
|
||||
if (self::$phpFilesSupported) {
|
||||
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory);
|
||||
if (!self::$apcuSupported) {
|
||||
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true);
|
||||
if (null !== $logger) {
|
||||
$opcache->setLogger($logger);
|
||||
}
|
||||
@ -125,14 +121,6 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
||||
return $opcache;
|
||||
}
|
||||
|
||||
$fs = new FilesystemAdapter($namespace, $defaultLifetime, $directory);
|
||||
if (null !== $logger) {
|
||||
$fs->setLogger($logger);
|
||||
}
|
||||
if (!self::$apcuSupported) {
|
||||
return $fs;
|
||||
}
|
||||
|
||||
$apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version);
|
||||
if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) {
|
||||
$apcu->setLogger(new NullLogger());
|
||||
@ -140,7 +128,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
||||
$apcu->setLogger($logger);
|
||||
}
|
||||
|
||||
return new ChainAdapter(array($apcu, $fs));
|
||||
return $apcu;
|
||||
}
|
||||
|
||||
public static function createConnection($dsn, array $options = array())
|
||||
|
@ -12,7 +12,6 @@ CHANGELOG
|
||||
* added automatic table creation when using Doctrine DBAL with PDO-based backends
|
||||
* throw `LogicException` when `CacheItem::tag()` is called on an item coming from a non tag-aware pool
|
||||
* deprecated `CacheItem::getPreviousTags()`, use `CacheItem::getMetadata()` instead
|
||||
* deprecated the `AbstractAdapter::createSystemCache()` method
|
||||
* deprecated the `AbstractAdapter::unserialize()` and `AbstractCache::unserialize()` methods
|
||||
* added `CacheCollectorPass` (originally in `FrameworkBundle`)
|
||||
* added `CachePoolClearerPass` (originally in `FrameworkBundle`)
|
||||
|
Reference in New Issue
Block a user