Commit 95591602 authored by David_Rothstein's avatar David_Rothstein

Issue #1930960 by pounard, iamEAP, pjcdawkins, msonnabaum, David_Rothstein:...

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.
parent d6c50292
Drupal 7.33, xxxx-xx-xx (development version)
-----------------------
- Added a "block_cache_bypass_node_grants" variable to allow sites which have
node access modules enabled to use the block cache if desired (API addition).
- Made image derivative generation HTTP requests return a 404 error (rather
than a 500 error) when the source image does not exist.
- Fixed a bug which caused user pictures to be removed from the user object
......
......@@ -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'),
......
......@@ -434,6 +434,18 @@
# $conf['css_gzip_compression'] = FALSE;
# $conf['js_gzip_compression'] = FALSE;
/**
* Block caching:
*
* Block caching may not be compatible with node access modules depending on
* how the original block cache policy is defined by the module that provides
* the block. By default, Drupal therefore disables block caching when one or
* more modules implement hook_node_grants(). If you consider block caching to
* be safe on your site and want to bypass this restriction, uncomment the line
* below.
*/
# $conf['block_cache_bypass_node_grants'] = TRUE;
/**
* String overrides:
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment