From fe554d302f8d223977e69299d258f87c4cd04dda Mon Sep 17 00:00:00 2001 From: Neil Drumm Date: Thu, 17 Apr 2008 07:12:15 +0000 Subject: [PATCH] #232037 by pwolanin: (performance) block regions should only be populated when called for, not in all cases (fixes performance expectation on 403/404 pages) --- modules/block/block.module | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/modules/block/block.module b/modules/block/block.module index 175bd81d115..ab3dc2ebe1e 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -684,8 +684,23 @@ function block_list($region) { else { $page_match = TRUE; } + $block->enabled = $enabled; + $block->page_match = $page_match; + $blocks[$block->region]["{$block->module}_{$block->delta}"] = $block; + } + } - if ($enabled && $page_match) { + // Create an empty array if there were no entries + if (!isset($blocks[$region])) { + $blocks[$region] = array(); + } + + foreach ($blocks[$region] 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($blocks[$region][$key]); + if ($block->enabled && $block->page_match) { // Check the current throttle status and see if block should be displayed // based on server load. if (!($block->throttle && (module_invoke('throttle', 'status') > 0))) { @@ -707,9 +722,5 @@ function block_list($region) { } } } - // Create an empty array if there were no entries - if (!isset($blocks[$region])) { - $blocks[$region] = array(); - } return $blocks[$region]; }