File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 17
17
*/
18
18
class DropCollection implements Executable
19
19
{
20
+ private static $ errorMessageNamespaceNotFound = 'ns not found ' ;
20
21
private $ databaseName ;
21
22
private $ collectionName ;
22
23
@@ -44,7 +45,11 @@ public function execute(Server $server)
44
45
try {
45
46
$ cursor = $ server ->executeCommand ($ this ->databaseName , new Command (array ('drop ' => $ this ->collectionName )));
46
47
} catch (DriverRuntimeException $ e ) {
47
- if ($ e ->getMessage () === 'ns not found ' ) {
48
+ /* The server may return an error if the collection does not exist.
49
+ * Check for an error message (unfortunately, there isn't a code)
50
+ * and NOP instead of throwing.
51
+ */
52
+ if ($ e ->getMessage () === self ::$ errorMessageNamespaceNotFound ) {
48
53
return (object ) ['ok ' => 0 , 'errmsg ' => 'ns not found ' ];
49
54
}
50
55
You can’t perform that action at this time.
0 commit comments