Update to Drupal 8.0.0-rc3. For more information, see https://www.drupal.org/node/2608078

This commit is contained in:
Pantheon Automation 2015-11-04 11:11:27 -08:00 committed by Greg Anderson
parent 6419a031d7
commit 4afb23bbd3
762 changed files with 20080 additions and 6368 deletions

View file

@ -74,7 +74,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::get().
* {@inheritdoc}
*/
public function get($cid, $allow_invalid = FALSE) {
foreach ($this->backends as $index => $backend) {
@ -94,7 +94,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
* {@inheritdoc}
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
$return = array();
@ -125,7 +125,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::set().
* {@inheritdoc}
*/
public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
foreach ($this->backends as $backend) {
@ -143,7 +143,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::delete().
* {@inheritdoc}
*/
public function delete($cid) {
foreach ($this->backends as $backend) {
@ -152,7 +152,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().
* {@inheritdoc}
*/
public function deleteMultiple(array $cids) {
foreach ($this->backends as $backend) {
@ -161,7 +161,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::deleteAll().
* {@inheritdoc}
*/
public function deleteAll() {
foreach ($this->backends as $backend) {
@ -170,7 +170,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidate().
* {@inheritdoc}
*/
public function invalidate($cid) {
foreach ($this->backends as $backend) {
@ -179,7 +179,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().
* {@inheritdoc}
*/
public function invalidateMultiple(array $cids) {
foreach ($this->backends as $backend) {
@ -188,7 +188,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidateTags().
* {@inheritdoc}
*/
public function invalidateTags(array $tags) {
foreach ($this->backends as $backend) {
@ -199,7 +199,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidateAll().
* {@inheritdoc}
*/
public function invalidateAll() {
foreach ($this->backends as $backend) {
@ -208,7 +208,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::garbageCollection().
* {@inheritdoc}
*/
public function garbageCollection() {
foreach ($this->backends as $backend) {

View file

@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\Core\Cache\CacheableResponse.
* Contains \Drupal\Core\Cache\CacheableJsonResponse.
*/
namespace Drupal\Core\Cache;

View file

@ -61,7 +61,7 @@ class DatabaseBackend implements CacheBackendInterface {
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::get().
* {@inheritdoc}
*/
public function get($cid, $allow_invalid = FALSE) {
$cids = array($cid);
@ -70,7 +70,7 @@ class DatabaseBackend implements CacheBackendInterface {
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
* {@inheritdoc}
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
$cid_mapping = array();
@ -240,14 +240,14 @@ class DatabaseBackend implements CacheBackendInterface {
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::delete().
* {@inheritdoc}
*/
public function delete($cid) {
$this->deleteMultiple(array($cid));
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().
* {@inheritdoc}
*/
public function deleteMultiple(array $cids) {
$cids = array_values(array_map(array($this, 'normalizeCid'), $cids));
@ -270,7 +270,7 @@ class DatabaseBackend implements CacheBackendInterface {
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::deleteAll().
* {@inheritdoc}
*/
public function deleteAll() {
try {
@ -287,14 +287,14 @@ class DatabaseBackend implements CacheBackendInterface {
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidate().
* {@inheritdoc}
*/
public function invalidate($cid) {
$this->invalidateMultiple(array($cid));
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().
* {@inheritdoc}
*/
public function invalidateMultiple(array $cids) {
$cids = array_values(array_map(array($this, 'normalizeCid'), $cids));
@ -313,7 +313,7 @@ class DatabaseBackend implements CacheBackendInterface {
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidateAll().
* {@inheritdoc}
*/
public function invalidateAll() {
try {
@ -327,7 +327,7 @@ class DatabaseBackend implements CacheBackendInterface {
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::garbageCollection().
* {@inheritdoc}
*/
public function garbageCollection() {
try {

View file

@ -34,7 +34,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::get().
* {@inheritdoc}
*/
public function get($cid, $allow_invalid = FALSE) {
if (isset($this->cache[$cid])) {
@ -46,7 +46,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
* {@inheritdoc}
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
$ret = array();
@ -104,7 +104,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::set().
* {@inheritdoc}
*/
public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.');
@ -130,28 +130,28 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::delete().
* {@inheritdoc}
*/
public function delete($cid) {
unset($this->cache[$cid]);
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().
* {@inheritdoc}
*/
public function deleteMultiple(array $cids) {
$this->cache = array_diff_key($this->cache, array_flip($cids));
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::deleteAll().
* {@inheritdoc}
*/
public function deleteAll() {
$this->cache = array();
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidate().
* {@inheritdoc}
*/
public function invalidate($cid) {
if (isset($this->cache[$cid])) {
@ -160,7 +160,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().
* {@inheritdoc}
*/
public function invalidateMultiple(array $cids) {
foreach ($cids as $cid) {
@ -180,7 +180,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidateAll().
* {@inheritdoc}
*/
public function invalidateAll() {
foreach ($this->cache as $cid => $item) {
@ -189,7 +189,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::garbageCollection()
* {@inheritdoc}
*/
public function garbageCollection() {
}

View file

@ -26,7 +26,7 @@ class MemoryCounterBackend extends MemoryBackend {
protected $counter = array();
/**
* Implements \Drupal\Core\Cache\CacheBackendInterface::get().
* {@inheritdoc}
*/
public function get($cid, $allow_invalid = FALSE) {
$this->increaseCounter(__FUNCTION__, $cid);
@ -34,7 +34,7 @@ class MemoryCounterBackend extends MemoryBackend {
}
/**
* Implements \Drupal\Core\Cache\CacheBackendInterface::set().
* {@inheritdoc}
*/
public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
$this->increaseCounter(__FUNCTION__, $cid);
@ -42,7 +42,7 @@ class MemoryCounterBackend extends MemoryBackend {
}
/**
* Implements \Drupal\Core\Cache\CacheBackendInterface::delete().
* {@inheritdoc}
*/
public function delete($cid) {
$this->increaseCounter(__FUNCTION__, $cid);

View file

@ -31,21 +31,21 @@ class NullBackend implements CacheBackendInterface {
public function __construct($bin) {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::get().
* {@inheritdoc}
*/
public function get($cid, $allow_invalid = FALSE) {
return FALSE;
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
* {@inheritdoc}
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
return array();
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::set().
* {@inheritdoc}
*/
public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {}
@ -55,37 +55,37 @@ class NullBackend implements CacheBackendInterface {
public function setMultiple(array $items = array()) {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::delete().
* {@inheritdoc}
*/
public function delete($cid) {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().
* {@inheritdoc}
*/
public function deleteMultiple(array $cids) {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::deleteAll().
* {@inheritdoc}
*/
public function deleteAll() {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidate().
* {@inheritdoc}
*/
public function invalidate($cid) {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().
* {@inheritdoc}
*/
public function invalidateMultiple(array $cids) {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidateAll().
* {@inheritdoc}
*/
public function invalidateAll() {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::garbageCollection().
* {@inheritdoc}
*/
public function garbageCollection() {}

View file

@ -0,0 +1,80 @@
<?php
/**
* @file
* Contains \Drupal\Core\Cache\UseCacheBackendTrait.
*/
namespace Drupal\Core\Cache;
/**
* Provides methods to use a cache backend while respecting a 'use caches' flag.
*/
trait UseCacheBackendTrait {
/**
* Cache backend instance.
*
* @var \Drupal\Core\Cache\CacheBackendInterface
*/
protected $cacheBackend;
/**
* Flag whether caches should be used or skipped.
*
* @var bool
*/
protected $useCaches = TRUE;
/**
* Fetches from the cache backend, respecting the use caches flag.
*
* @param string $cid
* The cache ID of the data to retrieve.
*
* @return object|false
* The cache item or FALSE on failure.
*
* @see \Drupal\Core\Cache\CacheBackendInterface::get()
*/
protected function cacheGet($cid) {
if ($this->useCaches && $this->cacheBackend) {
return $this->cacheBackend->get($cid);
}
return FALSE;
}
/**
* Stores data in the persistent cache, respecting the use caches flag.
*
* @param string $cid
* The cache ID of the data to store.
* @param mixed $data
* The data to store in the cache.
* Some storage engines only allow objects up to a maximum of 1MB in size to
* be stored by default. When caching large arrays or similar, take care to
* ensure $data does not exceed this size.
* @param int $expire
* One of the following values:
* - CacheBackendInterface::CACHE_PERMANENT: Indicates that the item should
* not be removed unless it is deleted explicitly.
* - A Unix timestamp: Indicates that the item will be considered invalid
* after this time, i.e. it will not be returned by get() unless
* $allow_invalid has been set to TRUE. When the item has expired, it may
* be permanently deleted by the garbage collector at any time.
* @param array $tags
* An array of tags to be stored with the cache item. These should normally
* identify objects used to build the cache item, which should trigger
* cache invalidation when updated. For example if a cached item represents
* a node, both the node ID and the author's user ID might be passed in as
* tags. For example array('node' => array(123), 'user' => array(92)).
*
* @see \Drupal\Core\Cache\CacheBackendInterface::set()
*/
protected function cacheSet($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {
if ($this->cacheBackend && $this->useCaches) {
$this->cacheBackend->set($cid, $data, $expire, $tags);
}
}
}