Skip to content

Commit dc11cf3

Browse files
committed
Drop custom fields from elements/* failure responses
Resolves #11807
1 parent 3c94009 commit dc11cf3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Improved the console output for the `gc` command.
1212
- The `gc` command now runs garbage collection for data caches.
1313
- Exception JSON responses now include `name` and `code` keys. ([#11799](https://github.com/craftcms/cms/discussions/11799))
14+
- `elements/*` actions no longer include custom field values in the failure response data, improving performance. ([#11807](https://github.com/craftcms/cms/discussions/11807))
1415

1516
### Fixed
1617
- Fixed a bug where keyboard focus wasn’t being maintained when changing the element type within a “Related To” condition rule.

src/controllers/ElementsController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,12 @@ private function _asSuccess(string $message, ElementInterface $element, array $d
17351735

17361736
private function _asFailure(ElementInterface $element, string $message): ?Response
17371737
{
1738-
/** @var Element $element */
1739-
return $this->asModelFailure($element, $message, 'element');
1738+
$data = [
1739+
'modelName' => 'element',
1740+
'element' => $element->toArray($element->attributes()),
1741+
'errors' => $element->getErrors(),
1742+
];
1743+
1744+
return $this->asFailure($message, $data, ['element' => $element]);
17401745
}
17411746
}

0 commit comments

Comments
 (0)