Skip to content

Commit e01bfa7

Browse files
authored
BUGFIX: Avoid creating workspaces in nodeindex:build
When the name of a non-existing workspace was given to `nodeindex:build`, that work was implicitly created (due to some legacy default behaviour of the content repository). This change adds a check and stops when the workspace does not exist. The `nodeindex:indexnode` command did not cause workspace creation, but now shows an error message, instead of an exception. Covfefe! Fixes issue #213
1 parent a092e41 commit e01bfa7

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Command/NodeIndexCommandController.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,12 @@ public function indexNodeCommand($identifier, $workspace = null)
181181
$indexInWorkspace($identifier, $workspace);
182182
}
183183
} else {
184-
$workspace = $this->workspaceRepository->findByIdentifier($workspace);
185-
$indexInWorkspace($identifier, $workspace);
184+
$workspaceInstance = $this->workspaceRepository->findByIdentifier($workspace);
185+
if ($workspaceInstance === null) {
186+
$this->outputLine('The given workspace (%s) does not exist.', [$workspace]);
187+
$this->quit(1);
188+
}
189+
$indexInWorkspace($identifier, $workspaceInstance);
186190
}
187191
}
188192

@@ -199,6 +203,11 @@ public function indexNodeCommand($identifier, $workspace = null)
199203
*/
200204
public function buildCommand($limit = null, $update = false, $workspace = null, $postfix = null)
201205
{
206+
if ($workspace !== null && $this->workspaceRepository->findByIdentifier($workspace) === null) {
207+
$this->logger->log('The given workspace (' . $workspace . ') does not exist.', LOG_ERR);
208+
$this->quit(1);
209+
}
210+
202211
if ($update === true) {
203212
$this->logger->log('!!! Update Mode (Development) active!', LOG_INFO);
204213
} else {

0 commit comments

Comments
 (0)