浏览代码

Fix parameters for command method

Andreas Braun 10 年之前
父节点
当前提交
1fc7f8dfc3
共有 3 个文件被更改,包括 8 次插入8 次删除
  1. 3 3
      lib/Mongo/MongoCollection.php
  2. 3 3
      lib/Mongo/MongoDB.php
  3. 2 2
      tests/Alcaeus/MongoDbAdapter/MongoDBTest.php

+ 3 - 3
lib/Mongo/MongoCollection.php

@@ -150,7 +150,7 @@ class MongoCollection
 
         $command += $options;
 
-        return $this->db->command($command, [], $hash);
+        return $this->db->command($command);
     }
 
     /**
@@ -241,7 +241,7 @@ class MongoCollection
             'full'     => $scan_data,
         ];
 
-        return $this->db->command($command, [], $hash);
+        return $this->db->command($command);
     }
 
     /**
@@ -598,7 +598,7 @@ class MongoCollection
             $command['group']['finalize'] = $condition['finalize'];
         }
 
-        return $this->db->command($command, [], $hash);
+        return $this->db->command($command);
     }
 
     /**

+ 3 - 3
lib/Mongo/MongoDB.php

@@ -166,7 +166,7 @@ class MongoDB
      */
     public function getProfilingLevel()
     {
-        $result = $this->command(['profile' => -1], [], $hash);
+        $result = $this->command(['profile' => -1]);
 
         return ($result['ok'] && isset($result['was'])) ? $result['was'] : 0;
     }
@@ -180,7 +180,7 @@ class MongoDB
      */
     public function setProfilingLevel($level)
     {
-        $result = $this->command(['profile' => $level], [], $hash);
+        $result = $this->command(['profile' => $level]);
 
         return ($result['ok'] && isset($result['was'])) ? $result['was'] : 0;
     }
@@ -369,7 +369,7 @@ class MongoDB
      * The resulting document's structure depends on the command,
      * but most results will have the ok field to indicate success or failure and results containing an array of each of the resulting documents.
      */
-    public function command(array $data, $options, &$hash)
+    public function command(array $data, $options = [], &$hash = null)
     {
         try {
             $cursor = new \MongoCommandCursor($this->connection, $this->name, $data);

+ 2 - 2
tests/Alcaeus/MongoDbAdapter/MongoDBTest.php

@@ -27,7 +27,7 @@ class MongoDBTest extends TestCase
     public function testCommand()
     {
         $db = $this->getDatabase();
-        $this->assertEquals(['ok' => 1], $db->command(['ping' => 1], [], $hash));
+        $this->assertEquals(['ok' => 1], $db->command(['ping' => 1]));
     }
 
     public function testCommandError()
@@ -39,7 +39,7 @@ class MongoDBTest extends TestCase
             'code' => 13,
         ];
 
-        $this->assertEquals($expected, $db->command(['listDatabases' => 1], [], $hash));
+        $this->assertEquals($expected, $db->command(['listDatabases' => 1]));
     }
 
     public function testReadPreference()