summaryrefslogtreecommitdiff
path: root/modules/block
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2012-03-01 21:20:12 -0800
committerwebchick <webchick@24967.no-reply.drupal.org>2012-03-01 21:20:12 -0800
commitdf911f3f5081b258eda937c4791eb854fe2720be (patch)
tree6f6b316d9c04376417b05a7ca8343bd0bd203fac /modules/block
parent50fdcb190e0abe82b6465fe70fb3cc5dccf9345c (diff)
downloadbrdo-df911f3f5081b258eda937c4791eb854fe2720be.tar.gz
brdo-df911f3f5081b258eda937c4791eb854fe2720be.tar.bz2
Issue #917490 by pounard, msonnabaum: Performance patch for block_list() (D6) and _block_render_blocks() (D7) functions.
Diffstat (limited to 'modules/block')
-rw-r--r--modules/block/block.module11
1 files changed, 6 insertions, 5 deletions
diff --git a/modules/block/block.module b/modules/block/block.module
index 24319089e..94dee69c6 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -836,17 +836,18 @@ function block_block_list_alter(&$blocks) {
* An array of visible blocks as expected by drupal_render().
*/
function _block_render_blocks($region_blocks) {
+ // 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').
+ $cacheable = !count(module_implements('node_grants')) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD');
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.
+ if ($cacheable && ($cid = _block_get_cache_id($block)) && ($cache = cache_get($cid, 'cache_block'))) {
$array = $cache->data;
}
else {