From 0cc2a9a1d354e2e9ea1112209f1869c47e78d850 Mon Sep 17 00:00:00 2001 From: Pablo Godel Date: Tue, 10 Jul 2012 16:27:47 -0300 Subject: [PATCH] Added check in doUpdate() to make sure the document containing the file is returned when updating an existing document with a new file. --- lib/Doctrine/MongoDB/GridFS.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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'],