function _block_get_cache_id

7.x block.module _block_get_cache_id($block)
6.x block.module _block_get_cache_id($block)

Assemble the cache_id to use for a given block.

The cache_id string reflects the viewing context for the current block instance, obtained by concatenating the relevant context information (user, page, ...) according to the block's cache settings (BLOCK_CACHE_* constants). Two block instances can use the same cached content when they share the same cache_id.

Theme and language contexts are automatically differentiated.

Parameters

$block:

Return value

The string used as cache_id for the block.

1 call to _block_get_cache_id()
_block_render_blocks in drupal-7.x/modules/block/block.module
Render the content and subject for a set of blocks.

File

drupal-7.x/modules/block/block.module, line 947
Controls the visual building blocks a page is constructed with.

Code

function _block_get_cache_id($block) {
  global $user;

  // User 1 being out of the regular 'roles define permissions' schema,
  // it brings too many chances of having unwanted output get in the cache
  // and later be served to other users. We therefore exclude user 1 from
  // block caching.
  if (variable_get('block_cache', FALSE) && !in_array($block->cache, array(DRUPAL_NO_CACHE, DRUPAL_CACHE_CUSTOM)) && $user->uid != 1) {
    // Start with common sub-patterns: block identification, theme, language.
    $cid_parts[] = $block->module;
    $cid_parts[] = $block->delta;
    $cid_parts = array_merge($cid_parts, drupal_render_cid_parts($block->cache));

    return implode(':', $cid_parts);
  }
}