diff --git a/src/Content/ContentStorageHandler.php b/src/Content/ContentStorageHandler.php index a7f0820561..c1084fd7a5 100644 --- a/src/Content/ContentStorageHandler.php +++ b/src/Content/ContentStorageHandler.php @@ -101,18 +101,18 @@ public function dynamicVersions(): array * * @throws \Kirby\Exception\NotFoundException If the version does not exist */ - public function ensure(VersionId $versionId, Language $language): bool + public function ensure(VersionId $versionId, Language $language): void { - if ($this->exists($versionId, $language) !== true) { - $message = match($this->model->kirby()->multilang()) { - true => 'Version "' . $versionId . ' (' . $language->code() . ')" does not already exist', - false => 'Version "' . $versionId . '" does not already exist', - }; - - throw new NotFoundException($message); + if ($this->exists($versionId, $language) === true) { + return; } - return true; + $message = match($this->model->kirby()->multilang()) { + true => 'Version "' . $versionId . ' (' . $language->code() . ')" does not already exist', + false => 'Version "' . $versionId . '" does not already exist', + }; + + throw new NotFoundException($message); } /** diff --git a/src/Content/Version.php b/src/Content/Version.php index d053dcc709..d9ba0d93a8 100644 --- a/src/Content/Version.php +++ b/src/Content/Version.php @@ -86,8 +86,8 @@ public function delete(): void */ public function ensure( Language|string $language = 'default' - ): bool { - return $this->model->storage()->ensure($this->id, $this->language($language)); + ): void { + $this->model->storage()->ensure($this->id, $this->language($language)); } /**