Not sure if it's because of something I'm doing wrong, but I just installed the latest version of the 2.x dev migrate module and am getting the error:

Fatal error: Uncaught exception 'DatabaseConnectionNotDefinedException' with message 'The specified database connection is not defined: default' in ...

default /is/ defined in settings.php and the site works normally.

I get the exception on admin/migrate/BeerTerm (and every other link on the admin/migrate page).

Comments

hadsie’s picture

Tracking down this one, it appears that in the UI for whatever reason dbtng_init() is not getting executed early enough. Setting the weight of the dbtng module to -1 fixes it.

In my setup I have og enabled, and as long as dbtng's weight is less than og then everything works fine. It appears that within og_init() there's a (indirect) call to menu_get_item() and triggers migration_load() in migrate_ui.module prematurely (this is due to the menu item: admin/migrate/%migration).

I'm not sure of a way to fix this or any better workaround than setting dbtng's weight to -1 at this point. But it seems like migration_load and migration_title shouldn't be called if dbtng hasn't been loaded yet.

moshe weitzman’s picture

Status: Active » Postponed (maintainer needs more info)

I have og as well and am not seeing an error. might be fixed in latest autoload+dbtng+migrate

hadsie’s picture

Status: Postponed (maintainer needs more info) » Fixed

I have a feeling that this client may have hacked the OG module to do some funky path stuff, which would explain this. I haven't compared against a stock copy of OG yet but I'm quite certain this is what's happened now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Ivo.Radulovski’s picture

any solution here? had the same error....

sadist’s picture

Status: Closed (fixed) » Active

I am still getting this error regardless of which version or migrate or dbtng modules I installed. I'm able to produce this error by just running cron, right after migrate.module is enabled.

PS: this is with fresh Drupal installation

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

How are you running cron? Where precisely do you see the message? I cannot reproduce this with either drush cron or invoking cron from the status report page.

sadist’s picture

Drupal Cron, from the status page. My web server is running Php by CGi. Not sure if that matter.

mikeryan’s picture

Ugh. I don't know of a specific reason it would matter (does CGI affect the PHP autoload behavior?), but CGI in 2011? Your webhost needs to join the 21st century... Has anyone seen this issue in a non-CGI environment?

catapultparlor’s picture

i'm getting this error.

Steps:
Installed and enabled autoload & dbtng.
Installed and enabled migrate.

Realized that I had installed wrong version of autoload.
Had some errors trying to disable Migrate.

Uninstalled autoload, dbtng and migrate and deleted from server.
update.php, cron, etc, no errors.

Installed and enabled each, one at a time, and ran update.php each time just in case.

When I ran update.php after seemingly successfully installing Migrate, i received the above error while trying to run the update script.
After the "0 of 0" thinking happened.

This is on a Dreamhost server that should be up-to-date.

sadist’s picture

sorry, I posted that using mobile and didn't get the message across. What I meant was PHP is installed as CGI/SuExec, not inside 'cgi-bin' folder for CGI/Perl scripts. I believe it offers better server security.

jcfiala’s picture

I'm getting this error when I'm running update.php (via the web browser) and it's a real pain. The error I"m getting is this:

Uncaught exception 'DatabaseConnectionNotDefinedException'
with message 'The specified database connection is not defined: default'
in /var/aegir/hpdb/sites/all/modules/contrib/dbtng/database/database.inc:1516
Stack trace:
#0 /var/aegir/hpdb/sites/all/modules/contrib/dbtng/database/database.inc(1317): Database::openConnection('default', 'default')
#1 /var/aegir/hpdb/sites/all/modules/contrib/dbtng/dbtng.module(179): Database::getConnection('default')
#2 /var/aegir/hpdb/sites/all/modules/contrib/migrate/migrate.module(102): db_select('migrate_status', 'ms')
#3 [internal function]: migrate_flush_caches()
#4 /var/aegir/hpdb/includes/module.inc(483): call_user_func_array('migrate_flush_c...', Array)
#5 /var/aegir/hpdb/includes/common.inc(3775): module_invoke_all('flush_caches')
#6 /var/aegir/hpdb/update.php(288): drupal_flush_all_caches()
#7 /var/aegir/hpdb/includes/batch.inc(302): update_finished(true, Array, Array)
#8 /var/aegir/hpdb/includes/batch.inc(43): _batch_finished()
#9 /var/aegir/hpdb/update.php(679): in /var/aegir/hpdb/sites/all/modules/contrib/dbtng/database/database.inc on line 1516

I'm guessing that migrate_flush_caches() is trying to use dbtng, but since we've come in from update.php, dbtng doesn't know about the database. I tried setting the dbtng module to have weight -1, but that doesn't seem to have helped.

Yeah... I just put 'dbtng_init()' in at line 96, at the start of migrate_flush_caches(), and the problem went away when I did an update.php again. So it really does seem to be that during an update.php, the hook_init isn't being called... but whether that's a problem with migrate, dbtng, or core, I'm not sure.

moshe weitzman’s picture

Status: Postponed (maintainer needs more info) » Active

For some obscure reason we don't fire init and friends on update.php so the proposed fix sounds right to me.

jcfiala’s picture

Status: Active » Postponed (maintainer needs more info)

Ah, yes, well, there you go. _drupal_boostrap_full(), in common.inc:

  // Let all modules take action before menu system handles the request
  // We do not want this while running update.php
  if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
    module_invoke_all('init');
  }

So... Hm. Maybe this is a dbtng problem.

jcfiala’s picture

Status: Postponed (maintainer needs more info) » Active

And I posted my response around the same time as moshe, without doing a refresh. Never mind!

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

Well, I was going to go ahead and insert the dbtng_init(), but... no such function. It's been removed from the dbtng module since the alpha7 release. Can anyone who is seeing this problem update to the latest dbtng dev release and see if you still have trouble?

Thanks.

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Fixed

No further reports, I'm assuming for now this is an artifact of older versions of dbtng.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.