Skip to content

Commit

Permalink
Make sure 'ez-all' is added to beginning of string to avoid being tru…
Browse files Browse the repository at this point in the history
…ncated
  • Loading branch information
andrerom committed Feb 10, 2020
1 parent 7708fd5 commit 86dc065
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions spec/Handler/TagHandlerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function let(
$cacheManager->supports(CacheManager::INVALIDATE)->willReturn(true);

$this->beConstructedWith($cacheManager, 'xkey', $purgeClient, $tagPrefix, $logger, 1000, 300);

$tagPrefix->getRepositoryPrefix()->willReturn('');
}

public function it_calls_purge_on_invalidate()
Expand Down Expand Up @@ -100,7 +102,7 @@ public function it_tags_all_tags_we_add(Response $response, ResponseHeaderBag $r
public function it_tags_all_tags_we_add_and_prefix_with_repo_id(Response $response, ResponseHeaderBag $responseHeaderBag, RepositoryTagPrefix $tagPrefix)
{
$tagPrefix->getRepositoryPrefix()->willReturn('0');
$responseHeaderBag->set('xkey', Argument::exact('0ez-all 0l4 0c4 0p2 ez-all'))->shouldBeCalled();
$responseHeaderBag->set('xkey', Argument::exact('ez-all 0ez-all 0l4 0c4 0p2'))->shouldBeCalled();

$this->addTags(['l4', 'c4']);
$this->addTags(['p2']);
Expand All @@ -112,7 +114,7 @@ public function it_tags_all_tags_we_add_and_prefix_with_repo_id_also_with_existi
$tagPrefix->getRepositoryPrefix()->willReturn('2');
$responseHeaderBag->has('xkey')->willReturn(true);
$responseHeaderBag->get('xkey', null, false)->willReturn(['tag1']);
$responseHeaderBag->set('xkey', Argument::exact('2tag1 2ez-all 2l4 2c4 2p2 ez-all'))->shouldBeCalled();
$responseHeaderBag->set('xkey', Argument::exact('ez-all 2tag1 2ez-all 2l4 2c4 2p2'))->shouldBeCalled();

$this->addTags(['l4', 'c4']);
$this->addTags(['p2']);
Expand Down
6 changes: 4 additions & 2 deletions src/Handler/TagHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ static function ($tag) use ($repoPrefix) {
$tags
);

// Also add a un-prefixed `ez-all` in order to be able to purge all across repos
$tags[] = 'ez-all';
if ($repoPrefix !== '') {
// An un-prefixed `ez-all` for purging across repos, add to start of array to avoid being truncated
array_unshift($tags, 'ez-all');
}

$tagsString = implode(' ', array_unique($tags));
$tagsLength = strlen($tagsString);
Expand Down

0 comments on commit 86dc065

Please sign in to comment.