Pretty simple fix. Note #1004850: DBTNG databaseType is confusing is broken too.

CommentFileSizeAuthor
#17 drush_databasetype.patch1.92 KBchx
#16 drush_databasetype.patch1.29 KBchx
#14 revert-fix.patch611 bytesbherlig
#5 p.patch1.96 KBchx
#3 p.patch1.95 KBchx
#2 p.patch2.84 KBchx
#1 p.patch1.11 KBchx
p.patch929 byteschx

Comments

chx’s picture

StatusFileSize
new1.11 KB

Moved a few lines down , after the PDO check.

chx’s picture

StatusFileSize
new2.84 KB

If I add this then even drush si and sqlc works. It smells like a utility function to me but not familiar enough with the drush customs on where to put this.

chx’s picture

StatusFileSize
new1.95 KB

W/o the first hunk, i filed a sep issue for that.

greg.1.anderson’s picture

Code looks good to me. Regarding the utility function, it could be placed in includes/drush.inc, but since it is only a few lines, I don't think that is necessary.

chx’s picture

StatusFileSize
new1.96 KB

Well it's wrong, i misunderstood: driver is the Drupal driver, databaseType is the PDO driver. Easy fix.

moshe weitzman’s picture

Status: Needs review » Needs work

Please remove that static cache. Those have eaten drupal alive and they aren't welcome here. Caller can do own cacheing if he needs to call this over and over again.

Otherwise, looks good.

chx’s picture

really? this is the kind that would not receive the drupal_static treatment even in Drupal as it can not change during a request (or in fact, evah)

moshe weitzman’s picture

I looked at postgres driver and it takes $connection_options in its contstructor. This passes the string 'databaseType' as $connection_options and caches the result. That does not look right.

moshe weitzman’s picture

Status: Needs work » Fixed

committed without uneeded static cache.

greg.1.anderson’s picture

Priority: Normal » Critical
Status: Fixed » Active

This patch causes sql-sync to catch fire and crash. Drush isn't bootstrapped, so it can't include the desired files. I didn't have time to try to fix it; I just backed out the last change, and sql-sync worked again. Did not commit; HEAD is still broken.

jonhattan’s picture

I've just seen this

Strict warning: call_user_func() expects parameter 1 to be a valid callback, non-static method                     [error]
DatabaseConnection_mysql::databaseType() should not be called statically in drush_valid_db_credentials() (line 1218
of /usr/src/drush-HEAD/includes/environment.inc).
moshe weitzman’s picture

Sorry. Please roll this back. Am offline until sun night

jonhattan’s picture

Priority: Critical » Normal
Status: Active » Needs work

reverted.

bherlig’s picture

StatusFileSize
new611 bytes

The revert removed some existing lines, so currently the SQL commands don't work for me (D6 installation using mysql).

Note that in 1.92 of sql.drush.inc (Diff) removes the following lines:

if (is_null($db_spec)) {
    $db_spec = _drush_sql_get_db_spec();
}

With that, the DB-driver isn't properly retrieved, but is returned as null. This becomes apparent when executing sql-connect:

bherlig@eltanin:/var/www/drupal/sites/g21$ /tmp/drush/drush.php sql-connect
 --database=origo_g21 --host=localhost --user=origo_331 --password=origo

Note that the command is missing.

Patch to fix the revert is attached for your consideration.

jonhattan’s picture

applied. thanks bherlig.

chx’s picture

Version: » All-versions-4.x-dev
Status: Needs work » Needs review
StatusFileSize
new1.29 KB

Argh! this wasnt fixed?

chx’s picture

StatusFileSize
new1.92 KB

SQL commands now work too.

moshe weitzman’s picture

Someone who needs this should step up for a code review and verify that it works. Otherwise, it won't get much attention from maintainers.

greg.1.anderson’s picture

Version: All-versions-4.x-dev » 8.x-6.x-dev
Status: Needs review » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If desired, you may copy this bug to our Github project and then post a link here to the new issue. Please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.