diff --git a/lib/Doctrine/MongoDB/GridFS.php b/lib/Doctrine/MongoDB/GridFS.php index be393721..7e4c69d4 100644 --- a/lib/Doctrine/MongoDB/GridFS.php +++ b/lib/Doctrine/MongoDB/GridFS.php @@ -70,7 +70,10 @@ protected function doUpdate($query, array $newObj, array $options = array()) // First do a find and remove query to remove the file metadata and chunks so // we can restore the file below - $document = $this->findAndRemove($query, $options); + if (null === $document = $this->findAndRemove($query, $options)) { + throw new \Exception("Could not find original document containing file"); + } + unset( $document['filename'], $document['length'],