From fc98b90904402f66dc60db9bd18c85fbeb869e0b Mon Sep 17 00:00:00 2001 From: Lukasz Cybula Date: Tue, 10 Jul 2018 12:13:33 +0200 Subject: [PATCH] Do not try to get saved property value when there is none --- composer.json | 3 +++ .../DoctrineExtensions/Uploadable/UploadableListener.php | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index af37059..61b51c0 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,9 @@ "doctrine/orm": "~2.4", "phpunit/phpunit": "3.7.*" }, + "conflict": { + "phpunit/php-file-iterator": ">=2.0.0" + }, "autoload": { "psr-4": { "FSi\\DoctrineExtensions\\": "lib/FSi/DoctrineExtensions/" diff --git a/lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php b/lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php index 03c9ccc..aa810b4 100644 --- a/lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php +++ b/lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php @@ -395,10 +395,10 @@ protected function updateFiles(ObjectManager $objectManager, $uploadableMeta, $o $filesystem = $this->computeFilesystem($config); // Since file has changed, the old one should be removed. - if ($oldKey = $accessor->getValue($object, $property)) { - if ($oldFile = $propertyObserver->getSavedValue($object, $config['targetField'])) { - $this->addToDelete($oldFile); - } + if ($accessor->getValue($object, $property) + && $propertyObserver->hasSavedValue($object, $config['targetField']) + && $oldFile = $propertyObserver->getSavedValue($object, $config['targetField'])) { + $this->addToDelete($oldFile); } if (empty($file)) {