bug #30621 [Cache] Ensure key exists before checking array value (jrjohnson)

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

f8b4adef23 Ensure key exists before checking array value
This commit is contained in:
Fabien Potencier 2019-03-27 07:46:42 +01:00
commit fdb0490a16

View File

@ -133,7 +133,7 @@ trait PhpFilesTrait
*/
protected function doHave($id)
{
if ($this->appendOnly && $this->values[$id]) {
if ($this->appendOnly && isset($this->values[$id])) {
return true;
}