function _block_get_cache_id in Drupal 7
Same name and namespace in other branches
- 6 modules/block/block.module \_block_get_cache_id()
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: The block to get the cache_id from.
Return value
The string used as cache_id for the block.
1 call to _block_get_cache_id()
- _block_render_blocks in modules/
block/ block.module - Render the content and subject for a set of blocks.
File
- modules/
block/ block.module, line 966 - 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;
drupal_alter('block_cid_parts', $cid_parts, $block);
$cid_parts = array_merge($cid_parts, drupal_render_cid_parts($block->cache));
return implode(':', $cid_parts);
}
}