Update to Drupal 8.0.2. For more information, see https://www.drupal.org/drupal-8.0.2-release-notes
This commit is contained in:
parent
1a0e9d9fac
commit
a6b049dd05
538 changed files with 5247 additions and 1594 deletions
26
core/lib/Drupal/Core/Cache/Apcu4Backend.php
Normal file
26
core/lib/Drupal/Core/Cache/Apcu4Backend.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Cache\Apcu4Backend.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Cache;
|
||||
|
||||
/**
|
||||
* Stores cache items in the Alternative PHP Cache User Cache (APCu).
|
||||
*
|
||||
* This class is used with APCu versions >= 4.0.0 and < 5.0.0.
|
||||
*/
|
||||
class Apcu4Backend extends ApcuBackend {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return \APCIterator
|
||||
*/
|
||||
protected function getIterator($search = NULL, $format = APC_ITER_ALL, $chunk_size = 100, $list = APC_LIST_ACTIVE) {
|
||||
return new \APCIterator('user', $search, $format, $chunk_size, $list);
|
||||
}
|
||||
|
||||
}
|
|
@ -60,7 +60,7 @@ class ApcuBackend implements CacheBackendInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Prepends the APC user variable prefix for this bin to a cache item ID.
|
||||
* Prepends the APCu user variable prefix for this bin to a cache item ID.
|
||||
*
|
||||
* @param string $cid
|
||||
* The cache item ID to prefix.
|
||||
|
@ -76,7 +76,7 @@ class ApcuBackend implements CacheBackendInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($cid, $allow_invalid = FALSE) {
|
||||
$cache = apc_fetch($this->getApcuKey($cid));
|
||||
$cache = apcu_fetch($this->getApcuKey($cid));
|
||||
return $this->prepareItem($cache, $allow_invalid);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ class ApcuBackend implements CacheBackendInterface {
|
|||
$map[$this->getApcuKey($cid)] = $cid;
|
||||
}
|
||||
|
||||
$result = apc_fetch(array_keys($map));
|
||||
$result = apcu_fetch(array_keys($map));
|
||||
$cache = array();
|
||||
if ($result) {
|
||||
foreach ($result as $key => $item) {
|
||||
|
@ -112,18 +112,18 @@ class ApcuBackend implements CacheBackendInterface {
|
|||
* APCu is a memory cache, shared across all server processes. To prevent
|
||||
* cache item clashes with other applications/installations, every cache item
|
||||
* is prefixed with a unique string for this site. Therefore, functions like
|
||||
* apc_clear_cache() cannot be used, and instead, a list of all cache items
|
||||
* apcu_clear_cache() cannot be used, and instead, a list of all cache items
|
||||
* belonging to this application need to be retrieved through this method
|
||||
* instead.
|
||||
*
|
||||
* @param string $prefix
|
||||
* (optional) A cache ID prefix to limit the result to.
|
||||
*
|
||||
* @return \APCIterator
|
||||
* An APCIterator containing matched items.
|
||||
* @return \APCUIterator
|
||||
* An APCUIterator containing matched items.
|
||||
*/
|
||||
protected function getAll($prefix = '') {
|
||||
return new \APCIterator('user', '/^' . preg_quote($this->getApcuKey($prefix), '/') . '/');
|
||||
return $this->getIterator('/^' . preg_quote($this->getApcuKey($prefix), '/') . '/');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,12 +174,12 @@ class ApcuBackend implements CacheBackendInterface {
|
|||
$cache->expire = $expire;
|
||||
$cache->tags = implode(' ', $tags);
|
||||
$cache->checksum = $this->checksumProvider->getCurrentChecksum($tags);
|
||||
// APC serializes/unserializes any structure itself.
|
||||
// APCu serializes/unserializes any structure itself.
|
||||
$cache->serialized = 0;
|
||||
$cache->data = $data;
|
||||
|
||||
// Expiration is handled by our own prepareItem(), not APCu.
|
||||
apc_store($this->getApcuKey($cid), $cache);
|
||||
apcu_store($this->getApcuKey($cid), $cache);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,35 +195,35 @@ class ApcuBackend implements CacheBackendInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($cid) {
|
||||
apc_delete($this->getApcuKey($cid));
|
||||
apcu_delete($this->getApcuKey($cid));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteMultiple(array $cids) {
|
||||
apc_delete(array_map(array($this, 'getApcuKey'), $cids));
|
||||
apcu_delete(array_map(array($this, 'getApcuKey'), $cids));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteAll() {
|
||||
apc_delete(new \APCIterator('user', '/^' . preg_quote($this->binPrefix, '/') . '/'));
|
||||
apcu_delete($this->getIterator('/^' . preg_quote($this->binPrefix, '/') . '/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function garbageCollection() {
|
||||
// APC performs garbage collection automatically.
|
||||
// APCu performs garbage collection automatically.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function removeBin() {
|
||||
apc_delete(new \APCIterator('user', '/^' . preg_quote($this->binPrefix, '/') . '/'));
|
||||
apcu_delete($this->getIterator('/^' . preg_quote($this->binPrefix, '/') . '/'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,4 +252,25 @@ class ApcuBackend implements CacheBackendInterface {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates and returns the APCUIterator class.
|
||||
*
|
||||
* @param mixed $search
|
||||
* A PCRE regular expression that matches against APC key names, either as a
|
||||
* string for a single regular expression, or as an array of regular
|
||||
* expressions. Or, optionally pass in NULL to skip the search.
|
||||
* @param int $format
|
||||
* The desired format, as configured with one or more of the APC_ITER_*
|
||||
* constants.
|
||||
* @param int $chunk_size
|
||||
* The chunk size. Must be a value greater than 0. The default value is 100.
|
||||
* @param int $list
|
||||
* The type to list. Either pass in APC_LIST_ACTIVE or APC_LIST_DELETED.
|
||||
*
|
||||
* @return \APCUIterator
|
||||
*/
|
||||
protected function getIterator($search = NULL, $format = APC_ITER_ALL, $chunk_size = 100, $list = APC_LIST_ACTIVE) {
|
||||
return new \APCUIterator($search, $format, $chunk_size, $list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,13 @@ class ApcuBackendFactory implements CacheFactoryInterface {
|
|||
*/
|
||||
protected $checksumProvider;
|
||||
|
||||
/**
|
||||
* The APCU backend class to use.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $backendClass;
|
||||
|
||||
/**
|
||||
* Constructs an ApcuBackendFactory object.
|
||||
*
|
||||
|
@ -38,6 +45,12 @@ class ApcuBackendFactory implements CacheFactoryInterface {
|
|||
public function __construct($root, $site_path, CacheTagsChecksumInterface $checksum_provider) {
|
||||
$this->sitePrefix = Settings::getApcuPrefix('apcu_backend', $root, $site_path);
|
||||
$this->checksumProvider = $checksum_provider;
|
||||
if (version_compare(phpversion('apcu'), '5.0.0', '>=')) {
|
||||
$this->backendClass = 'Drupal\Core\Cache\ApcuBackend';
|
||||
}
|
||||
else {
|
||||
$this->backendClass = 'Drupal\Core\Cache\Apcu4Backend';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,7 +63,7 @@ class ApcuBackendFactory implements CacheFactoryInterface {
|
|||
* The cache backend object for the specified cache bin.
|
||||
*/
|
||||
public function get($bin) {
|
||||
return new ApcuBackend($bin, $this->sitePrefix, $this->checksumProvider);
|
||||
return new $this->backendClass($bin, $this->sitePrefix, $this->checksumProvider);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use Drupal\Core\Site\Settings;
|
|||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
|
||||
class CacheFactory implements CacheFactoryInterface, ContainerAwareInterface {
|
||||
class CacheFactory implements CacheFactoryInterface, ContainerAwareInterface {
|
||||
|
||||
use ContainerAwareTrait;
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ interface CacheableResponseInterface {
|
|||
/**
|
||||
* Adds a dependency on an object: merges its cacheability metadata.
|
||||
*
|
||||
* E.g. when a response depends on some configuration, an entity, or an access
|
||||
* result, we must make sure their cacheability metadata is present on the
|
||||
* response. This method makes doing that simple.
|
||||
* For instance, when a response depends on some configuration, an entity, or
|
||||
* an access result, we must make sure their cacheability metadata is present
|
||||
* on the response. This method makes doing that simple.
|
||||
*
|
||||
* @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency
|
||||
* The dependency. If the object implements CacheableDependencyInterface,
|
||||
|
|
|
@ -53,7 +53,7 @@ class ChainedFastBackendFactory implements CacheFactoryInterface {
|
|||
}
|
||||
|
||||
// Default the fast backend to APCu if it's available.
|
||||
if (!isset($fast_service_name) && function_exists('apc_fetch')) {
|
||||
if (!isset($fast_service_name) && function_exists('apcu_fetch')) {
|
||||
$fast_service_name = 'cache.backend.apcu';
|
||||
}
|
||||
|
||||
|
|
|
@ -92,9 +92,10 @@ class CacheContextsManager {
|
|||
*
|
||||
* A cache context token is either:
|
||||
* - a cache context ID (if the service ID is 'cache_context.foo', then 'foo'
|
||||
* is a cache context ID), e.g. 'foo'
|
||||
* - a calculated cache context ID, followed by a double colon, followed by
|
||||
* the parameter for the calculated cache context, e.g. 'bar:some_parameter'
|
||||
* is a cache context ID); for example, 'foo'.
|
||||
* - a calculated cache context ID, followed by a colon, followed by
|
||||
* the parameter for the calculated cache context; for example,
|
||||
* 'bar:some_parameter'.
|
||||
*
|
||||
* @param string[] $context_tokens
|
||||
* An array of cache context tokens.
|
||||
|
@ -142,11 +143,12 @@ class CacheContextsManager {
|
|||
* If a cache context is being optimized away, it is able to set cacheable
|
||||
* metadata for itself which will be bubbled up.
|
||||
*
|
||||
* E.g. when caching per user ('user'), also caching per role ('user.roles')
|
||||
* is meaningless because "per role" is implied by "per user".
|
||||
* For example, when caching per user ('user'), also caching per role
|
||||
* ('user.roles') is meaningless because "per role" is implied by "per user".
|
||||
*
|
||||
* Examples — remember that the period indicates hierarchy and the colon can
|
||||
* be used to get a specific value of a calculated cache context:
|
||||
* In the following examples, remember that the period indicates hierarchy and
|
||||
* the colon can be used to get a specific value of a calculated cache
|
||||
* context:
|
||||
* - ['a', 'a.b'] -> ['a']
|
||||
* - ['a', 'a.b.c'] -> ['a']
|
||||
* - ['a.b', 'a.b.c'] -> ['a.b']
|
||||
|
|
Reference in a new issue