Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amcgowanca/b5b50803ece57aed79208e4643beda7b to your computer and use it in GitHub Desktop.
Save amcgowanca/b5b50803ece57aed79208e4643beda7b to your computer and use it in GitHub Desktop.
Drupal 7: D8Cache patches
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) {
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().
*/
diff --git a/includes/entity.inc b/includes/entity.inc
index 97c8957..08490f1 100644
--- a/includes/entity.inc
+++ b/includes/entity.inc
@@ -74,7 +74,7 @@ function d8cache_entitycache_load($entities, $entity_type) {
/**
* Temporarily disable adding of cache tags during entity loading.
*/
-function d8cache_disable_cache_tags_for_entity_load($new_status = NULL) {
+function d8cache_disable_cache_tags_for_entity_load($new_state = NULL) {
$state = &drupal_static('d8cache_entity_load', FALSE);
$old_state = $state;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment