Skip to content

Commit fce062a

Browse files
minor symfony#18792 [Cache] Rename nonce to version (nicolas-grekas)
This PR was submitted for the master branch but it was merged into the 3.1 branch instead (closes symfony#18792). Discussion ---------- [Cache] Rename nonce to version | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony-docs#6515 (comment) | License | MIT | Doc PR | - ping @javiereguiluz Commits ------- 0c8358b [Cache] Rename nonce to version
2 parents 7a4019b + 0c8358b commit fce062a

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,9 +1037,9 @@ private function registerPropertyInfoConfiguration(array $config, ContainerBuild
10371037

10381038
private function registerCacheConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
10391039
{
1040-
$nonce = substr(str_replace('/', '-', base64_encode(md5(uniqid(mt_rand(), true), true))), 0, -2);
1041-
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $nonce);
1042-
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $nonce);
1040+
$version = substr(str_replace('/', '-', base64_encode(md5(uniqid(mt_rand(), true), true))), 0, -2);
1041+
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
1042+
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
10431043
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);
10441044

10451045
foreach (array('doctrine', 'psr6', 'redis') as $name) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<tag name="monolog.logger" channel="cache" />
2929
<argument /> <!-- namespace -->
3030
<argument /> <!-- default lifetime -->
31-
<argument /> <!-- nonce -->
31+
<argument /> <!-- version -->
3232
<argument>%kernel.cache_dir%/pools</argument>
3333
<argument type="service" id="logger" on-invalid="ignore" />
3434
</service>
@@ -38,7 +38,7 @@
3838
<tag name="monolog.logger" channel="cache" />
3939
<argument /> <!-- namespace -->
4040
<argument /> <!-- default lifetime -->
41-
<argument /> <!-- nonce -->
41+
<argument /> <!-- version -->
4242
<call method="setLogger">
4343
<argument type="service" id="logger" on-invalid="ignore" />
4444
</call>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function ($deferred, $namespace, &$expiredIds) {
6868
);
6969
}
7070

71-
public static function createSystemCache($namespace, $defaultLifetime, $nonce, $directory, LoggerInterface $logger = null)
71+
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
7272
{
7373
$fs = new FilesystemAdapter($namespace, $defaultLifetime, $directory);
7474
if (null !== $logger) {
@@ -78,7 +78,7 @@ public static function createSystemCache($namespace, $defaultLifetime, $nonce, $
7878
return $fs;
7979
}
8080

81-
$apcu = new ApcuAdapter($namespace, $defaultLifetime / 5, $nonce);
81+
$apcu = new ApcuAdapter($namespace, $defaultLifetime / 5, $version);
8282
if (null !== $logger) {
8383
$apcu->setLogger($logger);
8484
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static function isSupported()
2424
return function_exists('apcu_fetch') && ini_get('apc.enabled') && !('cli' === PHP_SAPI && !ini_get('apc.enable_cli'));
2525
}
2626

27-
public function __construct($namespace = '', $defaultLifetime = 0, $nonce = null)
27+
public function __construct($namespace = '', $defaultLifetime = 0, $version = null)
2828
{
2929
if (!static::isSupported()) {
3030
throw new CacheException('APCu is not enabled');
@@ -34,12 +34,12 @@ public function __construct($namespace = '', $defaultLifetime = 0, $nonce = null
3434
}
3535
parent::__construct($namespace, $defaultLifetime);
3636

37-
if (null !== $nonce) {
38-
CacheItem::validateKey($nonce);
37+
if (null !== $version) {
38+
CacheItem::validateKey($version);
3939

40-
if (!apcu_exists($nonce.':nonce'.$namespace)) {
40+
if (!apcu_exists($version.':'.$namespace)) {
4141
$this->clear($namespace);
42-
apcu_add($nonce.':nonce'.$namespace, null);
42+
apcu_add($version.':'.$namespace, null);
4343
}
4444
}
4545
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testUnserializable()
4444
$this->assertFalse($item->isHit());
4545
}
4646

47-
public function testNonce()
47+
public function testVersion()
4848
{
4949
$namespace = str_replace('\\', '.', __CLASS__);
5050

0 commit comments

Comments
 (0)