@@ -55,28 +55,16 @@ class ContentReleaseManager
5555
5656 public function startIncrementalContentRelease (string $ currentContentReleaseId = null , Workspace $ workspace = null , array $ additionalVariables = []): ContentReleaseIdentifier
5757 {
58- $ redis = $ this ->redisClientManager ->getPrimaryRedis ();
59-
6058 $ contentReleaseId = ContentReleaseIdentifier::create ();
6159
62- $ currentContentReleaseIdOrFallback = $ currentContentReleaseId
63- ?? $ redis ->get (self ::REDIS_CURRENT_RELEASE_KEY )
64- ?: self ::NO_PREVIOUS_RELEASE ;
65-
66- $ workspaceName = $ workspace !== null ? $ workspace ->getName () : 'live ' ;
67-
68- $ accountId = $ this ->securityContext ->isInitialized ()
69- ? $ this ->securityContext ->getAccount ()->getAccountIdentifier ()
70- : null ;
71-
7260 // the currentContentReleaseId is not used in any pipeline step in this package, but is a common need in other
7361 // use cases in extensions, e.g. calculating the differences between current and new release
7462 $ this ->prunnerApiService ->schedulePipeline (PipelineName::create ('do_content_release ' ), array_merge ($ additionalVariables , [
7563 'contentReleaseId ' => $ contentReleaseId ,
76- 'currentContentReleaseId ' => $ currentContentReleaseIdOrFallback ,
64+ 'currentContentReleaseId ' => $ this -> resolveCurrentContentReleaseId ( $ currentContentReleaseId ) ,
7765 'validate ' => true ,
78- 'workspaceName ' => $ workspaceName ,
79- 'accountId ' => $ accountId ,
66+ 'workspaceName ' => $ workspace !== null ? $ workspace -> getName () : ' live ' ,
67+ 'accountId ' => $ this -> getAccountId () ,
8068 ]));
8169
8270 return $ contentReleaseId ;
@@ -85,27 +73,16 @@ public function startIncrementalContentRelease(string $currentContentReleaseId =
8573 // the validate parameter can be used to intentionally skip the validation step for this release
8674 public function startFullContentRelease (bool $ validate = true , string $ currentContentReleaseId = null , Workspace $ workspace = null , array $ additionalVariables = []): ContentReleaseIdentifier
8775 {
88- $ redis = $ this ->redisClientManager ->getPrimaryRedis ();
89-
9076 $ contentReleaseId = ContentReleaseIdentifier::create ();
9177
92- $ currentContentReleaseIdOrFallback = $ currentContentReleaseId
93- ?? $ redis ->get (self ::REDIS_CURRENT_RELEASE_KEY )
94- ?: self ::NO_PREVIOUS_RELEASE ;
95-
96- $ workspaceName = $ workspace !== null ? $ workspace ->getName () : 'live ' ;
97-
98- $ accountId = $ this ->securityContext ->isInitialized ()
99- ? $ this ->securityContext ->getAccount ()->getAccountIdentifier ()
100- : null ;
101-
10278 $ this ->contentCache ->flush ();
79+
10380 $ this ->prunnerApiService ->schedulePipeline (PipelineName::create ('do_content_release ' ), array_merge ($ additionalVariables , [
10481 'contentReleaseId ' => $ contentReleaseId ,
105- 'currentContentReleaseId ' => $ currentContentReleaseIdOrFallback ,
82+ 'currentContentReleaseId ' => $ this -> resolveCurrentContentReleaseId ( $ currentContentReleaseId ) ,
10683 'validate ' => $ validate ,
107- 'workspaceName ' => $ workspaceName ,
108- 'accountId ' => $ accountId ,
84+ 'workspaceName ' => $ workspace !== null ? $ workspace -> getName () : ' live ' ,
85+ 'accountId ' => $ this -> getAccountId () ,
10986 ]));
11087
11188 return $ contentReleaseId ;
@@ -148,4 +125,29 @@ public function toggleConfigEpoch(RedisInstanceIdentifier $redisInstanceIdentifi
148125 $ redis ->set ('contentStore:configEpoch ' , $ currentConfigEpochConfig );
149126 }
150127 }
128+
129+ private function resolveCurrentContentReleaseId (?string $ currentContentReleaseId ): string
130+ {
131+ if ($ currentContentReleaseId !== null ) {
132+ return $ currentContentReleaseId ;
133+ }
134+
135+ $ redis = $ this ->redisClientManager ->getPrimaryRedis ();
136+ $ currentContentReleaseIdFromRedis = $ redis ->get (self ::REDIS_CURRENT_RELEASE_KEY );
137+
138+ if ($ currentContentReleaseIdFromRedis !== false ) {
139+ return $ currentContentReleaseIdFromRedis ;
140+ }
141+
142+ return self ::NO_PREVIOUS_RELEASE ;
143+ }
144+
145+ private function getAccountId (): ?string
146+ {
147+ if ($ this ->securityContext ->isInitialized ()) {
148+ return $ this ->securityContext ->getAccount ()->getAccountIdentifier ();
149+ }
150+
151+ return null ;
152+ }
151153}
0 commit comments