diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php index d7bdbdb..e5e9f64 100644 --- a/core/lib/Drupal/Core/Cache/ApcuBackend.php +++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php @@ -163,13 +163,12 @@ protected function prepareItem($cache, $allow_invalid) { } $cache->tags = $cache->tags ? explode(' ', $cache->tags) : array(); - $checksum = $this->cacheTagsStorage->checksumTags($cache->tags); // Check expire time. $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME; // Check if invalidateTags() has been called with any of the entry's tags. - if ($cache->checksum_invalidations != $checksum) { + if ($cache->checksum != $this->cacheTagsStorage->checksumTags($cache->tags)) { $cache->valid = FALSE; } @@ -185,18 +184,17 @@ protected function prepareItem($cache, $allow_invalid) { */ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) { if ($tags) { + $tags = array_unique($tags); Cache::validateTags($tags); $this->cacheTagsStorage->onCacheTagsWrite($tags); } - $tags = array_unique($tags); $cache = new \stdClass(); $cache->cid = $cid; $cache->created = round(microtime(TRUE), 3); $cache->expire = $expire; $cache->tags = implode(' ', $tags); - $checksum = $this->cacheTagsStorage->checksumTags($tags); - $cache->checksum_invalidations = $checksum; + $cache->checksum = $this->cacheTagsStorage->checksumTags($tags);; // APC serializes/unserializes any structure itself. $cache->serialized = 0; $cache->data = $data; diff --git a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php index 543d195..636ce77 100644 --- a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php +++ b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php @@ -55,8 +55,8 @@ public function addInvalidator(CacheTagsInvalidatorInterface $invalidator) { * Returns all cache bins that need to be notified about invalidations. * * @return \Drupal\Core\Cache\CacheTagsInvalidatorInterface[] - * An array of cache backend objects that implement the invalidator interface, - * keyed by their cache bin. + * An array of cache backend objects that implement the invalidator + * interface, keyed by their cache bin. */ protected function getInvalidatorCacheBins() { $bins = array(); diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 10445e4..5e90a75 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -86,7 +86,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { // ::select() is a much smaller proportion of the request. $result = array(); try { - $result = $this->connection->query('SELECT cid, data, created, expire, serialized, tags, checksum_invalidations FROM {' . $this->connection->escapeTable($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => array_keys($cid_mapping))); + $result = $this->connection->query('SELECT cid, data, created, expire, serialized, tags, checksum FROM {' . $this->connection->escapeTable($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => array_keys($cid_mapping))); } catch (\Exception $e) { // Nothing to do. @@ -126,13 +126,11 @@ protected function prepareItem($cache, $allow_invalid) { $cache->tags = $cache->tags ? explode(' ', $cache->tags) : array(); - $checksum = $this->cacheTagStorage->checksumTags($cache->tags); - // Check expire time. $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME; // Check if invalidateTags() has been called with any of the entry's tags. - if ($cache->checksum_invalidations != $checksum) { + if ($cache->checksum != $this->cacheTagStorage->checksumTags($cache->tags)) { $cache->valid = FALSE; } @@ -182,13 +180,11 @@ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array * Actually set the cache. */ protected function doSet($cid, $data, $expire, $tags) { - $checksum = $this->cacheTagStorage->checksumTags($tags); $fields = array( - 'serialized' => 0, 'created' => round(microtime(TRUE), 3), 'expire' => $expire, 'tags' => implode(' ', $tags), - 'checksum_invalidations' => $checksum, + 'checksum' => $this->cacheTagStorage->checksumTags($tags), ); if (!is_string($data)) { $fields['data'] = serialize($data); @@ -220,7 +216,7 @@ public function setMultiple(array $items) { $query = $this->connection ->insert($this->bin) - ->fields(array('cid', 'data', 'expire', 'created', 'serialized', 'tags', 'checksum_invalidations')); + ->fields(array('cid', 'data', 'expire', 'created', 'serialized', 'tags', 'checksum')); foreach ($items as $cid => $item) { $item += array( @@ -235,14 +231,13 @@ public function setMultiple(array $items) { sort($item['tags']); $this->cacheTagStorage->onCacheTagsWrite($item['tags']); } - $checksum = $this->cacheTagStorage->checksumTags($item['tags']); $fields = array( 'cid' => $cid, 'expire' => $item['expire'], 'created' => round(microtime(TRUE), 3), 'tags' => implode(' ', $item['tags']), - 'checksum_invalidations' => $checksum, + 'checksum' => $this->cacheTagStorage->checksumTags($item['tags']), ); if (!is_string($item['data'])) { @@ -491,7 +486,7 @@ public function schemaDefinition() { 'size' => 'big', 'not null' => FALSE, ), - 'checksum_invalidations' => array( + 'checksum' => array( 'description' => 'The tag invalidation sum when this entry was saved.', 'type' => 'int', 'not null' => TRUE, diff --git a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsStorage.php b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsStorage.php index db4363a..b8c0556 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsStorage.php +++ b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsStorage.php @@ -81,7 +81,7 @@ public function invalidateTags(array $tags) { * {@inheritdoc} */ public function checksumTags(array $tags) { - $invalidations = 0; + $checksum = 0; $query_tags = array_diff($tags, array_keys($this->tagCache)); if ($query_tags) { @@ -102,10 +102,10 @@ public function checksumTags(array $tags) { } foreach ($tags as $tag) { - $invalidations += $this->tagCache[$tag]; + $checksum += $this->tagCache[$tag]; } - return $invalidations; + return $checksum; } /** diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php index ce120b9..99e7598 100644 --- a/core/lib/Drupal/Core/Cache/PhpBackend.php +++ b/core/lib/Drupal/Core/Cache/PhpBackend.php @@ -133,8 +133,7 @@ protected function prepareItem($cache, $allow_invalid) { $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME; // Check if invalidateTags() has been called with any of the item's tags. - $checksum = $this->cacheTagsStorage->checksumTags($cache->tags); - if ($cache->checksum_invalidations != $checksum) { + if ($cache->checksum != $this->cacheTagsStorage->checksumTags($cache->tags)) { $cache->valid = FALSE; } @@ -150,6 +149,7 @@ protected function prepareItem($cache, $allow_invalid) { */ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { if ($tags) { + $tags = array_unique($tags); Cache::validateTags($tags); $this->cacheTagsStorage->onCacheTagsWrite($tags); } @@ -158,8 +158,8 @@ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array 'data' => $data, 'created' => round(microtime(TRUE), 3), 'expire' => $expire, - 'tags' => array_unique($tags), - 'checksum_invalidations' => $this->cacheTagsStorage->checksumTags($tags), + 'tags' => $tags, + 'checksum' => $this->cacheTagsStorage->checksumTags($tags), ); $this->writeItem($this->normalizeCid($cid), $item); } diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index a82f2ba..9ae0fc4 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -755,85 +755,4 @@ public function isDeletable() { return !$this->deleted && !$this->persist_with_no_fields && count($this->getBundles()) == 0; } - /** - * Creates a new data definition object. - * - * This method is typically used by - * \Drupal\Core\TypedData\TypedDataManager::createDataDefinition() to build a - * definition object for an arbitrary data type. When the definition class is - * known, it is recommended to directly use the static create() method on that - * class instead; e.g.: - * - * @code - * $map_definition = \Drupal\Core\TypedData\MapDataDefinition::create(); - * @endcode - * - * @param string $data_type - * The data type, for which a data definition should be created. - * - * @throws \InvalidArgumentException - * If an unsupported data type gets passed to the class; e.g., 'string' to a - * definition class handling 'entity:* data types. - * - * @return static - */ - public static function createFromDataType($data_type) { - // TODO: Implement createFromDataType() method. - } - - /** - * Returns the data type of the data. - * - * @return string - * The data type. - */ - public function getDataType() { - // TODO: Implement getDataType() method. - } - - /** - * Returns whether the data is multi-valued, i.e. a list of data items. - * - * This is equivalent to checking whether the data definition implements the - * \Drupal\Core\TypedData\ListDefinitionInterface interface. - * - * @return bool - * Whether the data is multi-valued. - */ - public function isList() { - // TODO: Implement isList() method. - } - - /** - * Determines whether the data is read-only. - * - * @return bool - * Whether the data is read-only. - */ - public function isReadOnly() { - // TODO: Implement isReadOnly() method. - } - - /** - * Determines whether the data value is computed. - * - * For example, data could be computed depending on some other values. - * - * @return bool - * Whether the data value is computed. - */ - public function isComputed() { - // TODO: Implement isComputed() method. - } - - /** - * Returns the class used for creating the typed data object. - * - * If not specified, the default class of the data type will be returned. - * - * @return string - * The class used for creating the typed data object. - */ - public function getClass() { - // TODO: Implement getClass() method. - }} +} diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php index 763836d..2a20fe5 100644 --- a/core/modules/system/core.api.php +++ b/core/modules/system/core.api.php @@ -495,7 +495,7 @@ * ); * \Drupal::cache()->set($cid, $data, CacheBackendInterface::CACHE_PERMANENT, $tags); * - * // nvalidate all cache items with certain tags. + * // Invalidate all cache items with certain tags. * \Drupal\Core\Cache\Cache::invalidateTags(array('user:1')); * @endcode * diff --git a/core/modules/system/src/Tests/Cache/ChainedFastBackendUnitTest.php b/core/modules/system/src/Tests/Cache/ChainedFastBackendUnitTest.php index 0cf3883..6b06d04 100644 --- a/core/modules/system/src/Tests/Cache/ChainedFastBackendUnitTest.php +++ b/core/modules/system/src/Tests/Cache/ChainedFastBackendUnitTest.php @@ -25,7 +25,7 @@ class ChainedFastBackendUnitTest extends GenericCacheBackendUnitTestBase { * A new ChainedFastBackend object. */ protected function createCacheBackend($bin) { - $consistent_backend = new DatabaseBackend($this->container->get('database'), \Drupal::service('cache_tags_storage'), $bin); + $consistent_backend = new DatabaseBackend(\Drupal::service('database'), \Drupal::service('cache_tags_storage'), $bin); $fast_backend = new PhpBackend($bin, \Drupal::service('cache_tags_storage')); return new ChainedFastBackend($consistent_backend, $fast_backend, $bin); } diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php index ffc5a27..e4fc1d7 100644 --- a/core/tests/Drupal/Tests/UnitTestCase.php +++ b/core/tests/Drupal/Tests/UnitTestCase.php @@ -198,18 +198,18 @@ public function getStringTranslationStub() { /** * Sets up a container with a cache tags invalidator. * - * @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_handler + * @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_validator * The cache tags invalidator. * * @return \Symfony\Component\DependencyInjection\ContainerInterface|\PHPUnit_Framework_MockObject_MockObject * The container with the cache tags invalidator service. */ - protected function getContainerWithCacheTagsInvalidator(CacheTagsInvalidatorInterface $cache_tags_handler) { + protected function getContainerWithCacheTagsInvalidator(CacheTagsInvalidatorInterface $cache_tags_validator) { $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container->expects($this->any()) ->method('get') ->with('cache_tags_invalidator') - ->will($this->returnValue($cache_tags_handler)); + ->will($this->returnValue($cache_tags_validator)); \Drupal::setContainer($container); return $container;