diff options
author | David Rothstein <drothstein@gmail.com> | 2014-11-04 20:07:30 -0500 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2014-11-04 20:07:30 -0500 |
commit | 9559160204f1c4e72e145cf95d61bf61e4bd1fcf (patch) | |
tree | 7d90d37162f5694ea079122846bf4ed2ffb4b50b /modules/block | |
parent | d6c502926e1286e22771c58e01db386ba80d6480 (diff) | |
download | brdo-9559160204f1c4e72e145cf95d61bf61e4bd1fcf.tar.gz brdo-9559160204f1c4e72e145cf95d61bf61e4bd1fcf.tar.bz2 |
Issue #1930960 by pounard, iamEAP, pjcdawkins, msonnabaum, David_Rothstein: Fixed Block caching disable hardcoded on sites with hook_node_grant() causes serious performance troubles when not necessary.
Diffstat (limited to 'modules/block')
-rw-r--r-- | modules/block/block.module | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/modules/block/block.module b/modules/block/block.module index 2977ca88f..b6a733267 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -848,10 +848,19 @@ 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 + $cacheable = TRUE; + + // We 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'); + if ($_SERVER['REQUEST_METHOD'] != 'GET' && $_SERVER['REQUEST_METHOD'] != 'HEAD') { + $cacheable = FALSE; + } + // Block caching is not usually compatible with node access modules, so by + // default it is disabled when node access modules exist. However, it can be + // allowed by using the variable 'block_cache_bypass_node_grants'. + elseif (!variable_get('block_cache_bypass_node_grants', FALSE) && count(module_implements('node_grants'))) { + $cacheable = FALSE; + } // Proceed to loop over all blocks in order to compute their respective cache // identifiers; this allows us to do one single cache_get_multiple() call @@ -1054,7 +1063,7 @@ function block_menu_delete($menu) { * Implements hook_form_FORM_ID_alter(). */ function block_form_system_performance_settings_alter(&$form, &$form_state) { - $disabled = count(module_implements('node_grants')); + $disabled = (!variable_get('block_cache_bypass_node_grants', FALSE) && count(module_implements('node_grants'))); $form['caching']['block_cache'] = array( '#type' => 'checkbox', '#title' => t('Cache blocks'), |