Skip to content

Commit f4db0b6

Browse files
committed
BUGFIX: Set up missing alias during nodeindex:indexnode
With this change running `nodeindex:indexnode` - without `--postfix` uses existing aliases or creates a new postfix (like `nodeindex:build` does) and sets up aliases - with `--postfix` given will use that postfix and not change aliases, as that's probably intended when passing the postfix manually Fixes #370
1 parent 5ad0cd9 commit f4db0b6

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Classes/Command/NodeIndexCommandController.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,27 @@ class NodeIndexCommandController extends CommandController
152152
* @param string|null $workspace
153153
* @param string|null $postfix
154154
* @return void
155+
* @throws ApiException
155156
* @throws ConfigurationException
156157
* @throws Exception
158+
* @throws RuntimeException
159+
* @throws SubProcessException
157160
* @throws \Flowpack\ElasticSearch\Exception
161+
* @throws \JsonException
158162
*/
159163
public function indexNodeCommand(string $identifier, string $workspace = null, string $postfix = null): void
160164
{
161165
if ($workspace === null && $this->settings['indexAllWorkspaces'] === false) {
162166
$workspace = 'live';
163167
}
164168

169+
$updateAliases = false;
165170
if ($postfix !== null) {
166171
$this->nodeIndexer->setIndexNamePostfix($postfix);
172+
} elseif ($this->aliasesExist() === false) {
173+
$postfix = (string)time();
174+
$updateAliases = true;
175+
$this->nodeIndexer->setIndexNamePostfix($postfix);
167176
}
168177

169178
$indexNode = function ($identifier, Workspace $workspace, array $dimensions) {
@@ -211,6 +220,22 @@ public function indexNodeCommand(string $identifier, string $workspace = null, s
211220
}
212221

213222
$this->nodeIndexer->flush();
223+
224+
if ($updateAliases) {
225+
$combinations = $this->contentDimensionCombinator->getAllAllowedCombinations();
226+
$combinations = $combinations === [] ? [[]] : $combinations;
227+
228+
foreach ($combinations as $combination) {
229+
$this->executeInternalCommand('aliasInternal', [
230+
'dimensionsValues' => json_encode($combination, JSON_THROW_ON_ERROR),
231+
'postfix' => $postfix,
232+
'update' => false
233+
]);
234+
}
235+
236+
$this->nodeIndexer->updateMainAlias();
237+
}
238+
214239
$this->outputErrorHandling();
215240
}
216241

0 commit comments

Comments
 (0)