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)) {