Skip to content

Commit

Permalink
Fall back to "newX" keys for blocks without UUIDs
Browse files Browse the repository at this point in the history
Resolves #15103
  • Loading branch information
brandonkelly committed Jun 1, 2024
1 parent 7c59496 commit 95205c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Fixed a bug where the `users/create` command would fail without explaining why, when the maximum number of users had already been reached.
- Fixed a validation error that could occur when saving an entry on Craft Solo. ([#15082](https://github.com/craftcms/cms/issues/15082))
- Fixed an error that could occur on an element edit page, if a Matrix field’s Propagation Method was set to “Custom…”, but its Propagation Key Format wasn’t filled in.
- Fixed a bug where Matrix block invalidation errors weren’t getting grouped by block when set on the parent element, for blocks that didn’t have `uid` values. ([#15103](https://github.com/craftcms/cms/discussions/15103))

## 5.1.7 - 2024-05-25

Expand Down
4 changes: 3 additions & 1 deletion src/fields/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ private function validateEntries(ElementInterface $element): void
{
/** @var EntryQuery|ElementCollection $value */
$value = $element->getFieldValue($this->handle);
$new = 0;
if ($value instanceof EntryQuery) {
/** @var Entry[] $entries */
Expand All @@ -1004,7 +1005,8 @@ private function validateEntries(ElementInterface $element): void
}
if (!$entry->validate()) {
$element->addModelErrors($entry, "$this->handle[$entry->uid]");
$key = $entry->uid ?? sprintf('new%s', ++$new);
$element->addModelErrors($entry, sprintf('%s[%s]', $this->handle, $key));
$allEntriesValidate = false;
}
}
Expand Down

0 comments on commit 95205c2

Please sign in to comment.