Skip to content

Commit

Permalink
Merge pull request #16235 from craftcms/bugfix/16227-apply-field-save…
Browse files Browse the repository at this point in the history
…-old-and-new-settings

`applyFieldSave` needs to get the most up-to-date field before assigning old settings
  • Loading branch information
brandonkelly authored Dec 1, 2024
2 parents 718173a + 4546068 commit 218ee9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fixed an error that could occur when duplicating an element with an Assets field that had a dynamic subpath. ([#16214](https://github.com/craftcms/cms/issues/16214))
- Reduced the likelihood of a deadlock error occurring when updating search indexes. ([#15221](https://github.com/craftcms/cms/issues/15221))
- Fixed a bug where renaming asset folders could move them to the webroot on Windows. ([#16215](https://github.com/craftcms/cms/issues/16215))
- Fixed a bug where Matrix fields’ content tables weren’t getting renamed properly when applying project config changes. ([#16227](https://github.com/craftcms/cms/issues/16227))

## 4.13.3 - 2024-11-22

Expand Down
7 changes: 7 additions & 0 deletions src/services/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,13 @@ public function applyFieldSave(string $fieldUid, array $data, string $context):
$field ??= $this->getFieldById($fieldRecord->id);
$field->id = $fieldRecord->id;
} else {
// if it's not a control panel save request, get the field again
// so that it has the new settings
// https://github.com/craftcms/cms/issues/16227
if (!isset($this->_savingFields[$fieldUid])) {
$field = $this->getFieldById($fieldRecord->id);
}

// Save the old field handle and settings on the model in case the field type needs to do something with it.
$field->oldHandle = $fieldRecord->getOldHandle();
$field->oldSettings = is_string($oldSettings) ? Json::decode($oldSettings) : null;
Expand Down

0 comments on commit 218ee9a

Please sign in to comment.