diff --git a/core/lib/Drupal/Core/Cache/BackendChain.php b/core/lib/Drupal/Core/Cache/BackendChain.php index 16136df..e8f6744 100644 --- a/core/lib/Drupal/Core/Cache/BackendChain.php +++ b/core/lib/Drupal/Core/Cache/BackendChain.php @@ -130,7 +130,7 @@ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANEN } /** - * Implements Drupal\Core\Cache\CacheBackendInterface::setMultiple(). + * Implements \Drupal\Core\Cache\CacheBackendInterface::setMultiple(). */ public function setMultiple(array $items) { foreach ($this->backends as $backend) { diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php index 59b62db..440de17 100644 --- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php @@ -163,7 +163,7 @@ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANEN * ); * @endcode */ - function setMultiple(array $items); + public function setMultiple(array $items); /** * Deletes an item from the cache. diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 98c47db..51a79b0 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -149,32 +149,31 @@ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANEN } /** - * Implements Drupal\Core\Cache\CacheBackendInterface::setMultiple(). + * Implements \Drupal\Core\Cache\CacheBackendInterface::setMultiple(). */ function setMultiple(array $items) { - try { - $this->deleteMultiple(array_keys($items)); - $query = Database::getConnection()->insert($this->bin)->fields(array('cid', 'data', 'expire', 'created', 'serialized', 'tags', 'checksum_invalidations', 'checksum_deletions')); - foreach ($items as $cid => $item) { - $flat_tags = $this->flattenTags(isset($item['tags']) ? $item['tags'] : array()); - $checksum = $this->checksumTags($flat_tags); - $fields = array( - 'cid' => $cid, - 'data' => is_string($item['data']) ? $item['data'] : serialize($item['data']), - 'expire' => isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, - 'created' => REQUEST_TIME, - 'serialized' => is_string($item['data']) ? 0 : 1, - 'tags' => implode(' ', $flat_tags), - 'checksum_invalidations' => $checksum['invalidations'], - 'checksum_deletions' => $checksum['deletions'], - ); - $query->values($fields); - } - $query->execute(); + $this->deleteMultiple(array_keys($items)); + $query = Database::getConnection()->insert($this->bin)->fields(array('cid', 'data', 'expire', 'created', 'serialized', 'tags', 'checksCum_invalidations', 'checksum_deletions')); + foreach ($items as $cid => $item) { + $item += array( + 'expire' => CacheBackendInterface::CACHE_PERMANENT, + 'tags' => array(), + ); + $flat_tags = $this->flattenTags($item['tags']); + $checksum = $this->checksumTags($flat_tags); + $fields = array( + 'cid' => $cid, + 'data' => is_string($item['data']) ? $item['data'] : serialize($item['data']), + 'expire' => $item['expire'], + 'created' => REQUEST_TIME, + 'serialized' => is_string($item['data']) ? 0 : 1, + 'tags' => implode(' ', $flat_tags), + 'checksum_invalidations' => $checksum['invalidations'], + 'checksum_deletions' => $checksum['deletions'], + ); + $query->values($fields); } - catch (Exception $e) { - // The database may not be available, so we'll ignore errors. - } + $query->execute(); } /** diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index 8cac1be..ac998fb 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -106,7 +106,7 @@ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANEN } /** - * Implements Drupal\Core\Cache\CacheBackendInterface::setMultiple(). + * Implements \Drupal\Core\Cache\CacheBackendInterface::setMultiple(). */ public function setMultiple(array $items = array()) { foreach ($items as $cid => $item) { diff --git a/core/lib/Drupal/Core/Cache/NullBackend.php b/core/lib/Drupal/Core/Cache/NullBackend.php index 392b7a4..98fa600 100644 --- a/core/lib/Drupal/Core/Cache/NullBackend.php +++ b/core/lib/Drupal/Core/Cache/NullBackend.php @@ -48,9 +48,9 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {} /** - * Implements Drupal\Core\Cache\CacheBackendInterface::setMultiple(). + * Implements \Drupal\Core\Cache\CacheBackendInterface::setMultiple(). */ - function setMultiple(array $items = array()) {} + public function setMultiple(array $items = array()) {} /** * Implements Drupal\Core\Cache\CacheBackendInterface::delete(). diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php index 4b9c45a..601782a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php @@ -299,7 +299,7 @@ public function testGetMultiple() { } /** - * Test Drupal\Core\Cache\CacheBackendInterface::setMultiple(). + * Tests \Drupal\Core\Cache\CacheBackendInterface::setMultiple(). */ public function testSetMultiple() { $backend = $this->getCacheBackend();