Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Revert "feature #27549 [Cache] Unconditionally use PhpFilesAdapter fo…
…r system pools (nicolas-grekas)"

This reverts commit d4f5d46, reversing
changes made to 7e3b7b0.
  • Loading branch information
nicolas-grekas committed Oct 10, 2018
commit dbc1230735a1ddbe1759e597d37aaddf31d0302c
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con

$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'])) {
Expand Down
9 changes: 4 additions & 5 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
<argument type="service" id="logger" on-invalid="ignore" />
</service>

<service id="cache.adapter.apcu" class="Symfony\Component\Cache\Adapter\ApcuAdapter" abstract="true">
Expand Down
26 changes: 7 additions & 19 deletions src/Symfony/Component/Cache/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,53 +94,41 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) {
}

/**
* 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
* @param string $directory
* @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);
}

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());
} elseif (null !== $logger) {
$apcu->setLogger($logger);
}

return new ChainAdapter(array($apcu, $fs));
return $apcu;
}

public static function createConnection($dsn, array $options = array())
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Cache/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down