diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 7149004..0a7cc92 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1086,7 +1086,7 @@ function drupal_page_get_cache($check_only = FALSE) { } if (drupal_page_is_cacheable()) { - $cache = cache('page')->get($base_root . request_uri()); + $cache = cache('render')->get($base_root . request_uri()); if ($cache !== FALSE) { $cache_hit = TRUE; } diff --git a/core/includes/common.inc b/core/includes/common.inc index b3dc9cb..33f96e8 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -4982,7 +4982,7 @@ function drupal_page_set_cache($body) { if (config('system.performance')->get('response.gzip') && extension_loaded('zlib')) { $cache->data['body'] = gzencode($cache->data['body'], 9, FORCE_GZIP); } - cache('page')->set($cache->cid, $cache->data, $cache->expire, $cache->tags); + cache('render')->set($cache->cid, $cache->data, $cache->expire, $cache->tags); } return $cache; } diff --git a/core/includes/form.inc b/core/includes/form.inc index 5d6b32e..66c81f1 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -501,12 +501,12 @@ function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) { * Fetches a form from the cache. */ function form_get_cache($form_build_id, &$form_state) { - if ($cached = cache('form')->get('form_' . $form_build_id)) { + if ($cached = cache('path')->get('form_' . $form_build_id)) { $form = $cached->data; global $user; if ((isset($form['#cache_token']) && drupal_valid_token($form['#cache_token'])) || (!isset($form['#cache_token']) && !$user->uid)) { - if ($cached = cache('form')->get('form_state_' . $form_build_id)) { + if ($cached = cache('path')->get('form_state_' . $form_build_id)) { // Re-populate $form_state for subsequent rebuilds. $form_state = $cached->data + $form_state; @@ -540,12 +540,12 @@ function form_set_cache($form_build_id, $form, $form_state) { if ($GLOBALS['user']->uid) { $form['#cache_token'] = drupal_get_token(); } - cache('form')->set('form_' . $form_build_id, $form, REQUEST_TIME + $expire); + cache('path')->set('form_' . $form_build_id, $form, REQUEST_TIME + $expire); } // Cache form state. if ($data = array_diff_key($form_state, array_flip(form_state_keys_no_cache()))) { - cache('form')->set('form_state_' . $form_build_id, $data, REQUEST_TIME + $expire); + cache('path')->set('form_state_' . $form_build_id, $data, REQUEST_TIME + $expire); } } @@ -884,8 +884,8 @@ function drupal_process_form($form_id, &$form, &$form_state) { // here, though. $config = config('system.performance'); if (!$config->get('cache.page.enabled') && !empty($form_state['values']['form_build_id'])) { - cache('form')->delete('form_' . $form_state['values']['form_build_id']); - cache('form')->delete('form_state_' . $form_state['values']['form_build_id']); + cache('path')->delete('form_' . $form_state['values']['form_build_id']); + cache('path')->delete('form_state_' . $form_state['values']['form_build_id']); } // If batches were set in the submit handlers, we process them now, diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 70113b0..cf0d0b5 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1083,7 +1083,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) { if (!isset($tree[$cid])) { // If the static variable doesn't have the data, check {cache_menu}. - $cache = cache('menu')->get($cid); + $cache = cache('path')->get($cid); if ($cache && isset($cache->data)) { // If the cache entry exists, it contains the parameters for // menu_build_tree(). @@ -1110,7 +1110,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) { } // Cache the tree building parameters using the page-specific cid. - cache('menu')->set($cid, $tree_parameters, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name)); + cache('path')->set($cid, $tree_parameters, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name)); } // Build the tree using the parameters; the resulting tree will be cached @@ -1210,7 +1210,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = if (!isset($tree[$cid])) { // If the static variable doesn't have the data, check {cache_menu}. - $cache = cache('menu')->get($cid); + $cache = cache('path')->get($cid); if ($cache && isset($cache->data)) { // If the cache entry exists, it contains the parameters for // menu_build_tree(). @@ -1283,7 +1283,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = $tree_parameters['active_trail'] = $active_trail; } // Cache the tree building parameters using the page-specific cid. - cache('menu')->set($cid, $tree_parameters, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name)); + cache('path')->set($cid, $tree_parameters, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name)); } // Build the tree using the parameters; the resulting tree will be cached @@ -1352,7 +1352,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) { // If we do not have this tree in the static cache, check {cache_menu}. if (!isset($trees[$tree_cid])) { - $cache = cache('menu')->get($tree_cid); + $cache = cache('path')->get($tree_cid); if ($cache && isset($cache->data)) { $trees[$tree_cid] = $cache->data; } @@ -1420,7 +1420,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) { menu_tree_collect_node_links($data['tree'], $data['node_links']); // Cache the data, if it is not already in the cache. - cache('menu')->set($tree_cid, $data, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name)); + cache('path')->set($tree_cid, $data, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name)); $trees[$tree_cid] = $data; } @@ -2615,7 +2615,7 @@ function menu_link_load($mlid) { * Clears the cached cached data for a single named menu. */ function menu_cache_clear($menu_name = 'navigation') { - cache('menu')->invalidateTags(array('menu' => $menu_name)); + cache('path')->invalidateTags(array('menu' => $menu_name)); // Also clear the menu system static caches. menu_reset_static_cache(); } @@ -2627,7 +2627,7 @@ function menu_cache_clear($menu_name = 'navigation') { * might have been made to the router items or menu links. */ function menu_cache_clear_all() { - cache('menu')->flush(); + cache('path')->flush(); menu_reset_static_cache(); } diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php index 02c9dd2..ba72ea4 100644 --- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php @@ -18,9 +18,9 @@ * set a variable with the name of the cache bin as its key and the name of * your class as its value. For example, if your implementation of * Drupal\Core\Cache\CacheBackendInterface was called MyCustomCache, the - * following line would make Drupal use it for the 'cache_page' bin: + * following line would make Drupal use it for the 'cache_render' bin: * @code - * $conf['cache_classes']['cache_page'] = 'MyCustomCache'; + * $conf['cache_classes']['cache_render'] = 'MyCustomCache'; * @endcode * * Additionally, you can register your cache implementation to be used by diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index e62f1da..17624dd 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -150,9 +150,13 @@ function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, arra * Implements Drupal\Core\Cache\CacheBackendInterface::delete(). */ function delete($cid) { - Database::getConnection()->delete($this->bin) - ->condition('cid', $cid) - ->execute(); + try { + Database::getConnection()->delete($this->bin) + ->condition('cid', $cid) + ->execute(); + } catch (Exception $e) { + // The database may not be available, so we'll ignore delete requests. + } } /** @@ -172,7 +176,11 @@ function deleteMultiple(array $cids) { * Implements Drupal\Core\Cache\CacheBackendInterface::flush(). */ function flush() { - Database::getConnection()->truncate($this->bin)->execute(); + try { + Database::getConnection()->truncate($this->bin)->execute(); + } catch (Exception $e) { + // The database may not be available, so we'll ignore flush requests. + } } /** diff --git a/core/modules/block/block.install b/core/modules/block/block.install index ee72e0f..cfd8ac8 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -202,10 +202,6 @@ function block_schema() { ), 'primary key' => array('module', 'delta', 'type', 'langcode'), ); - - $schema['cache_block'] = drupal_get_schema_unprocessed('system', 'cache'); - $schema['cache_block']['description'] = 'Cache table for the Block module to store already built blocks, identified by module, delta, and various contexts which may change the block, such as theme, locale, and caching mode defined for the block.'; - return $schema; } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 2978146..d1a0973 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -373,7 +373,7 @@ function _block_get_renderable_region($list = array()) { '#cache' => array( 'keys' => array($block->module, $block->delta), 'granularity' => $block->cache, - 'bin' => 'block', + 'bin' => 'html', 'tags' => array('content' => TRUE), ), ); @@ -948,13 +948,6 @@ function _block_get_renderable_block($element) { } /** - * Implements hook_cache_flush(). - */ -function block_cache_flush() { - return array('block'); -} - -/** * Implements hook_rebuild(). */ function block_rebuild() { diff --git a/core/modules/book/book.module b/core/modules/book/book.module index fd4fac9..fae23d4 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -1404,12 +1404,12 @@ function book_menu_subtree_data($link) { $cid = 'links:' . $link['menu_name'] . ':subtree-cid:' . $link['mlid']; if (!isset($tree[$cid])) { - $cache = cache('menu')->get($cid); + $cache = cache('path')->get($cid); if ($cache && isset($cache->data)) { // If the cache entry exists, it will just be the cid for the actual data. // This avoids duplication of large amounts of data. - $cache = cache('menu')->get($cache->data); + $cache = cache('path')->get($cache->data); if ($cache && isset($cache->data)) { $data = $cache->data; @@ -1442,11 +1442,11 @@ function book_menu_subtree_data($link) { $tree_cid = 'links:' . $item['menu_name'] . ':subtree-data:' . hash('sha256', serialize($data)); // Cache the data, if it is not already in the cache. - if (!cache('menu')->get($tree_cid)) { - cache('menu')->set($tree_cid, $data); + if (!cache('path')->get($tree_cid)) { + cache('path')->set($tree_cid, $data); } // Cache the cid of the (shared) data using the menu and item-specific cid. - cache('menu')->set($cid, $tree_cid); + cache('path')->set($cid, $tree_cid); } // Check access for the current user to each item in the tree. menu_tree_check_access($data['tree'], $data['node_links']); diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 2278826..ed6c45c 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -765,7 +765,7 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $ foreach ($entities as $id => $entity) { $cids[] = "field:$entity_type:$id"; } - $cache = cache('field')->getMultiple($cids); + $cache = cache('entity')->getMultiple($cids); // Put the cached field values back into the entities and remove them from // the list of entities to query. foreach ($entities as $id => $entity) { @@ -841,7 +841,7 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $ $data[$instance['field_name']] = $queried_entities[$id]->{$instance['field_name']}; } $cid = "field:$entity_type:$id"; - cache('field')->set($cid, $data); + cache('entity')->set($cid, $data); } } } @@ -1105,7 +1105,7 @@ function field_attach_update($entity_type, EntityInterface $entity) { $entity_info = entity_get_info($entity_type); if ($entity_info['field cache']) { - cache('field')->delete("field:$entity_type:" . $entity->id()); + cache('entity')->delete("field:$entity_type:" . $entity->id()); } } @@ -1140,7 +1140,7 @@ function field_attach_delete($entity_type, $entity) { $entity_info = entity_get_info($entity_type); if ($entity_info['field cache']) { - cache('field')->delete("field:$entity_type:" . $entity->id()); + cache('entity')->delete("field:$entity_type:" . $entity->id()); } } diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc index 62bf171..b8a5f46 100644 --- a/core/modules/field/field.info.inc +++ b/core/modules/field/field.info.inc @@ -108,7 +108,7 @@ function _field_info_collate_types() { $langcode = $language_interface->langcode; if (!isset($info)) { - if ($cached = cache('field')->get("field_info_types:$langcode")) { + if ($cached = cache('entity')->get("field_info_types:$langcode")) { $info = $cached->data; } else { @@ -161,7 +161,7 @@ function _field_info_collate_types() { } drupal_alter('field_storage_info', $info['storage types']); - cache('field')->set("field_info_types:$langcode", $info, CacheBackendInterface::CACHE_PERMANENT, array('field_info_types' => TRUE)); + cache('entity')->set("field_info_types:$langcode", $info, CacheBackendInterface::CACHE_PERMANENT, array('field_info_types' => TRUE)); } } @@ -174,7 +174,7 @@ function _field_info_collate_types() { function _field_info_collate_types_reset() { drupal_static_reset('_field_info_collate_types'); // Clear all languages. - cache('field')->invalidateTags(array('field_info_types' => TRUE)); + cache('entity')->invalidateTags(array('field_info_types' => TRUE)); } /** diff --git a/core/modules/field/field.install b/core/modules/field/field.install index 24849e3..1c04d80 100644 --- a/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -161,7 +161,6 @@ function field_schema() { 'deleted' => array('deleted'), ), ); - $schema['cache_field'] = drupal_get_schema_unprocessed('system', 'cache'); return $schema; } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 1c3c4fb..f1621bd 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -467,14 +467,6 @@ function field_language_fallback(&$field_langcodes, $entity, $langcode) { } /** - * Implements hook_cache_flush(). - */ -function field_cache_flush() { - // Request a flush of our cache table. - return array('field'); -} - -/** * Implements hook_rebuild(). */ function field_rebuild() { @@ -856,7 +848,7 @@ function _field_extra_fields_pre_render($elements) { * Clears the field info and field data caches. */ function field_cache_clear() { - cache('field')->flush(); + //cache('entity')->flush(); field_info_cache_clear(); } diff --git a/core/modules/field/lib/Drupal/field/FieldInfo.php b/core/modules/field/lib/Drupal/field/FieldInfo.php index 02f3b12..13b4d64 100644 --- a/core/modules/field/lib/Drupal/field/FieldInfo.php +++ b/core/modules/field/lib/Drupal/field/FieldInfo.php @@ -112,7 +112,7 @@ public function flush() { $this->bundleExtraFields = array(); - cache('field')->invalidateTags(array('field_info' => TRUE)); + cache('entity')->invalidateTags(array('field_info' => TRUE)); } /** @@ -131,7 +131,7 @@ public function getFieldMap() { } // Read from persistent cache. - if ($cached = cache('field')->get('field_info:field_map')) { + if ($cached = cache('entity')->get('field_info:field_map')) { $map = $cached->data; // Save in "static" cache. @@ -157,7 +157,7 @@ public function getFieldMap() { // Save in "static" and persistent caches. $this->fieldMap = $map; - cache('field')->set('field_info:field_map', $map, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); + cache('entity')->set('field_info:field_map', $map, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); return $map; } @@ -175,7 +175,7 @@ public function getFields() { } // Read from persistent cache. - if ($cached = cache('field')->get('field_info:fields')) { + if ($cached = cache('entity')->get('field_info:fields')) { $this->fieldsById = $cached->data; } else { @@ -185,7 +185,7 @@ public function getFields() { } // Store in persistent cache. - cache('field')->set('field_info:fields', $this->fieldsById, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); + cache('entity')->set('field_info:fields', $this->fieldsById, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); } // Fill the name/ID map. @@ -219,7 +219,7 @@ public function getInstances($entity_type = NULL) { if (!$this->loadedAllInstances) { // Read from persistent cache. - if ($cached = cache('field')->get('field_info:instances')) { + if ($cached = cache('entity')->get('field_info:instances')) { $this->bundleInstances = $cached->data; } else { @@ -236,7 +236,7 @@ public function getInstances($entity_type = NULL) { } // Store in persistent cache. - cache('field')->set('field_info:instances', $this->bundleInstances, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); + cache('entity')->set('field_info:instances', $this->bundleInstances, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); } $this->loadedAllInstances = TRUE; @@ -353,7 +353,7 @@ public function getBundleInstances($entity_type, $bundle) { } // Read from the persistent cache. - if ($cached = cache('field')->get("field_info:bundle:$entity_type:$bundle")) { + if ($cached = cache('entity')->get("field_info:bundle:$entity_type:$bundle")) { $info = $cached->data; // Extract the field definitions and save them in the "static" cache. @@ -417,7 +417,7 @@ public function getBundleInstances($entity_type, $bundle) { foreach ($instances as $instance) { $cache['fields'][] = $this->fieldsById[$instance['field_id']]; } - cache('field')->set("field_info:bundle:$entity_type:$bundle", $cache, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); + cache('entity')->set("field_info:bundle:$entity_type:$bundle", $cache, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); return $instances; } @@ -440,7 +440,7 @@ public function getBundleExtraFields($entity_type, $bundle) { } // Read from the persistent cache. - if ($cached = cache('field')->get("field_info:bundle_extra:$entity_type:$bundle")) { + if ($cached = cache('entity')->get("field_info:bundle_extra:$entity_type:$bundle")) { $this->bundleExtraFields[$entity_type][$bundle] = $cached->data; return $this->bundleExtraFields[$entity_type][$bundle]; } @@ -458,7 +458,7 @@ public function getBundleExtraFields($entity_type, $bundle) { // Store in the 'static' and persistent caches. $this->bundleExtraFields[$entity_type][$bundle] = $info; - cache('field')->set("field_info:bundle_extra:$entity_type:$bundle", $info, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); + cache('entity')->set("field_info:bundle_extra:$entity_type:$bundle", $info, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); return $this->bundleExtraFields[$entity_type][$bundle]; } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php index 9bf4b2e..890b9a1 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php @@ -209,18 +209,18 @@ function testFieldAttachCache() { $cid = "field:$entity_type:{$entity_init->ftid}"; // Check that no initial cache entry is present. - $this->assertFalse(cache('field')->get($cid), 'Non-cached: no initial cache entry'); + $this->assertFalse(cache('entity')->get($cid), 'Non-cached: no initial cache entry'); // Save, and check that no cache entry is present. $entity = clone($entity_init); $entity->{$this->field_name}[$langcode] = $values; field_attach_insert($entity_type, $entity); - $this->assertFalse(cache('field')->get($cid), 'Non-cached: no cache entry on insert'); + $this->assertFalse(cache('entity')->get($cid), 'Non-cached: no cache entry on insert'); // Load, and check that no cache entry is present. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertFalse(cache('field')->get($cid), 'Non-cached: no cache entry on load'); + $this->assertFalse(cache('entity')->get($cid), 'Non-cached: no cache entry on load'); // Cacheable entity type. @@ -231,24 +231,24 @@ function testFieldAttachCache() { field_create_instance($instance); // Check that no initial cache entry is present. - $this->assertFalse(cache('field')->get($cid), 'Cached: no initial cache entry'); + $this->assertFalse(cache('entity')->get($cid), 'Cached: no initial cache entry'); // Save, and check that no cache entry is present. $entity = clone($entity_init); $entity->{$this->field_name}[$langcode] = $values; field_attach_insert($entity_type, $entity); - $this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on insert'); + $this->assertFalse(cache('entity')->get($cid), 'Cached: no cache entry on insert'); // Load a single field, and check that no cache entry is present. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity), FIELD_LOAD_CURRENT, array('field_id' => $this->field_id)); - $cache = cache('field')->get($cid); - $this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on loading a single field'); + $cache = cache('entity')->get($cid); + $this->assertFalse(cache('entity')->get($cid), 'Cached: no cache entry on loading a single field'); // Load, and check that a cache entry is present with the expected values. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $cache = cache('field')->get($cid); + $cache = cache('entity')->get($cid); $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); // Update with different values, and check that the cache entry is wiped. @@ -256,12 +256,12 @@ function testFieldAttachCache() { $entity = clone($entity_init); $entity->{$this->field_name}[$langcode] = $values; field_attach_update($entity_type, $entity); - $this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on update'); + $this->assertFalse(cache('entity')->get($cid), 'Cached: no cache entry on update'); // Load, and check that a cache entry is present with the expected values. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $cache = cache('field')->get($cid); + $cache = cache('entity')->get($cid); $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); // Create a new revision, and check that the cache entry is wiped. @@ -270,18 +270,18 @@ function testFieldAttachCache() { $entity = clone($entity_init); $entity->{$this->field_name}[$langcode] = $values; field_attach_update($entity_type, $entity); - $cache = cache('field')->get($cid); - $this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on new revision creation'); + $cache = cache('entity')->get($cid); + $this->assertFalse(cache('entity')->get($cid), 'Cached: no cache entry on new revision creation'); // Load, and check that a cache entry is present with the expected values. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $cache = cache('field')->get($cid); + $cache = cache('entity')->get($cid); $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); // Delete, and check that the cache entry is wiped. field_attach_delete($entity_type, $entity); - $this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry after delete'); + $this->assertFalse(cache('entity')->get($cid), 'Cached: no cache entry after delete'); } /** diff --git a/core/modules/filter/filter.api.php b/core/modules/filter/filter.api.php index f11a528..1a32b8c 100644 --- a/core/modules/filter/filter.api.php +++ b/core/modules/filter/filter.api.php @@ -194,9 +194,9 @@ function hook_filter_FILTER_settings($form, &$form_state, $filter, $format, $def * The language code of the text to be filtered. * @param $cache * A Boolean indicating whether the filtered text is going to be cached in - * {cache_filter}. + * {cache_render}. * @param $cache_id - * The ID of the filtered text in {cache_filter}, if $cache is TRUE. + * The ID of the filtered text in {cache_render}, if $cache is TRUE. * * @return * The prepared, escaped text. @@ -227,9 +227,9 @@ function hook_filter_FILTER_prepare($text, $filter, $format, $langcode, $cache, * The language code of the text to be filtered. * @param $cache * A Boolean indicating whether the filtered text is going to be cached in - * {cache_filter}. + * {cache_render}. * @param $cache_id - * The ID of the filtered text in {cache_filter}, if $cache is TRUE. + * The ID of the filtered text in {cache_render}, if $cache is TRUE. * * @return * The filtered text. diff --git a/core/modules/filter/filter.install b/core/modules/filter/filter.install index 9237ad1..303faba 100644 --- a/core/modules/filter/filter.install +++ b/core/modules/filter/filter.install @@ -104,10 +104,6 @@ function filter_schema() { 'status_weight' => array('status', 'weight'), ), ); - - $schema['cache_filter'] = drupal_get_schema_unprocessed('system', 'cache'); - $schema['cache_filter']['description'] = 'Cache table for the Filter module to store already filtered pieces of text, identified by text format and hash of the text.'; - return $schema; } diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 8b98bbe..988b6d1 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -8,13 +8,6 @@ use Drupal\Core\Template\Attribute; /** - * Implements hook_cache_flush(). - */ -function filter_cache_flush() { - return array('filter'); -} - -/** * Implements hook_help(). */ function filter_help($path, $arg) { @@ -286,7 +279,7 @@ function filter_format_save($format) { $return = SAVED_UPDATED; // Clear the filter cache whenever a text format is updated. - cache('filter')->invalidateTags(array('filter_format' => $format->format)); + cache('render')->invalidateTags(array('filter_format' => $format->format)); } filter_formats_reset(); @@ -316,7 +309,7 @@ function filter_format_disable($format) { // Clear the filter cache whenever a text format is disabled. filter_formats_reset(); - cache('filter')->invalidateTags(array('filter_format' => $format->format)); + cache('render')->invalidateTags(array('filter_format' => $format->format)); } /** @@ -753,7 +746,7 @@ function filter_list_format($format_id) { * English. This allows filters to be language aware so language specific * text replacement can be implemented. * @param $cache - * Boolean whether to cache the filtered output in the {cache_filter} table. + * Boolean whether to cache the filtered output in the {cache_render} table. * The caller may set this to FALSE when the output is already cached * elsewhere to avoid duplicate cache lookups and storage. * @@ -777,7 +770,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE) $cache_id = ''; if ($cache) { $cache_id = $format->format . ':' . $langcode . ':' . hash('sha256', $text); - if ($cached = cache('filter')->get($cache_id)) { + if ($cached = cache('render')->get($cache_id)) { return $cached->data; } } @@ -811,7 +804,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE) // automatically flushed when the text format is updated. // @see filter_format_save() if ($cache) { - cache('filter')->set($cache_id, $text, CacheBackendInterface::CACHE_PERMANENT, array('filter_format' => $format->format)); + cache('render')->set($cache_id, $text, CacheBackendInterface::CACHE_PERMANENT, array('filter_format' => $format->format)); } return $text; diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php index 21540da..42bd4f7 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php @@ -129,7 +129,7 @@ function testFilterAdmin() { $this->drupalPost('admin/config/content/formats/' . $filtered, $edit, t('Save configuration')); $this->assertFieldByName('filters[filter_html][settings][allowed_html]', $edit['filters[filter_html][settings][allowed_html]'], t('Allowed HTML tag added.')); - $result = db_query('SELECT * FROM {cache_filter}')->fetchObject(); + $result = db_query('SELECT * FROM {cache_render}')->fetchObject(); $this->assertFalse($result, t('Cache cleared.')); $elements = $this->xpath('//select[@name=:first]/following::select[@name=:second]', array( diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 01d2b3b..623c800 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -909,11 +909,7 @@ function image_style_flush($style) { field_info_cache_clear(); drupal_theme_rebuild(); - // Clear page caches when flushing. - if (module_exists('block')) { - cache('block')->flush(); - } - cache('page')->flush(); + cache('render')->flush(); } /** diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index b2bfa95..b0ea2f0 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -191,7 +191,7 @@ function locale_stream_wrappers() { function locale_language_insert($language) { // @todo move these two cache clears out. See http://drupal.org/node/1293252 // Changing the language settings impacts the interface. - cache('page')->flush(); + cache('render')->flush(); // Force JavaScript translation file re-creation for the new language. _locale_invalidate_js($language->langcode); } @@ -202,7 +202,7 @@ function locale_language_insert($language) { function locale_language_update($language) { // @todo move these two cache clears out. See http://drupal.org/node/1293252 // Changing the language settings impacts the interface. - cache('page')->flush(); + cache('render')->flush(); // Force JavaScript translation file re-creation for the modified language. _locale_invalidate_js($language->langcode); } @@ -221,7 +221,7 @@ function locale_language_delete($language) { _locale_invalidate_js($language->langcode); // Changing the language settings impacts the interface: - cache('page')->flush(); + cache('render')->flush(); // Clearing all locale cache from database cache()->delete('locale:' . $language->langcode); diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index cee4ba5..0a2d3af 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -234,12 +234,12 @@ function menu_load($menu_name) { function menu_load_all() { $custom_menus = &drupal_static(__FUNCTION__); if (!isset($custom_menus)) { - if ($cached = cache('menu')->get('menu_custom')) { + if ($cached = cache('path')->get('menu_custom')) { $custom_menus = $cached->data; } else { $custom_menus = db_query('SELECT * FROM {menu_custom}')->fetchAllAssoc('menu_name', PDO::FETCH_ASSOC); - cache('menu')->set('menu_custom', $custom_menus); + cache('path')->set('menu_custom', $custom_menus); } } return $custom_menus; diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookBootExitTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookBootExitTest.php index b90370c..1843420 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookBootExitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookBootExitTest.php @@ -53,13 +53,13 @@ function testHookBootExit() { // Boot and exit should not fire since the page is cached. variable_set('page_cache_invoke_hooks', FALSE); - $this->assertTrue(cache('page')->get(url('', array('absolute' => TRUE))), 'Page has been cached.'); + $this->assertTrue(cache('render')->get(url('', array('absolute' => TRUE))), 'Page has been cached.'); $this->drupalGet(''); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, 'hook_boot not called with aggressive cache and a cached page.'); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, 'hook_exit not called with aggressive cache and a cached page.'); // Test with page cache cleared, boot and exit should be called. - $this->assertTrue(db_delete('cache_page')->execute(), 'Page cache cleared.'); + $this->assertTrue(db_delete('cache_render')->execute(), 'Page cache cleared.'); $this->drupalGet(''); $calls++; $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, 'hook_boot called with aggressive cache and no cached page.'); 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 760d3ca..6b36a77 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php @@ -54,7 +54,7 @@ */ protected function getTestBin() { if (!isset($this->testBin)) { - $this->testBin = 'page'; + $this->testBin = 'render'; } return $this->testBin; } @@ -418,7 +418,7 @@ function testClearTags() { // Create cache entry in multiple bins. Two cache entries (test_cid_clear1 // and test_cid_clear2) still exist from previous tests. $tags = array('test_tag' => array(1, 2, 3)); - $bins = array('path', 'bootstrap', 'page'); + $bins = array('path', 'bootstrap', 'render'); foreach ($bins as $bin) { $this->getCacheBackend($bin)->set('test', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, $tags); $this->assertTrue($this->checkCacheExists('test', $bin), 'Cache item was set in bin.'); diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 8033ad0..ebc2d1f 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1706,7 +1706,7 @@ function system_clear_cache_submit($form, &$form_state) { * @ingroup forms */ function system_clear_page_cache_submit($form, &$form_state) { - cache('page')->flush(); + cache('render')->flush(); } /** diff --git a/core/modules/system/system.install b/core/modules/system/system.install index e138f32..3e12c9e 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -659,14 +659,12 @@ function system_schema() { $schema['cache_bootstrap']['description'] = 'Cache table for data required to bootstrap Drupal, may be routed to a shared memory cache.'; $schema['cache_config'] = $schema['cache']; $schema['cache_config']['description'] = 'Cache table for configuration data.'; - $schema['cache_form'] = $schema['cache']; - $schema['cache_form']['description'] = 'Cache table for the form system to store recently built forms and their storage data, to be used in subsequent page requests.'; - $schema['cache_page'] = $schema['cache']; - $schema['cache_page']['description'] = 'Cache table used to store compressed pages for anonymous users, if page caching is enabled.'; - $schema['cache_menu'] = $schema['cache']; - $schema['cache_menu']['description'] = 'Cache table for the menu system to store router information as well as generated link trees for various menu/page/user combinations.'; + $schema['cache_render'] = $schema['cache']; + $schema['cache_render']['description'] = 'Cache table to store rendered HTML strings.'; + $schema['cache_entity'] = $schema['cache']; + $schema['cache_entity']['description'] = 'Cache table for field and entity caches.'; $schema['cache_path'] = $schema['cache']; - $schema['cache_path']['description'] = 'Cache table for path alias lookup.'; + $schema['cache_path']['description'] = 'Cache table for path-specific (but not HTML strings) caches.'; $schema['date_format_type'] = array( 'description' => 'Stores configured date format types.', @@ -2132,6 +2130,19 @@ function system_update_8025() { } /** + * Add new generic cache bins. + */ +function system_update_8026() { + $schema['cache_render'] = drupal_get_schema_unprocessed('system', 'cache'); + $schema['cache_render']['description'] = 'Cache table to store rendered HTML strings.'; + $schema['cache_entity'] = drupal_get_schema_unprocessed('system', 'cache'); + $schema['cache_entity']['description'] = 'Cache table for field and entity caches.'; + foreach ($schema as $name => $definition) { + db_create_table($name, $definition); + } +} + +/** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. */ diff --git a/core/modules/system/system.module b/core/modules/system/system.module index bb3f2b4..d507208 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -3476,8 +3476,7 @@ function system_cron() { * Implements hook_cache_flush(). */ function system_cache_flush() { - // Do NOT flush the 'form' cache bin to retain in-progress form submissions. - return array('bootstrap', 'config', 'cache', 'page', 'path'); + return array('bootstrap', 'config', 'cache', 'render', 'entity', 'path'); } /**