Skip to content

Commit

Permalink
Fixed #14350
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Feb 11, 2024
1 parent 43dd2e0 commit 6635cc6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- `craft\behaviors\SessionBehavior::setSuccess()` and `getSuccess()` use the `success` flash key now, rather than `notice`. ([#14345](https://github.com/craftcms/cms/pull/14345))
- Exception response data no longer includes an `error` key with the exception message. `message` should be used instead. ([#14346](https://github.com/craftcms/cms/pull/14346))
- Fixed a bug where read/write splitting was always getting disabled for GraphQL POST requests. ([#14324](https://github.com/craftcms/cms/issues/14324))
- Fixed an error that occurred when adding a new block to a Matrix field with an overridden handle. ([#14350](https://github.com/craftcms/cms/issues/14350))

## 5.0.0-beta.1 - 2024-02-08

Expand Down
14 changes: 7 additions & 7 deletions src/controllers/MatrixController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ public function actionCreateEntry(): Response
$siteId = $this->request->getRequiredBodyParam('siteId');
$namespace = $this->request->getRequiredBodyParam('namespace');

$field = Craft::$app->getFields()->getFieldById($fieldId);
$elementsService = Craft::$app->getElements();
$owner = $elementsService->getElementById($ownerId, $ownerElementType, $siteId);
if (!$owner) {
throw new BadRequestHttpException("Invalid owner ID, element type, or site ID.");
}

$field = $owner->getFieldLayout()?->getFieldById($fieldId);
if (!$field instanceof Matrix) {
throw new BadRequestHttpException("Invalid Matrix field ID: $fieldId");
}
Expand All @@ -94,12 +100,6 @@ public function actionCreateEntry(): Response
throw new BadRequestHttpException("Invalid site ID: $siteId");
}

$elementsService = Craft::$app->getElements();
$owner = $elementsService->getElementById($ownerId, $ownerElementType, $siteId);
if (!$owner) {
throw new BadRequestHttpException("Invalid owner ID, element type, or site ID.");
}

/** @var Entry $entry */
$entry = Craft::createObject([
'class' => Entry::class,
Expand Down

0 comments on commit 6635cc6

Please sign in to comment.