Commit cc54a481 authored by alexpott's avatar alexpott

Issue #2453891 by Dragooon, Wim Leers: Renderer::getCacheableRenderArray() does not include max-age

parent c393119b
......@@ -754,6 +754,7 @@ public function getCacheableRenderArray(array $elements) {
'#cache' => [
'contexts' => $elements['#cache']['contexts'],
'tags' => $elements['#cache']['tags'],
'max-age' => $elements['#cache']['max-age'],
],
];
}
......
......@@ -10,6 +10,7 @@
use Drupal\Core\KeyValueStore\KeyValueMemoryFactory;
use Drupal\Core\Render\Element;
use Drupal\Core\State\State;
use Drupal\Core\Cache\Cache;
/**
* @coversDefaultClass \Drupal\Core\Render\Renderer
......@@ -114,6 +115,7 @@ public function providerTestContextBubblingEdgeCases() {
'#cache' => [
'contexts' => ['foo'],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
'#post_render_cache' => [],
'#markup' => 'parent',
......@@ -142,6 +144,7 @@ public function providerTestContextBubblingEdgeCases() {
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
'#post_render_cache' => [],
'#markup' => 'parent',
......@@ -165,6 +168,7 @@ public function providerTestContextBubblingEdgeCases() {
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
'#post_render_cache' => [],
'#markup' => '',
......@@ -196,6 +200,7 @@ public function providerTestContextBubblingEdgeCases() {
'child' => [
'#cache' => [
'contexts' => ['foo', 'baz'],
'max-age' => 3600,
],
],
];
......@@ -205,6 +210,7 @@ public function providerTestContextBubblingEdgeCases() {
'#cache' => [
'contexts' => ['bar', 'baz', 'foo'],
'tags' => [],
'max-age' => 3600,
],
'#post_render_cache' => [],
'#markup' => 'parent',
......@@ -251,6 +257,7 @@ public function providerTestContextBubblingEdgeCases() {
'#cache' => [
'contexts' => ['bar', 'foo'],
'tags' => ['dee', 'fiddle', 'har', 'yar'],
'max-age' => Cache::PERMANENT,
],
'#post_render_cache' => [],
'#markup' => 'parent',
......@@ -339,6 +346,7 @@ public function testConditionalCacheContextBubblingSelfHealing() {
'#cache' => [
'contexts' => ['user.roles'],
'tags' => ['a', 'b'],
'max-age' => Cache::PERMANENT,
],
'#post_render_cache' => [],
'#markup' => 'parent',
......@@ -362,6 +370,7 @@ public function testConditionalCacheContextBubblingSelfHealing() {
'#cache' => [
'contexts' => ['foo', 'user.roles'],
'tags' => ['a', 'b', 'c'],
'max-age' => Cache::PERMANENT,
],
'#post_render_cache' => [],
'#markup' => 'parent',
......@@ -393,6 +402,7 @@ public function testConditionalCacheContextBubblingSelfHealing() {
'#cache' => [
'contexts' => ['foo', 'user.roles'],
'tags' => ['a', 'b'],
'max-age' => Cache::PERMANENT,
],
'#post_render_cache' => [],
'#markup' => 'parent',
......@@ -417,6 +427,7 @@ public function testConditionalCacheContextBubblingSelfHealing() {
'#cache' => [
'contexts' => ['bar', 'foo', 'user.roles'],
'tags' => ['a', 'b', 'c', 'd'],
'max-age' => Cache::PERMANENT,
],
'#post_render_cache' => [],
'#markup' => 'parent',
......@@ -432,6 +443,7 @@ public function testConditionalCacheContextBubblingSelfHealing() {
'#cache' => [
'contexts' => ['bar', 'foo', 'user.roles'],
'tags' => ['a', 'b'],
'max-age' => Cache::PERMANENT,
],
'#post_render_cache' => [],
'#markup' => 'parent',
......@@ -447,6 +459,7 @@ public function testConditionalCacheContextBubblingSelfHealing() {
'#cache' => [
'contexts' => ['bar', 'foo', 'user.roles'],
'tags' => ['a', 'b', 'c'],
'max-age' => Cache::PERMANENT,
],
'#post_render_cache' => [],
'#markup' => 'parent',
......
......@@ -9,6 +9,7 @@
use Drupal\Component\Utility\Html;
use Drupal\Core\Render\Element;
use Drupal\Core\Cache\Cache;
/**
* @coversDefaultClass \Drupal\Core\Render\Renderer
......@@ -92,6 +93,7 @@ public function testPostRenderCacheWithColdCache() {
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
];
$this->assertSame($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
......@@ -228,6 +230,7 @@ public function testRenderChildrenPostRenderCacheDifferentContexts() {
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
];
......@@ -323,6 +326,7 @@ public function testRenderChildrenPostRenderCacheComplex() {
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
];
......@@ -349,6 +353,7 @@ public function testRenderChildrenPostRenderCacheComplex() {
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
];
......@@ -463,6 +468,7 @@ public function testPlaceholder() {
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
];
$this->assertSame($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
......@@ -561,6 +567,7 @@ public function testChildElementPlaceholder() {
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
];
$this->assertSame($cached_element, $expected_element, 'The correct data is cached for the child element: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
......@@ -589,6 +596,7 @@ public function testChildElementPlaceholder() {
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
];
$this->assertSame($cached_element, $expected_element, 'The correct data is cached for the parent element: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
......@@ -620,6 +628,7 @@ public function testChildElementPlaceholder() {
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => Cache::PERMANENT,
],
];
$this->assertSame($cached_element, $expected_element, 'The correct data is cached for the child element: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
......
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