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 1717 */
1818class DropCollection implements Executable
1919{
20+ private static $ errorMessageNamespaceNotFound = 'ns not found ' ;
2021 private $ databaseName ;
2122 private $ collectionName ;
2223
@@ -44,7 +45,11 @@ public function execute(Server $server)
4445 try {
4546 $ cursor = $ server ->executeCommand ($ this ->databaseName , new Command (array ('drop ' => $ this ->collectionName )));
4647 } 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 ) {
4853 return (object ) ['ok ' => 0 , 'errmsg ' => 'ns not found ' ];
4954 }
5055
You can’t perform that action at this time.
0 commit comments