Skip to content

Commit

Permalink
Merge pull request #47 from pantheon-systems/bugs-5478
Browse files Browse the repository at this point in the history
[BUGS-5478] Skip clearing keys on install.php page.
  • Loading branch information
kporras07 authored Nov 28, 2022
2 parents 434da48 + 9022d4e commit 5e81a1a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions pantheon_advanced_page_cache.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
arguments: ['pantheon_advanced_page_cache']
pantheon_advanced_page_cache.cache_tags.invalidator:
class: Drupal\pantheon_advanced_page_cache\CacheTagsInvalidator
arguments: ['@request_stack']
tags:
- { name: cache_tags_invalidator }
pantheon_advanced_page_cache.cacheable_response_subscriber:
Expand Down
23 changes: 23 additions & 0 deletions src/CacheTagsInvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,39 @@
namespace Drupal\pantheon_advanced_page_cache;

use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
use Symfony\Component\HttpFoundation\RequestStack;

/**
* Cache tags invalidator implementation that invalidates the Pantheon edge.
*/
class CacheTagsInvalidator implements CacheTagsInvalidatorInterface {

/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;

/**
* Construct.
*/
public function __construct(RequestStack $request_stack) {
$this->requestStack = $request_stack;
}

/**
* {@inheritdoc}
*/
public function invalidateTags(array $tags) {
$do_not_run_urls = [
// There is a weird interaction with metatag that clear local_tasks key
// and therefore lots of cached pages.
'/core/install.php',
];
if (in_array($this->requestStack->getCurrentRequest()->getBaseUrl(), $do_not_run_urls)) {
return;
}
if (function_exists('pantheon_clear_edge_keys')) {
pantheon_clear_edge_keys($tags);
}
Expand Down

0 comments on commit 5e81a1a

Please sign in to comment.