When running drush mongodb-cli or mongodb-query, "mongodb://" in the host breaks the shell.
eg:

drush mdbc
MongoDB shell version: 2.2.2
connecting to: mongodb://127.0.0.1/XXXX
Fri Mar  1 02:45:59   Assertion failure _setName.size() src/mongo/client/dbclientinterface.h 209
...

It looks like the PECL mongo client can handle the 'mongodb://' in the host, but works just as well without it (AFAICT); whereas the js shell client chokes on it and spits out a pretty unhelpful error message.

line 62 in the README.txt: 'host' => 'mongodb://USER:PASS@localhost',

At first I was thinking we could just remove the scheme from the host, but that looks necessary to support the user and pass authentication. So I've borrowed the relevant db url parsing code from drush's sitealias include for the upcoming patch which should work w/ or w/o the scheme and support user and pass in the mongo shell too.

Comments

tloudon’s picture

and here's the patch.

mcrittenden’s picture

Status: Active » Needs review
mwisner’s picture

The patch provided in #1 resolved the issue for me.

Ubuntu 12.04 / Mongodb installed via pecl.

Anonymous’s picture

Issue summary: View changes
StatusFileSize
new1.39 KB

The patch from #1 works fine except for the fact that it drops the port number and that it ignores the cases when parse_url() returns FALSE.

Here is a patch that generates the proper database address syntax and arguments.

fgm’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#1930822: drush mongo shell host scheme error

Part of this has already been committed while working on #1823478: Drush command line commands should support connections to replica sets.

Marking this issue as duplicate since it is more recent, this patch should be merged with the one on #1823478 because the former doesn't address the case of replica sets, while the latter doesn't address the case of authenticated connections, but both target the same issue.