Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -166,7 +166,7 @@ class ApcuBackend implements CacheBackendInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {
|
||||
Cache::validateTags($tags);
|
||||
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.');
|
||||
$tags = array_unique($tags);
|
||||
$cache = new \stdClass();
|
||||
$cache->cid = $cid;
|
||||
|
|
|
@ -34,7 +34,7 @@ class Cache {
|
|||
*/
|
||||
public static function mergeContexts(array $a = [], array $b = []) {
|
||||
$cache_contexts = array_unique(array_merge($a, $b));
|
||||
\Drupal::service('cache_contexts_manager')->validateTokens($cache_contexts);
|
||||
assert('\Drupal::service(\'cache_contexts_manager\')->assertValidTokens($cache_contexts)');
|
||||
sort($cache_contexts);
|
||||
return $cache_contexts;
|
||||
}
|
||||
|
@ -59,8 +59,9 @@ class Cache {
|
|||
* The merged array of cache tags.
|
||||
*/
|
||||
public static function mergeTags(array $a = [], array $b = []) {
|
||||
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($a) && \Drupal\Component\Assertion\Inspector::assertAllStrings($b)', 'Cache tags must be valid strings');
|
||||
|
||||
$cache_tags = array_unique(array_merge($a, $b));
|
||||
static::validateTags($cache_tags);
|
||||
sort($cache_tags);
|
||||
return $cache_tags;
|
||||
}
|
||||
|
@ -99,6 +100,9 @@ class Cache {
|
|||
* @param string[] $tags
|
||||
* An array of cache tags.
|
||||
*
|
||||
* @deprecated
|
||||
* Use assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)');
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public static function validateTags(array $tags) {
|
||||
|
|
|
@ -115,7 +115,7 @@ abstract class CacheCollector implements CacheCollectorInterface, DestructableIn
|
|||
* (optional) The tags to specify for the cache item.
|
||||
*/
|
||||
public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, array $tags = array()) {
|
||||
Cache::validateTags($tags);
|
||||
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.');
|
||||
$this->cid = $cid;
|
||||
$this->cache = $cache;
|
||||
$this->tags = $tags;
|
||||
|
|
|
@ -27,8 +27,7 @@ class CacheTagsInvalidator implements CacheTagsInvalidatorInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function invalidateTags(array $tags) {
|
||||
// Validate the tags.
|
||||
Cache::validateTags($tags);
|
||||
assert('Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.');
|
||||
|
||||
// Notify all added cache tags invalidators.
|
||||
foreach ($this->invalidators as $invalidator) {
|
||||
|
|
|
@ -103,11 +103,9 @@ class CacheContextsManager {
|
|||
* The ContextCacheKeys object containing the converted cache keys and
|
||||
* cacheability metadata.
|
||||
*
|
||||
* @throws \LogicException
|
||||
* Thrown if any of the context tokens or parameters are not valid.
|
||||
*/
|
||||
public function convertTokensToKeys(array $context_tokens) {
|
||||
$this->validateTokens($context_tokens);
|
||||
assert('$this->assertValidTokens($context_tokens)');
|
||||
$cacheable_metadata = new CacheableMetadata();
|
||||
$optimized_tokens = $this->optimizeTokens($context_tokens);
|
||||
// Iterate over cache contexts that have been optimized away and get their
|
||||
|
@ -299,4 +297,33 @@ class CacheContextsManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts the context tokens are valid
|
||||
*
|
||||
* Similar to ::validateTokens, this method returns boolean TRUE when the
|
||||
* context tokens are valid, and FALSE when they are not instead of returning
|
||||
* NULL when they are valid and throwing a \LogicException when they are not.
|
||||
* This function should be used with the assert() statement.
|
||||
*
|
||||
* @param mixed $context_tokens
|
||||
* Variable to be examined - should be array of context_tokens.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if context_tokens is an array of valid tokens.
|
||||
*/
|
||||
public function assertValidTokens($context_tokens) {
|
||||
if (!is_array($context_tokens)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->validateTokens($context_tokens);
|
||||
}
|
||||
catch (\LogicException $e) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ class DatabaseBackend implements CacheBackendInterface {
|
|||
'tags' => array(),
|
||||
);
|
||||
|
||||
Cache::validateTags($item['tags']);
|
||||
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($item[\'tags\'])', 'Cache Tags must be strings.');
|
||||
$item['tags'] = array_unique($item['tags']);
|
||||
// Sort the cache tags so that they are stored consistently in the DB.
|
||||
sort($item['tags']);
|
||||
|
|
|
@ -107,7 +107,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
|
|||
* Implements Drupal\Core\Cache\CacheBackendInterface::set().
|
||||
*/
|
||||
public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
|
||||
Cache::validateTags($tags);
|
||||
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.');
|
||||
$tags = array_unique($tags);
|
||||
// Sort the cache tags so that they are stored consistently in the database.
|
||||
sort($tags);
|
||||
|
|
|
@ -148,7 +148,7 @@ class PhpBackend implements CacheBackendInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
|
||||
Cache::validateTags($tags);
|
||||
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.');
|
||||
$item = (object) array(
|
||||
'cid' => $cid,
|
||||
'data' => $data,
|
||||
|
|
|
@ -33,6 +33,27 @@ trait RefinableCacheableDependencyTrait {
|
|||
*/
|
||||
protected $cacheMaxAge = Cache::PERMANENT;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheTags() {
|
||||
return $this->cacheTags;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheContexts() {
|
||||
return $this->cacheContexts;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheMaxAge() {
|
||||
return $this->cacheMaxAge;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
Reference in a new issue