Commit 6aa739c4 authored by Will Banfield's avatar Will Banfield Committed by Jeremy Mikola

PHPLIB-159: rename uses UpdateOne() per the spec

parent 2ca40c7d
......@@ -279,14 +279,10 @@ class Bucket
public function rename(ObjectId $id, $newFilename)
{
$filesCollection = $this->collectionsWrapper->getFilesCollection();
$file = $filesCollection->findOne(['_id' => $id]);
if ($file === null) {
$result = $filesCollection->updateOne(['_id' => $id], ['$set' => ['filename' => $newFilename]]);
if($result->getModifiedCount() == 0) {
throw new GridFSFileNotFoundException($id, $this->collectionsWrapper->getFilesCollection()->getNameSpace());
}
$file->filename = $newFilename;
$filesCollection->replaceOne(['_id' => $id], $file);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment