Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
Clean up withReadPreference handling
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed Apr 27, 2018
1 parent d7dcc75 commit 859565b
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions lib/Doctrine/MongoDB/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,17 +481,10 @@ private function withReadPreference($object, \Closure $closure)
$object->setReadPreference($this->query['readPreference'], $this->query['readPreferenceTags']);

try {
$result = $closure();
} catch (\Exception $e) {
}

$prevTags = ! empty($prevReadPref['tagsets']) ? $prevReadPref['tagsets'] : null;
$object->setReadPreference($prevReadPref['type'], $prevTags);

if (isset($e)) {
throw $e;
return $closure();
} finally {
$prevTags = ! empty($prevReadPref['tagsets']) ? $prevReadPref['tagsets'] : [];
$object->setReadPreference($prevReadPref['type'], $prevTags);
}

return $result;
}
}

0 comments on commit 859565b

Please sign in to comment.