Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.429 diff -u -p -r1.429 block.module --- modules/block/block.module 18 Sep 2010 02:18:35 -0000 1.429 +++ modules/block/block.module 21 Sep 2010 22:31:02 -0000 @@ -804,17 +804,25 @@ function block_block_list_alter(&$blocks * An array of visible blocks as expected by drupal_render(). */ function _block_render_blocks($region_blocks) { + // Keep cache enabled as a static variable because this method will be called + // for each region. + static $cache_enabled; + + // Block caching is not compatible with node_access modules. + if (!isset($cache_enabled)) { + $cache_enabled = &drupal_static(__FUNCTION__, !count(module_implements('node_grants'))); + } + foreach ($region_blocks as $key => $block) { // Render the block content if it has not been created already. if (!isset($block->content)) { // Erase the block from the static array - we'll put it back if it has // content. unset($region_blocks[$key]); - // Try fetching the block from cache. Block caching is not compatible - // with node_access modules. We also preserve the submission of forms in - // blocks, by fetching from cache only if the request method is 'GET' - // (or 'HEAD'). - if (!count(module_implements('node_grants')) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') && ($cid = _block_get_cache_id($block)) && ($cache = cache_get($cid, 'cache_block'))) { + // Try fetching the block from cache. We also preserve the submission of + // forms in blocks, by fetching from cache only if the request method is + // 'GET' (or 'HEAD'). + if ($cache_enabled && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') && ($cid = _block_get_cache_id($block)) && ($cache = cache_get($cid, 'cache_block'))) { $array = $cache->data; } else {