//
// We can't reach that state right away, since we don't know what the
// result of future requests will be, but we can incrementally move
// towards that state by progressively merging the 'contexts' value
// across requests. That's the strategy employed below and tested in
// \Drupal\Tests\Core\Render\RendererBubblingTest::testConditionalCacheContextBubblingSelfHealing().
// Get the cacheability of this element according to the current (stored)
// redirecting cache item, if any.
$redirect_cacheability =
new CacheableMetadata();
if ($stored_cache_redirect =
$cache->
get($pre_bubbling_cid)) { $redirect_cacheability = CacheableMetadata::
createFromRenderArray($stored_cache_redirect->data
);
} // Calculate the union of the cacheability for this request and the
// current (stored) redirecting cache item. We need:
// - the union of cache contexts, because that is how we know which cache
// item to redirect to;
// - the union of cache tags, because that is how we know when the cache
// redirect cache item itself is invalidated;
// - the union of max ages, because that is how we know when the cache
// redirect cache item itself becomes stale. (Without this, we might end
// up toggling between a permanently and a briefly cacheable cache