Skip to content

Commit d39ef93

Browse files
committed
BUGFIX: Flush content cache when the pipeline actually starts
1 parent 8b5f110 commit d39ef93

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

Classes/Command/ContentReleasePrepareCommandController.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Flowpack\DecoupledContentStore\Core\Domain\ValueObject\ContentReleaseIdentifier;
1111
use Flowpack\DecoupledContentStore\Core\Infrastructure\ContentReleaseLogger;
1212
use Neos\Flow\Cli\CommandController;
13+
use Neos\Fusion\Core\Cache\ContentCache;
1314

1415
/**
1516
* Commands for the PREPARE stage in the pipeline. Not meant to be called manually.
@@ -28,6 +29,12 @@ class ContentReleasePrepareCommandController extends CommandController
2829
*/
2930
protected $concurrentBuildLock;
3031

32+
/**
33+
* @Flow\Inject
34+
* @var ContentCache
35+
*/
36+
protected $contentCache;
37+
3138
public function createContentReleaseCommand(string $contentReleaseIdentifier, string $prunnerJobId, string $workspaceName = 'live'): void
3239
{
3340
$contentReleaseIdentifier = ContentReleaseIdentifier::fromString($contentReleaseIdentifier);
@@ -52,4 +59,15 @@ public function registerManualTransferJobCommand(string $contentReleaseIdentifie
5259

5360
$this->redisContentReleaseService->registerManualTransferJob($contentReleaseIdentifier, $prunnerJobId, $logger);
5461
}
62+
63+
public function flushContentCacheIfRequiredCommand(string $contentReleaseIdentifier, bool $flushContentCache = false): void
64+
{
65+
$logger = ContentReleaseLogger::fromConsoleOutput($this->output, ContentReleaseIdentifier::fromString($contentReleaseIdentifier));
66+
if (!$flushContentCache) {
67+
$logger->info('Not flushing content cache');
68+
return;
69+
}
70+
$logger->info('Flushing content cache');
71+
$this->contentCache->flush();
72+
}
5573
}

Classes/ContentReleaseManager.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,12 @@
1212
use Neos\Flow\Annotations as Flow;
1313
use Flowpack\Prunner\PrunnerApiService;
1414
use Flowpack\Prunner\ValueObject\PipelineName;
15-
use Neos\Fusion\Core\Cache\ContentCache;
1615

1716
/**
1817
* @Flow\Scope("singleton")
1918
*/
2019
class ContentReleaseManager
2120
{
22-
/**
23-
* @Flow\Inject
24-
* @var ContentCache
25-
*/
26-
protected $contentCache;
2721

2822
/**
2923
* @Flow\Inject
@@ -61,6 +55,7 @@ public function startIncrementalContentRelease(string $currentContentReleaseId =
6155
'currentContentReleaseId' => $currentContentReleaseId ?: self::NO_PREVIOUS_RELEASE,
6256
'validate' => true,
6357
'workspaceName' => $workspace ? $workspace->getName() : 'live',
58+
'flushContentCache' => false,
6459
]));
6560
return $contentReleaseId;
6661
}
@@ -74,12 +69,12 @@ public function startFullContentRelease(bool $validate = true, string $currentCo
7469
}
7570

7671
$contentReleaseId = ContentReleaseIdentifier::create();
77-
$this->contentCache->flush();
7872
$this->prunnerApiService->schedulePipeline(PipelineName::create('do_content_release'), array_merge($additionalVariables, [
7973
'contentReleaseId' => $contentReleaseId,
8074
'currentContentReleaseId' => $currentContentReleaseId ?: self::NO_PREVIOUS_RELEASE,
8175
'validate' => $validate,
8276
'workspaceName' => $workspace ? $workspace->getName() : 'live',
77+
'flushContentCache' => true,
8378
]));
8479
return $contentReleaseId;
8580
}

pipelines_template.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ pipelines:
3434
################################################################################
3535
prepare_finished:
3636
script:
37-
- ./flow contentReleasePrepare:createContentRelease {{ .contentReleaseId }} {{ .__jobID }} {{ .workspaceName }}
37+
- ./flow contentReleasePrepare:createContentRelease {{ .contentReleaseId }} {{ .__jobID }} --workspaceName={{ .workspaceName }}
3838
- ./flow contentReleasePrepare:ensureAllOtherInProgressContentReleasesWillBeTerminated {{ .contentReleaseId }}
39+
- ./flow contentReleasePrepare:flushContentCacheIfRequired {{ .contentReleaseId }} --flushContentCache={{ .flushContentCache }}
3940

4041
################################################################################
4142
# 1) ENUMERATION

0 commit comments

Comments
 (0)