Skip to content

Commit 3b3deb8

Browse files
committed
Fix wrong return type for operations
1 parent a3c0584 commit 3b3deb8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Operation/DropSearchIndex.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
namespace MongoDB\Operation;
1919

2020
use MongoDB\Driver\Command;
21+
use MongoDB\Driver\Cursor;
2122
use MongoDB\Driver\Exception\CommandException;
2223
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
2324
use MongoDB\Driver\Server;
@@ -57,7 +58,7 @@ public function __construct(private string $databaseName, private string $collec
5758
* @throws UnsupportedException if write concern is used and unsupported
5859
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
5960
*/
60-
public function execute(Server $server): void
61+
public function execute(Server $server): Cursor
6162
{
6263
$cmd = [
6364
'dropSearchIndex' => $this->collectionName,
@@ -69,7 +70,7 @@ public function execute(Server $server): void
6970
}
7071

7172
try {
72-
$server->executeCommand($this->databaseName, new Command($cmd));
73+
return $server->executeCommand($this->databaseName, new Command($cmd));
7374
} catch (CommandException $e) {
7475
// Drop operations are idempotent. The server may return an error if the collection does not exist.
7576
if ($e->getCode() !== self::ERROR_CODE_NAMESPACE_NOT_FOUND) {

src/Operation/UpdateSearchIndex.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
namespace MongoDB\Operation;
1919

2020
use MongoDB\Driver\Command;
21+
use MongoDB\Driver\Cursor;
2122
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
2223
use MongoDB\Driver\Server;
2324
use MongoDB\Exception\InvalidArgumentException;
@@ -65,7 +66,7 @@ public function __construct(private string $databaseName, private string $collec
6566
* @throws UnsupportedException if write concern is used and unsupported
6667
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
6768
*/
68-
public function execute(Server $server): void
69+
public function execute(Server $server): Cursor
6970
{
7071
$cmd = [
7172
'updateSearchIndex' => $this->collectionName,
@@ -77,6 +78,6 @@ public function execute(Server $server): void
7778
$cmd['comment'] = $this->options['comment'];
7879
}
7980

80-
$server->executeCommand($this->databaseName, new Command($cmd));
81+
return $server->executeCommand($this->databaseName, new Command($cmd));
8182
}
8283
}

0 commit comments

Comments
 (0)