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

Skip to content

Commit ec49aa1

Browse files
bug #29591 [Cache] Fix undefined variable in ArrayTrait (eXtreme)
This PR was merged into the 4.2 branch. Discussion ---------- [Cache] Fix undefined variable in ArrayTrait | 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 | After upgrading my project to 4.2 my tests failed with a message that `$key` variable is missing here: https://github.com/symfony/symfony/blob/e81285249b780a11ed209a79fa77c1f6ea6da67b/src/Symfony/Component/Cache/Traits/ArrayTrait.php#L131 which seems to be introduced with PR symfony/symfony#27563. So I added that variable to the trait and method calls (are there any other?). This is internal class so I guess noone is using it anywhere. Anyway, my tests pass with this fix. Commits ------- b0b5937d1d Fix undefined variable in cache ArrayTrait
2 parents 467a736 + 6b9c23c commit ec49aa1

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Adapter/ArrayAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function save(CacheItemInterface $item)
124124

125125
return true;
126126
}
127-
if ($this->storeSerialized && null === $value = $this->freeze($value)) {
127+
if ($this->storeSerialized && null === $value = $this->freeze($value, $key)) {
128128
return false;
129129
}
130130
if (null === $expiry && 0 < $item["\0*\0defaultLifetime"]) {

Simple/ArrayCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function setMultiple($values, $ttl = null)
129129
$expiry = 0 < $ttl ? microtime(true) + $ttl : PHP_INT_MAX;
130130

131131
foreach ($valuesArray as $key => $value) {
132-
if ($this->storeSerialized && null === $value = $this->freeze($value)) {
132+
if ($this->storeSerialized && null === $value = $this->freeze($value, $key)) {
133133
return false;
134134
}
135135
$this->values[$key] = $value;

Traits/ArrayTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private function generateItems(array $keys, $now, $f)
113113
}
114114
}
115115

116-
private function freeze($value)
116+
private function freeze($value, $key)
117117
{
118118
if (null === $value) {
119119
return 'N;';

0 commit comments

Comments
 (0)