diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php index c360700..8613859 100644 --- a/core/lib/Drupal/Core/Cache/PhpBackend.php +++ b/core/lib/Drupal/Core/Cache/PhpBackend.php @@ -49,15 +49,14 @@ public function __construct($bin) { * {@inheritdoc} */ public function get($cid, $allow_invalid = FALSE) { - return $this->getByHash(Crypt::hashBase64($cid), $allow_invalid); + return $this->getByHash($this->normalizeCid($cid), $allow_invalid); } /** * Fetch a cache item using a hashed cache ID. * * @param string $cidhash - * The hashed version of the original cache ID after applying - * Crypt::hashBase64(). + * The hashed version of the original cache ID after being normalized. * @param bool $allow_invalid * (optional) If TRUE, a cache item may be returned even if it is expired or * has been invalidated. @@ -141,14 +140,14 @@ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array 'expire' => $expire, ); $item->tags = $this->flattenTags($tags); - $this->writeItem(Crypt::hashBase64($cid), $item); + $this->writeItem($this->normalizeCid($cid), $item); } /** * {@inheritdoc} */ public function delete($cid) { - $this->storage()->delete(Crypt::hashBase64($cid)); + $this->storage()->delete($this->normalizeCid($cid)); } /** @@ -184,15 +183,14 @@ public function deleteAll() { * {@inheritdoc} */ public function invalidate($cid) { - $this->invalidatebyHash(Crypt::hashBase64($cid)); + $this->invalidatebyHash($this->normalizeCid($cid)); } /** * Invalidate one cache item. * * @param string $cidhash - * The hashed version of the original cache ID after applying - * Crypt::hashBase64(). + * The hashed version of the original cache ID after being normalized. */ protected function invalidatebyHash($cidhash) { if ($item = $this->getByHash($cidhash)) { @@ -278,8 +276,7 @@ public function removeBin() { * Writes a cache item to PhpStorage. * * @param string $cidhash - * The hashed version of the original cache ID after applying - * Crypt::hashBase64(). + * The hashed version of the original cache ID after being normalized. * @param \stdClass $item * The cache item to store. */ @@ -300,4 +297,17 @@ protected function storage() { return $this->storage; } + /** + * Ensures a normalized cache ID. + * + * @param string $cid + * The passed in cache ID. + * + * @return string + * A normalized cache ID. + */ + protected function normalizeCid($cid) { + return Crypt::hashBase64($cid); + } + }