Skip to content

Commit

Permalink
bug #30621 [Cache] Ensure key exists before checking array value (jrj…
Browse files Browse the repository at this point in the history
…ohnson)

This PR was merged into the 4.2 branch.

Discussion
----------

[Cache] Ensure key exists before checking array value

| 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        |

Without this fix we're getting warnings like

```
PHP Notice:  Undefined index: %5BOUR-KEY%5D%5B1%5D in vendor/symfony/cache/Traits/PhpFilesTrait.php on line 136
```

when doing a `$cache->contains()` in some cases. I'm having a lot of trouble tracking down exactly when and where this error will happen and what changes in our app / cache cause it, but this fix seems benign enough that maybe it can be merged without that backstory.

Commits
-------

f8b4ade Ensure key exists before checking array value
  • Loading branch information
fabpot committed Mar 27, 2019
2 parents 438940f + f8b4ade commit fdb0490
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Traits/PhpFilesTrait.php
Expand Up @@ -133,7 +133,7 @@ protected function doFetch(array $ids)
*/
protected function doHave($id)
{
if ($this->appendOnly && $this->values[$id]) {
if ($this->appendOnly && isset($this->values[$id])) {
return true;
}

Expand Down

0 comments on commit fdb0490

Please sign in to comment.