@@ -848,10 +848,19 @@ function block_block_list_alter(&$blocks) {
848
848
* An array of visible blocks as expected by drupal_render().
849
849
*/
850
850
function _block_render_blocks($region_blocks) {
851
- // Block caching is not compatible with node access modules. We also
852
- // preserve the submission of forms in blocks, by fetching from cache only
851
+ $cacheable = TRUE;
852
+
853
+ // We preserve the submission of forms in blocks, by fetching from cache only
853
854
// if the request method is 'GET' (or 'HEAD').
854
- $cacheable = !count(module_implements('node_grants')) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD');
855
+ if ($_SERVER['REQUEST_METHOD'] != 'GET' && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
856
+ $cacheable = FALSE;
857
+ }
858
+ // Block caching is not usually compatible with node access modules, so by
859
+ // default it is disabled when node access modules exist. However, it can be
860
+ // allowed by using the variable 'block_cache_bypass_node_grants'.
861
+ elseif (!variable_get('block_cache_bypass_node_grants', FALSE) && count(module_implements('node_grants'))) {
862
+ $cacheable = FALSE;
863
+ }
855
864
856
865
// Proceed to loop over all blocks in order to compute their respective cache
857
866
// identifiers; this allows us to do one single cache_get_multiple() call
@@ -1054,7 +1063,7 @@ function block_menu_delete($menu) {
1054
1063
* Implements hook_form_FORM_ID_alter().
1055
1064
*/
1056
1065
function block_form_system_performance_settings_alter(&$form, &$form_state) {
1057
- $disabled = count(module_implements('node_grants'));
1066
+ $disabled = (!variable_get('block_cache_bypass_node_grants', FALSE) && count(module_implements('node_grants') ));
1058
1067
$form['caching']['block_cache'] = array(
1059
1068
'#type' => 'checkbox',
1060
1069
'#title' => t('Cache blocks'),
0 commit comments