From 53324683532c0dbcf19ea42922a3115c9c9cd03c Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Wed, 18 Apr 2018 03:54:50 -0700 Subject: [PATCH] Fixed #2764 --- CHANGELOG-v3.md | 1 + src/elements/Asset.php | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index 3784a1d386f..9166a04022d 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -4,6 +4,7 @@ ### Fixed - Fixed an error that occurred when editing an entry if any of the entry’s revisions were created with an entry type that no longer exists. +- Fixed an error that could occur when saving an asset. ([#2764](https://github.com/craftcms/cms/issues/2764)) ## 3.0.3 - 2018-04-17 diff --git a/src/elements/Asset.php b/src/elements/Asset.php index b4f31cf5cc1..d02c843c211 100644 --- a/src/elements/Asset.php +++ b/src/elements/Asset.php @@ -1212,9 +1212,12 @@ public function afterSave(bool $isNew) { // If this is just an element being propagated, there's absolutely no need for re-saving this. if (!$this->propagating) { - if (AssetsHelper::getFileKindByExtension($this->tempFilePath) === static::KIND_IMAGE && + if ( + $this->tempFilePath !== null && + AssetsHelper::getFileKindByExtension($this->tempFilePath) === static::KIND_IMAGE && \in_array($this->getScenario(), [self::SCENARIO_REPLACE, self::SCENARIO_CREATE], true) && - null !== $this->tempFilePath) { + null !== $this->tempFilePath + ) { Image::cleanImageByPath($this->tempFilePath); }