Skip to content

Commit

Permalink
Fix “Copy value from site” for non-admin users
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Feb 1, 2025
1 parent f1aeb2a commit d7a2f4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fixed a bug where section-specific GraphQL queries (`<sectionHandle>Entries`) weren’t available if a Matrix or CKEditor field existed with the same handle as the section.
- Fixed an error that could occur after reordering routes. ([#16610](https://github.com/craftcms/cms/pull/16610))
- Fixed an error that occurred when a non-admin user attempted to copy a field value from another site.

## 5.6.4 - 2025-01-30

Expand Down
6 changes: 5 additions & 1 deletion src/controllers/ElementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,11 @@ public function actionCopyValuesFromSite(): Response
}

$copyFromSiteId = (int)$this->request->getRequiredBodyParam('fromSiteId');
$this->requirePermission("editSite:$copyFromSiteId");
$site = Craft::$app->getSites()->getSiteById($copyFromSiteId);
if (!$site) {
throw new BadRequestHttpException("Invalid site ID: $copyFromSiteId");
}
$this->requirePermission("editSite:$site->uid");

$layoutElementUid = $this->request->getRequiredBodyParam('layoutElementUid');
$namespace = $this->request->getBodyParam('namespace');
Expand Down

0 comments on commit d7a2f4d

Please sign in to comment.