bug #38126 [Cache] Limit cache version character range (lstrojny)
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
[Cache] Limit cache version character range
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | n.A.
| License | MIT
| Doc PR |
Follow up for https://github.com/symfony/symfony/pull/38108
With current HEAD in 4.4, this will fail eventually: `simple-phpunit --repeat 1000 --stop-on-failure --filter "testGetMultiple$" src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php`
After this PR it will no longer fail
@nicolas-grekas
Commits
-------
15c21db856
[Cache] Limit cache version character range
This commit is contained in:
commit
e8dc35dc2d
@ -182,7 +182,7 @@ abstract class AbstractCache implements Psr16CacheInterface, LoggerAwareInterfac
|
|||||||
try {
|
try {
|
||||||
foreach ($values as $id => $value) {
|
foreach ($values as $id => $value) {
|
||||||
if (!isset($keys[$id])) {
|
if (!isset($keys[$id])) {
|
||||||
$id = key($keys);
|
throw new InvalidArgumentException(sprintf('Could not match value id "%s" to keys "%s".', $id, implode('", "', $keys)));
|
||||||
}
|
}
|
||||||
$key = $keys[$id];
|
$key = $keys[$id];
|
||||||
unset($keys[$id]);
|
unset($keys[$id]);
|
||||||
|
@ -119,7 +119,7 @@ trait AbstractTrait
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$namespaceToClear = $this->namespace.$namespaceVersionToClear;
|
$namespaceToClear = $this->namespace.$namespaceVersionToClear;
|
||||||
$namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), static::NS_SEPARATOR, 5);
|
$namespaceVersion = strtr(substr_replace(base64_encode(pack('V', mt_rand())), static::NS_SEPARATOR, 5), '/', '_');
|
||||||
try {
|
try {
|
||||||
$cleared = $this->doSave([static::NS_SEPARATOR.$this->namespace => $namespaceVersion], 0);
|
$cleared = $this->doSave([static::NS_SEPARATOR.$this->namespace => $namespaceVersion], 0);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -268,7 +268,7 @@ trait AbstractTrait
|
|||||||
$this->namespaceVersion = $v;
|
$this->namespaceVersion = $v;
|
||||||
}
|
}
|
||||||
if ('1'.static::NS_SEPARATOR === $this->namespaceVersion) {
|
if ('1'.static::NS_SEPARATOR === $this->namespaceVersion) {
|
||||||
$this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), static::NS_SEPARATOR, 5);
|
$this->namespaceVersion = strtr(substr_replace(base64_encode(pack('V', time())), static::NS_SEPARATOR, 5), '/', '_');
|
||||||
$this->doSave([static::NS_SEPARATOR.$this->namespace => $this->namespaceVersion], 0);
|
$this->doSave([static::NS_SEPARATOR.$this->namespace => $this->namespaceVersion], 0);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
Reference in New Issue
Block a user