Last active
July 23, 2018 17:39
-
-
Save amcgowanca/b5b50803ece57aed79208e4643beda7b to your computer and use it in GitHub Desktop.
Drupal 7: D8Cache patches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/includes/entity.inc b/includes/entity.inc | |
index 97c8957..518bc2b 100644 | |
--- a/includes/entity.inc | |
+++ b/includes/entity.inc | |
@@ -13,7 +13,7 @@ function d8cache_entity_view($entity, $entity_type, $view_mode, $langcode) { | |
if ($entity_type == 'node' && $view_mode != 'full') { | |
// @todo Find a better way to add list cache tags. | |
- $tags = array_merge($tags, _d8cache_entity_get_list_cache_tags($entity_type)); | |
+ $tags = array_merge($tags, _d8cache_entity_get_list_cache_tags($entity_type, $entity)); | |
} | |
$entity->content['#attached']['drupal_add_cache_tags'][][0] = $tags; | |
@@ -89,16 +89,19 @@ function d8cache_disable_cache_tags_for_entity_load($new_status = NULL) { | |
// Helper functions | |
function _d8cache_entity_invalidate_cache_tags($entity_type, $entity) { | |
- $tags = _d8cache_entity_get_list_cache_tags($entity_type); | |
+ $tags = _d8cache_entity_get_list_cache_tags($entity_type, $entity); | |
$tags = array_merge($tags, _d8cache_entity_get_cache_tags($entity_type, $entity)); | |
drupal_invalidate_cache_tags($tags); | |
} | |
-function _d8cache_entity_get_list_cache_tags($entity_type) { | |
- return array( | |
- $entity_type . '_list', | |
- ); | |
+function _d8cache_entity_get_list_cache_tags($entity_type, $entity = NULL) { | |
+ $return = array($entity_type . '_list'); | |
+ if (!empty($entity)) { | |
+ list(,, $entity_bundle) = entity_extract_ids($entity_type, $entity); | |
+ $return[] = $entity_type . '_' . $entity_bundle . '_list'; | |
+ } | |
+ return $return; | |
} | |
function _d8cache_entity_get_cache_tags($entity_type, $entity) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/d8cache-ac.cache.inc b/d8cache-ac.cache.inc | |
index 73d9705..aade805 100644 | |
--- a/d8cache-ac.cache.inc | |
+++ b/d8cache-ac.cache.inc | |
@@ -3,6 +3,10 @@ | |
require_once __DIR__ . '/d8cache.cache.inc'; | |
require_once __DIR__ . '/includes/core-attachments-collector.inc'; | |
+if (!function_exists('drupal_process_attached')) { | |
+ require_once DRUPAL_ROOT . '/includes/common.inc'; | |
+} | |
+ | |
/** | |
* Adds reset() and some properties to DrupalAttachmentsCollector(). | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment