#651902: support ESI for cached renderable arrays. From: Damien Tournoud --- common.inc | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git includes/common.inc includes/common.inc index b4cb09a..e39a923 100644 --- includes/common.inc +++ includes/common.inc @@ -5075,14 +5075,15 @@ function drupal_render(&$elements) { $prefix = isset($elements['#prefix']) ? $elements['#prefix'] : ''; $suffix = isset($elements['#suffix']) ? $elements['#suffix'] : ''; + $output = $prefix . $elements['#children'] . $suffix; // Cache the processed element if #cache is set. if (isset($elements['#cache'])) { - drupal_render_cache_set($prefix . $elements['#children'] . $suffix, $elements); + drupal_render_cache_set($output, $elements); } $elements['#printed'] = TRUE; - return $prefix . $elements['#children'] . $suffix; + return $output; } /** @@ -5203,13 +5204,15 @@ function drupal_render_cache_get($elements) { * @param $elements * A renderable array. */ -function drupal_render_cache_set($markup, $elements) { +function drupal_render_cache_set(&$markup, $elements) { // Create the cache ID for the element. if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = drupal_render_cid_create($elements)) { return FALSE; } - $data['#markup'] = $markup; + // Cache implementations are allowed to modify the markup, to support + // edge-side replacement of the cached markup. + $data['#markup'] = &$markup; // Persist attached data associated with this element. if (isset($elements['#attached'])) { $data['#attached'] = $elements['#attached'];