Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -15,7 +15,7 @@ function page_cache_help($route_name, RouteMatchInterface $route_match) {
|
|||
switch ($route_name) {
|
||||
case 'help.page.page_cache':
|
||||
$output = '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Internal Page Cache module caches pages for anonymous users in the database. For more information, see the <a href=":pagecache-documentation">online documentation for the Internal Page Cache module</a>.', array(':pagecache-documentation' => 'https://www.drupal.org/documentation/modules/internal_page_cache')) . '</p>';
|
||||
$output .= '<p>' . t('The Internal Page Cache module caches pages for anonymous users in the database. For more information, see the <a href=":pagecache-documentation">online documentation for the Internal Page Cache module</a>.', [':pagecache-documentation' => 'https://www.drupal.org/documentation/modules/internal_page_cache']) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Speeding up your site') . '</dt>';
|
||||
|
@ -23,7 +23,7 @@ function page_cache_help($route_name, RouteMatchInterface $route_match) {
|
|||
$output .= '<dd>' . t('Pages are usually identical for all anonymous users, while they can be personalized for each authenticated user. This is why entire pages can be cached for anonymous users, whereas they will have to be rebuilt for every authenticated user.') . '</dd>';
|
||||
$output .= '<dd>' . t('To speed up your site for authenticated users, see the <a href=":dynamic_page_cache-help">Dynamic Page Cache module</a>.', [':dynamic_page_cache-help' => (\Drupal::moduleHandler()->moduleExists('dynamic_page_cache')) ? Url::fromRoute('help.page', ['name' => 'dynamic_page_cache'])->toString() : '#']) . '</p>';
|
||||
$output .= '<dt>' . t('Configuring the internal page cache') . '</dt>';
|
||||
$output .= '<dd>' . t('On the <a href=":cache-settings">Performance page</a>, you can configure how long browsers and proxies may cache pages; that setting is also respected by the Internal Page Cache module. There is no other configuration.', array(':cache-settings' => \Drupal::url('system.performance_settings'))) . '</dd>';
|
||||
$output .= '<dd>' . t('On the <a href=":cache-settings">Performance page</a>, you can configure how long browsers and proxies may cache pages; that setting is also respected by the Internal Page Cache module. There is no other configuration.', [':cache-settings' => \Drupal::url('system.performance_settings')]) . '</dd>';
|
||||
$output .= '</dl>';
|
||||
|
||||
return $output;
|
||||
|
|
|
@ -168,7 +168,7 @@ class PageCache implements HttpKernelInterface {
|
|||
// In the case of a 304 response, certain headers must be sent, and the
|
||||
// remaining may not (see RFC 2616, section 10.3.5).
|
||||
foreach (array_keys($response->headers->all()) as $name) {
|
||||
if (!in_array($name, array('content-location', 'expires', 'cache-control', 'vary'))) {
|
||||
if (!in_array($name, ['content-location', 'expires', 'cache-control', 'vary'])) {
|
||||
$response->headers->remove($name);
|
||||
}
|
||||
}
|
||||
|
@ -206,6 +206,26 @@ class PageCache implements HttpKernelInterface {
|
|||
/** @var \Symfony\Component\HttpFoundation\Response $response */
|
||||
$response = $this->httpKernel->handle($request, $type, $catch);
|
||||
|
||||
// Only set the 'X-Drupal-Cache' header if caching is allowed for this
|
||||
// response.
|
||||
if ($this->storeResponse($request, $response)) {
|
||||
$response->headers->set('X-Drupal-Cache', 'MISS');
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a response in the page cache.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* A request object.
|
||||
* @param \Symfony\Component\HttpFoundation\Response $response
|
||||
* A response object that should be stored in the page cache.
|
||||
*
|
||||
* @returns bool
|
||||
*/
|
||||
protected function storeResponse(Request $request, Response $response) {
|
||||
// Drupal's primary cache invalidation architecture is cache tags: any
|
||||
// response that varies by a configuration value or data in a content
|
||||
// entity should have cache tags, to allow for instant cache invalidation
|
||||
|
@ -228,7 +248,7 @@ class PageCache implements HttpKernelInterface {
|
|||
// so by replacing/extending this middleware service or adding another
|
||||
// one.
|
||||
if (!$response instanceof CacheableResponseInterface) {
|
||||
return $response;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Currently it is not possible to cache binary file or streamed responses:
|
||||
|
@ -236,12 +256,12 @@ class PageCache implements HttpKernelInterface {
|
|||
// Therefore exclude them, even for subclasses that implement
|
||||
// CacheableResponseInterface.
|
||||
if ($response instanceof BinaryFileResponse || $response instanceof StreamedResponse) {
|
||||
return $response;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Allow policy rules to further restrict which responses to cache.
|
||||
if ($this->responsePolicy->check($response, $request) === ResponsePolicyInterface::DENY) {
|
||||
return $response;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$request_time = $request->server->get('REQUEST_TIME');
|
||||
|
@ -273,10 +293,7 @@ class PageCache implements HttpKernelInterface {
|
|||
$this->set($request, $response, $expire, $tags);
|
||||
}
|
||||
|
||||
// Mark response as a cache miss.
|
||||
$response->headers->set('X-Drupal-Cache', 'MISS');
|
||||
|
||||
return $response;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -340,10 +357,10 @@ class PageCache implements HttpKernelInterface {
|
|||
* The cache ID for this request.
|
||||
*/
|
||||
protected function getCacheId(Request $request) {
|
||||
$cid_parts = array(
|
||||
$cid_parts = [
|
||||
$request->getUri(),
|
||||
$request->getRequestFormat(),
|
||||
);
|
||||
];
|
||||
return implode(':', $cid_parts);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
|
|||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\node\NodeInterface;
|
||||
|
||||
/**
|
||||
* Enables the page cache and tests its cache tags in various scenarios.
|
||||
|
@ -35,35 +36,35 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
|
|||
/**
|
||||
* Test that cache tags are properly bubbled up to the page level.
|
||||
*/
|
||||
function testPageCacheTags() {
|
||||
public function testPageCacheTags() {
|
||||
// Create two nodes.
|
||||
$author_1 = $this->drupalCreateUser();
|
||||
$node_1 = $this->drupalCreateNode(array(
|
||||
$node_1 = $this->drupalCreateNode([
|
||||
'uid' => $author_1->id(),
|
||||
'title' => 'Node 1',
|
||||
'body' => array(
|
||||
0 => array('value' => 'Body 1', 'format' => 'basic_html'),
|
||||
),
|
||||
'promote' => NODE_PROMOTED,
|
||||
));
|
||||
'body' => [
|
||||
0 => ['value' => 'Body 1', 'format' => 'basic_html'],
|
||||
],
|
||||
'promote' => NodeInterface::PROMOTED,
|
||||
]);
|
||||
$author_2 = $this->drupalCreateUser();
|
||||
$node_2 = $this->drupalCreateNode(array(
|
||||
$node_2 = $this->drupalCreateNode([
|
||||
'uid' => $author_2->id(),
|
||||
'title' => 'Node 2',
|
||||
'body' => array(
|
||||
0 => array('value' => 'Body 2', 'format' => 'full_html'),
|
||||
),
|
||||
'promote' => NODE_PROMOTED,
|
||||
));
|
||||
'body' => [
|
||||
0 => ['value' => 'Body 2', 'format' => 'full_html'],
|
||||
],
|
||||
'promote' => NodeInterface::PROMOTED,
|
||||
]);
|
||||
|
||||
// Place a block, but only make it visible on full node page 2.
|
||||
$block = $this->drupalPlaceBlock('views_block:comments_recent-block_1', array(
|
||||
'visibility' => array(
|
||||
'request_path' => array(
|
||||
$block = $this->drupalPlaceBlock('views_block:comments_recent-block_1', [
|
||||
'visibility' => [
|
||||
'request_path' => [
|
||||
'pages' => '/node/' . $node_2->id(),
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$cache_contexts = [
|
||||
'languages:' . LanguageInterface::TYPE_INTERFACE,
|
||||
|
@ -78,7 +79,8 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
|
|||
];
|
||||
|
||||
// Full node page 1.
|
||||
$this->assertPageCacheContextsAndTags($node_1->urlInfo(), $cache_contexts, array(
|
||||
$this->assertPageCacheContextsAndTags($node_1->urlInfo(), $cache_contexts, [
|
||||
'http_response',
|
||||
'rendered',
|
||||
'block_view',
|
||||
'config:block_list',
|
||||
|
@ -112,13 +114,14 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
|
|||
// FinishResponseSubscriber adds this cache tag to responses that have the
|
||||
// 'user.permissions' cache context for anonymous users.
|
||||
'config:user.role.anonymous',
|
||||
));
|
||||
]);
|
||||
|
||||
// Render the view block adds the languages cache context.
|
||||
$cache_contexts[] = 'languages:' . LanguageInterface::TYPE_CONTENT;
|
||||
|
||||
// Full node page 2.
|
||||
$this->assertPageCacheContextsAndTags($node_2->urlInfo(), $cache_contexts, array(
|
||||
$this->assertPageCacheContextsAndTags($node_2->urlInfo(), $cache_contexts, [
|
||||
'http_response',
|
||||
'rendered',
|
||||
'block_view',
|
||||
'config:block_list',
|
||||
|
@ -155,7 +158,7 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
|
|||
// 'user.permissions' cache context for anonymous users.
|
||||
'config:user.role.anonymous',
|
||||
'user:0',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class PageCacheTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('test_page_test', 'system_test', 'entity_test');
|
||||
public static $modules = ['test_page_test', 'system_test', 'entity_test'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -44,29 +44,30 @@ class PageCacheTest extends WebTestBase {
|
|||
* Since tag based invalidation works, we know that our tag properly
|
||||
* persisted.
|
||||
*/
|
||||
function testPageCacheTags() {
|
||||
public function testPageCacheTags() {
|
||||
$config = $this->config('system.performance');
|
||||
$config->set('cache.page.max_age', 300);
|
||||
$config->save();
|
||||
|
||||
$path = 'system-test/cache_tags_page';
|
||||
$tags = array('system_test_cache_tags_page');
|
||||
$tags = ['system_test_cache_tags_page'];
|
||||
$this->drupalGet($path);
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
|
||||
|
||||
// Verify a cache hit, but also the presence of the correct cache tags.
|
||||
$this->drupalGet($path);
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
|
||||
$cid_parts = array(\Drupal::url('system_test.cache_tags_page', array(), array('absolute' => TRUE)), 'html');
|
||||
$cid_parts = [\Drupal::url('system_test.cache_tags_page', [], ['absolute' => TRUE]), 'html'];
|
||||
$cid = implode(':', $cid_parts);
|
||||
$cache_entry = \Drupal::cache('render')->get($cid);
|
||||
sort($cache_entry->tags);
|
||||
$expected_tags = array(
|
||||
$expected_tags = [
|
||||
'config:user.role.anonymous',
|
||||
'http_response',
|
||||
'pre_render',
|
||||
'rendered',
|
||||
'system_test_cache_tags_page',
|
||||
);
|
||||
];
|
||||
$this->assertIdentical($cache_entry->tags, $expected_tags);
|
||||
|
||||
Cache::invalidateTags($tags);
|
||||
|
@ -77,27 +78,28 @@ class PageCacheTest extends WebTestBase {
|
|||
/**
|
||||
* Test that the page cache doesn't depend on cacheability headers.
|
||||
*/
|
||||
function testPageCacheTagsIndependentFromCacheabilityHeaders() {
|
||||
public function testPageCacheTagsIndependentFromCacheabilityHeaders() {
|
||||
$this->setHttpResponseDebugCacheabilityHeaders(FALSE);
|
||||
|
||||
$path = 'system-test/cache_tags_page';
|
||||
$tags = array('system_test_cache_tags_page');
|
||||
$tags = ['system_test_cache_tags_page'];
|
||||
$this->drupalGet($path);
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
|
||||
|
||||
// Verify a cache hit, but also the presence of the correct cache tags.
|
||||
$this->drupalGet($path);
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
|
||||
$cid_parts = array(\Drupal::url('system_test.cache_tags_page', array(), array('absolute' => TRUE)), 'html');
|
||||
$cid_parts = [\Drupal::url('system_test.cache_tags_page', [], ['absolute' => TRUE]), 'html'];
|
||||
$cid = implode(':', $cid_parts);
|
||||
$cache_entry = \Drupal::cache('render')->get($cid);
|
||||
sort($cache_entry->tags);
|
||||
$expected_tags = array(
|
||||
$expected_tags = [
|
||||
'config:user.role.anonymous',
|
||||
'http_response',
|
||||
'pre_render',
|
||||
'rendered',
|
||||
'system_test_cache_tags_page',
|
||||
);
|
||||
];
|
||||
$this->assertIdentical($cache_entry->tags, $expected_tags);
|
||||
|
||||
Cache::invalidateTags($tags);
|
||||
|
@ -109,7 +111,7 @@ class PageCacheTest extends WebTestBase {
|
|||
* Tests support for different cache items with different request formats
|
||||
* specified via a query parameter.
|
||||
*/
|
||||
function testQueryParameterFormatRequests() {
|
||||
public function testQueryParameterFormatRequests() {
|
||||
$config = $this->config('system.performance');
|
||||
$config->set('cache.page.max_age', 300);
|
||||
$config->save();
|
||||
|
@ -173,7 +175,7 @@ class PageCacheTest extends WebTestBase {
|
|||
/**
|
||||
* Tests support of requests with If-Modified-Since and If-None-Match headers.
|
||||
*/
|
||||
function testConditionalRequests() {
|
||||
public function testConditionalRequests() {
|
||||
$config = $this->config('system.performance');
|
||||
$config->set('cache.page.max_age', 300);
|
||||
$config->save();
|
||||
|
@ -188,28 +190,28 @@ class PageCacheTest extends WebTestBase {
|
|||
$etag = $this->drupalGetHeader('ETag');
|
||||
$last_modified = $this->drupalGetHeader('Last-Modified');
|
||||
|
||||
$this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag));
|
||||
$this->drupalGet('', [], ['If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag]);
|
||||
$this->assertResponse(304, 'Conditional request returned 304 Not Modified.');
|
||||
|
||||
$this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC822, strtotime($last_modified)), 'If-None-Match: ' . $etag));
|
||||
$this->drupalGet('', [], ['If-Modified-Since: ' . gmdate(DATE_RFC822, strtotime($last_modified)), 'If-None-Match: ' . $etag]);
|
||||
$this->assertResponse(304, 'Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.');
|
||||
|
||||
$this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC850, strtotime($last_modified)), 'If-None-Match: ' . $etag));
|
||||
$this->drupalGet('', [], ['If-Modified-Since: ' . gmdate(DATE_RFC850, strtotime($last_modified)), 'If-None-Match: ' . $etag]);
|
||||
$this->assertResponse(304, 'Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.');
|
||||
|
||||
$this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified));
|
||||
$this->drupalGet('', [], ['If-Modified-Since: ' . $last_modified]);
|
||||
// Verify the page is not printed twice when the cache is warm.
|
||||
$this->assertNoPattern('#<html.*<html#');
|
||||
$this->assertResponse(200, 'Conditional request without If-None-Match returned 200 OK.');
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
|
||||
|
||||
$this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DateTimePlus::RFC7231, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag));
|
||||
$this->drupalGet('', [], ['If-Modified-Since: ' . gmdate(DateTimePlus::RFC7231, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag]);
|
||||
$this->assertResponse(200, 'Conditional request with new a If-Modified-Since date newer than Last-Modified returned 200 OK.');
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
|
||||
|
||||
$user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($user);
|
||||
$this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag));
|
||||
$this->drupalGet('', [], ['If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag]);
|
||||
$this->assertResponse(200, 'Conditional request returned 200 OK for authenticated user.');
|
||||
$this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), 'Absence of Page was not cached.');
|
||||
}
|
||||
|
@ -217,14 +219,14 @@ class PageCacheTest extends WebTestBase {
|
|||
/**
|
||||
* Tests cache headers.
|
||||
*/
|
||||
function testPageCache() {
|
||||
public function testPageCache() {
|
||||
$config = $this->config('system.performance');
|
||||
$config->set('cache.page.max_age', 300);
|
||||
$config->set('response.gzip', 1);
|
||||
$config->save();
|
||||
|
||||
// Fill the cache.
|
||||
$this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar')));
|
||||
$this->drupalGet('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]);
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
|
||||
$this->assertEqual(strtolower($this->drupalGetHeader('Vary')), 'cookie,accept-encoding', 'Vary header was sent.');
|
||||
// Symfony's Response logic determines a specific order for the subvalues
|
||||
|
@ -235,7 +237,7 @@ class PageCacheTest extends WebTestBase {
|
|||
$this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.');
|
||||
|
||||
// Check cache.
|
||||
$this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar')));
|
||||
$this->drupalGet('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]);
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
|
||||
$this->assertEqual(strtolower($this->drupalGetHeader('Vary')), 'cookie,accept-encoding', 'Vary: Cookie header was sent.');
|
||||
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=300, public', 'Cache-Control header was sent.');
|
||||
|
@ -243,15 +245,15 @@ class PageCacheTest extends WebTestBase {
|
|||
$this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.');
|
||||
|
||||
// Check replacing default headers.
|
||||
$this->drupalGet('system-test/set-header', array('query' => array('name' => 'Expires', 'value' => 'Fri, 19 Nov 2008 05:00:00 GMT')));
|
||||
$this->drupalGet('system-test/set-header', ['query' => ['name' => 'Expires', 'value' => 'Fri, 19 Nov 2008 05:00:00 GMT']]);
|
||||
$this->assertEqual($this->drupalGetHeader('Expires'), 'Fri, 19 Nov 2008 05:00:00 GMT', 'Default header was replaced.');
|
||||
$this->drupalGet('system-test/set-header', array('query' => array('name' => 'Vary', 'value' => 'User-Agent')));
|
||||
$this->drupalGet('system-test/set-header', ['query' => ['name' => 'Vary', 'value' => 'User-Agent']]);
|
||||
$this->assertEqual(strtolower($this->drupalGetHeader('Vary')), 'user-agent,accept-encoding', 'Default header was replaced.');
|
||||
|
||||
// Check that authenticated users bypass the cache.
|
||||
$user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($user);
|
||||
$this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar')));
|
||||
$this->drupalGet('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]);
|
||||
$this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), 'Caching was bypassed.');
|
||||
$this->assertTrue(strpos(strtolower($this->drupalGetHeader('Vary')), 'cookie') === FALSE, 'Vary: Cookie header was not sent.');
|
||||
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'must-revalidate, no-cache, private', 'Cache-Control header was sent.');
|
||||
|
@ -330,7 +332,7 @@ class PageCacheTest extends WebTestBase {
|
|||
/**
|
||||
* Tests the 4xx-response cache tag is added and invalidated.
|
||||
*/
|
||||
function testPageCacheAnonymous403404() {
|
||||
public function testPageCacheAnonymous403404() {
|
||||
$admin_url = Url::fromRoute('system.admin');
|
||||
$invalid_url = 'foo/does_not_exist';
|
||||
$tests = [
|
||||
|
@ -347,16 +349,16 @@ class PageCacheTest extends WebTestBase {
|
|||
$this->drupalGet($content_url);
|
||||
$this->assertResponse($code);
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
|
||||
$entity_values = array(
|
||||
$entity_values = [
|
||||
'name' => $this->randomMachineName(),
|
||||
'user_id' => 1,
|
||||
'field_test_text' => array(
|
||||
0 => array(
|
||||
'field_test_text' => [
|
||||
0 => [
|
||||
'value' => $this->randomString(),
|
||||
'format' => 'plain_text',
|
||||
)
|
||||
),
|
||||
);
|
||||
]
|
||||
],
|
||||
];
|
||||
$entity = EntityTest::create($entity_values);
|
||||
$entity->save();
|
||||
// Saving an entity clears 4xx cache tag.
|
||||
|
@ -378,19 +380,19 @@ class PageCacheTest extends WebTestBase {
|
|||
// Given that a second might have passed we cannot be sure that
|
||||
// $difference will exactly equal the default cache_ttl_4xx setting.
|
||||
// Account for any timing difference or rounding errors by ensuring the
|
||||
// value is within 5 seconds.
|
||||
// value is within 10 seconds.
|
||||
$this->assertTrue(
|
||||
$difference > $cache_ttl_4xx - 5 &&
|
||||
$difference < $cache_ttl_4xx + 5,
|
||||
'The cache entry expiry time uses the cache_ttl_4xx setting.'
|
||||
$difference > $cache_ttl_4xx - 10 &&
|
||||
$difference < $cache_ttl_4xx + 10,
|
||||
"The cache entry expiry time uses the cache_ttl_4xx setting. Expire: {$cache_item->expire} Created: {$cache_item->created}"
|
||||
);
|
||||
}
|
||||
|
||||
// Disable 403 and 404 caching.
|
||||
$settings['settings']['cache_ttl_4xx'] = (object) array(
|
||||
$settings['settings']['cache_ttl_4xx'] = (object) [
|
||||
'value' => 0,
|
||||
'required' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->writeSettings($settings);
|
||||
\Drupal::service('cache.render')->deleteAll();
|
||||
|
||||
|
@ -411,10 +413,10 @@ class PageCacheTest extends WebTestBase {
|
|||
$config->set('cache.page.max_age', 300);
|
||||
$config->save();
|
||||
|
||||
$settings['settings']['omit_vary_cookie'] = (object) array(
|
||||
$settings['settings']['omit_vary_cookie'] = (object) [
|
||||
'value' => TRUE,
|
||||
'required' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->writeSettings($settings);
|
||||
|
||||
// Fill the cache.
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
* Install hooks for page_cache_form_test.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function page_cache_form_test_install() {
|
||||
// Set an explicit module weight, to ensure that the form alter hook is
|
||||
// always called after page_cache_form_alter().
|
||||
|
|
Reference in a new issue