Problem/Motivation
Avoid writing invalid data to the fast backend.
Only relevant if/when someone calls getMultiple() with invalid == TRUE.
Marking issue NOVICE ONLY for creating a patch out of the below code.
Steps to reproduce
- Call getMultiple() with $allow_invalid = TRUE.
- See that fastBackend is happily setting invalid data, which will never be useful
Proposed resolution
<code>
diff --git a/web/core/lib/Drupal/Core/Cache/ChainedFastBackend.php b/web/core/lib/Drupal/Core/Cache/ChainedFastBackend.php
--- a/web/core/lib/Drupal/Core/Cache/ChainedFastBackend.php
+++ b/web/core/lib/Drupal/Core/Cache/ChainedFastBackend.php
@@ -166,7 +166,10 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) {
$cache[$item->cid] = $item;
// Don't write the cache tags to the fast backend as any cache tag
// invalidation results in an invalidation of the whole fast backend.
- $this->fastBackend->set($item->cid, $item->data, $item->expire);
+ if (!$allow_invalid || $item->valid) {
+ $this->fastBackend->set($item->cid, $item->data, $item->expire);
+ }
}
}
Remaining tasks
Review
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
N/A