summaryrefslogtreecommitdiff
path: root/modules/block
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2014-11-04 20:07:30 -0500
committerDavid Rothstein <drothstein@gmail.com>2014-11-04 20:07:30 -0500
commit9559160204f1c4e72e145cf95d61bf61e4bd1fcf (patch)
tree7d90d37162f5694ea079122846bf4ed2ffb4b50b /modules/block
parentd6c502926e1286e22771c58e01db386ba80d6480 (diff)
downloadbrdo-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.module17
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'),