function mongodb_block_get_cache_id in MongoDB 7
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
object $block: The block object.
Return value
string The string used as cache_id for the block.
1 call to mongodb_block_get_cache_id()
- mongodb_block_render_blocks in mongodb_block/
mongodb_block.module - Render the content and subject for a set of blocks.
File
- mongodb_block/
mongodb_block.module, line 219 - Controls the visual building blocks a page is constructed with.
Code
function mongodb_block_get_cache_id($block) {
global $user;
// Not all block definitions define caching.
if (!isset($block->cache)) {
$block->cache = DRUPAL_NO_CACHE;
}
// 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', 0) && !in_array($block->cache, [
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);
}
}