From cf98566bbdf1649e12ff2a0fb929792ed9761eda Mon Sep 17 00:00:00 2001 From: Lorenz Schori Date: Mon, 21 Jan 2013 15:39:37 +0100 Subject: [PATCH 5/6] Fix blocks: cache contains render array, not markup. --- ajax/authcache.php | 24 +++++++++++++++--------- authcache.module | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ajax/authcache.php b/ajax/authcache.php index be4c1f8..42b98dd 100644 --- a/ajax/authcache.php +++ b/ajax/authcache.php @@ -285,12 +285,10 @@ function _authcache_blocks($blocks) { // Check cache_block bin first if ($block_cached = cache_get($block_cid, 'cache_block')) { - - if (variable_get('authcache_debug_all', FALSE)) { - $block_cached->data['content'] .= ''; - } - - $block_view = $block_cached->data; + $return[$block_id] = array( + 'subject' => check_plain($block_cached->data['subject']), + 'content' => render($block_cached->data['content']), + ); } else { // Full bootstrap required for correct theming. @@ -298,10 +296,18 @@ function _authcache_blocks($blocks) { drupal_theme_initialize(); $id = explode('-', $block_id, 2); - $block_view = module_invoke($id[0], 'block', 'view', $id[1]); - } - $return[$block_id] = $block_view; + $block = block_load($id[0], $id[1]); + $build = reset(_block_get_renderable_array(_block_render_blocks(array($block_id => $block)))); + if (!empty($build['#theme_wrappers'])) { + $build['#theme_wrappers'] = array_diff($build['#theme_wrappers'], array('block')); + } + + $return[$block_id] = array( + 'subject' => check_plain($build['#block']->subject), + 'content' => render($build), + ); + } } return $return; diff --git a/authcache.module b/authcache.module index 7e14190..81b0bde 100644 --- a/authcache.module +++ b/authcache.module @@ -613,7 +613,7 @@ function authcache_preprocess_block(&$variables) { $data[] = 'data-block-cid="' . _block_get_cache_id($block) . '"'; $variables['block']->subject = '' . $variables['block']->subject . ''; - $variables['block']->content = '
'; + $variables['content'] = '
'; } } } -- 1.7.10.4