From 19107f2f86b93c22ceb3f68149652ed2ed109b2d Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Sat, 7 Apr 2018 06:33:30 -0700 Subject: [PATCH] Fixed #2687 --- CHANGELOG-v2.md | 5 +++++ src/controllers/EntriesController.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-v2.md b/CHANGELOG-v2.md index 260f5391bc2..2a07cd72f92 100644 --- a/CHANGELOG-v2.md +++ b/CHANGELOG-v2.md @@ -1,5 +1,10 @@ # Release Notes for Craft CMS 2.x +## Unreleased + +### Fixed +- Fixed an error that occurred when saving a Single entry over Ajax. ([#2687](https://github.com/craftcms/cms/issues/2687)) + ## 2.6.3015 - 2018-04-06 ### Changed diff --git a/src/controllers/EntriesController.php b/src/controllers/EntriesController.php index 71b83893dd9..ec3e8338099 100644 --- a/src/controllers/EntriesController.php +++ b/src/controllers/EntriesController.php @@ -472,7 +472,11 @@ public function actionSaveEntry() $return['cpEditUrl'] = $entry->getCpEditUrl(); } - $return['authorUsername'] = $entry->getAuthor()->username; + if (($author = $entry->getAuthor()) !== null) + { + $return['authorUsername'] = $author->username; + } + $return['dateCreated'] = DateTimeHelper::toIso8601($entry->dateCreated); $return['dateUpdated'] = DateTimeHelper::toIso8601($entry->dateUpdated); $return['postDate'] = ($entry->postDate ? DateTimeHelper::toIso8601($entry->postDate) : null);