diff --git a/core/includes/common.inc b/core/includes/common.inc index 8f60fe4..3748110 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -4306,6 +4306,12 @@ function drupal_render_cache_by_query($query, $function, $expire = CacheBackendI * @code * DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE * @endcode + * Carefully consider exactly what can cause the content of your block to + * change. If you choose too general a granularity then you could end up + * serving the wrong content, but if you are too specific then you could end + * up with a very large cache and low hit rate, which could actually reduce + * performance. In particular, DRUPAL_CACHE_PER_USER can be very + * resource-consuming on sites with many users. * * @return * An array of cache ID parts, always containing the active theme. If the @@ -4325,16 +4331,12 @@ function drupal_render_cid_parts($granularity = NULL) { } if (!empty($granularity)) { - // 'PER_ROLE' and 'PER_USER' are mutually exclusive. 'PER_USER' can be a - // resource drag for sites with many users, so when a module is being - // equivocal, we favor the less expensive 'PER_ROLE' pattern. if ($granularity & DRUPAL_CACHE_PER_ROLE) { $cid_parts[] = 'r.' . implode(',', $user->getRoles()); } - elseif ($granularity & DRUPAL_CACHE_PER_USER) { + if ($granularity & DRUPAL_CACHE_PER_USER) { $cid_parts[] = 'u.' . $user->id(); } - if ($granularity & DRUPAL_CACHE_PER_PAGE) { $cid_parts[] = $base_root . request_uri(); }