Commit cab405d6 authored by Jeremy Mikola's avatar Jeremy Mikola

Aggregate should check server support before returning a cursor

parent 26078fe2
...@@ -113,10 +113,12 @@ class Aggregate implements Executable ...@@ -113,10 +113,12 @@ class Aggregate implements Executable
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
$command = $this->createCommand($server); $isCursorSupported = \MongoDB\server_supports_feature($server, self::$wireVersionForCursor);
$command = $this->createCommand($server, $isCursorSupported);
$cursor = $server->executeCommand($this->databaseName, $command); $cursor = $server->executeCommand($this->databaseName, $command);
if ($this->options['useCursor']) { if ($isCursorSupported && $this->options['useCursor']) {
return $cursor; return $cursor;
} }
...@@ -140,9 +142,10 @@ class Aggregate implements Executable ...@@ -140,9 +142,10 @@ class Aggregate implements Executable
* Create the aggregate command. * Create the aggregate command.
* *
* @param Server $server * @param Server $server
* @param boolean $isCursorSupported
* @return Command * @return Command
*/ */
private function createCommand(Server $server) private function createCommand(Server $server, $isCursorSupported)
{ {
$cmd = array( $cmd = array(
'aggregate' => $this->collectionName, 'aggregate' => $this->collectionName,
...@@ -150,7 +153,7 @@ class Aggregate implements Executable ...@@ -150,7 +153,7 @@ class Aggregate implements Executable
); );
// Servers < 2.6 do not support any command options // Servers < 2.6 do not support any command options
if ( ! \MongoDB\server_supports_feature($server, self::$wireVersionForCursor)) { if ( ! $isCursorSupported) {
return new Command($cmd); return new Command($cmd);
} }
......
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