diff --git a/CHANGELOG.md b/CHANGELOG.md index e4fb786f904..fcbcde05707 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Fixed a bug where field layout designers weren’t displaying native fields in the library pane when a tab was removed that contained them. ([#15064](https://github.com/craftcms/cms/issues/15064)) - Fixed a bug where recent textual changes could be lost when creating a new inline-editable Matrix block, if the block was created before the autosave had a chance to initiate. ([#15069](https://github.com/craftcms/cms/issues/15069)) - 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)) ## 5.1.7 - 2024-05-25 diff --git a/src/elements/Entry.php b/src/elements/Entry.php index 0de7280d514..b0d67521983 100644 --- a/src/elements/Entry.php +++ b/src/elements/Entry.php @@ -2201,8 +2201,15 @@ private function _userPostDate(): ?DateTime */ public function beforeValidate(): bool { - if (!isset($this->_authorIds) && !isset($this->fieldId) && $this->getSection()->type !== Section::TYPE_SINGLE) { - $this->setAuthor(Craft::$app->getUser()->getIdentity()); + if ( + (!isset($this->_authorIds) || empty($this->_authorIds)) && + !isset($this->fieldId) && + $this->getSection()->type !== Section::TYPE_SINGLE + ) { + $user = Craft::$app->getUser()->getIdentity(); + if ($user) { + $this->setAuthor($user); + } } if (