This is a recurrent problems for me, and it may or may not be module-specific as it also happenes with Views (but only those two, so far).

I get this error by:
-Download fresh install of Drupal and set i up
-install Views
-install Backup and Migrate.

Now if I try 'drush cc all' I get this error:

Fatal error: Cannot redeclare class backup_migrate_destination_db in /Users/henrikakselsen/sites/drupal-7.8/sites/all/modules/backup_migrate/includes/destinations.db.inc on line 294
Drush command terminated abnormally due to an unrecoverable error.                                                   [error]
Error: Cannot redeclare class backup_migrate_destination_db in
/Users/henrikakselsen/sites/drupal-7.8/sites/all/modules/backup_migrate/includes/destinations.db.inc, line 294
Macintosh:drupal-7.8 henrikakselsen$ mate /Users/henrikakselsen/sites/drupal-7.8/sites/all/modules/backup_migrate/includes/destinations.db.inc

I've seen a lot others having this issue, but mostly with Views. There seems to be a duplicate call to declare classes somewhere in the system, but I'm hardpressed to know where to start the troubleshoot on this one. I'll post an update if I make progress on it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

henrikakselsen’s picture

Actually, I don't even need to install Views to get the error message. A clean Drupal-install + backup migrate is enough to get the error on a drush cc all.

ohthehugemanatee’s picture

Thank goodness - I thought I was the only one.

Oddly enough, this only happens when I enable backup_migrate with drush. I can enable it just fine through the GUI, which makes me suspect something wrong with the php configuration drush is using.

alesr’s picture

Is there a known solution for this?
I also have this issue with drush and backup and migrate module, but didn't experienced it in the first 3-4 weeks using both modules together.
Doing 'sudo drush cc all' works, but it's not the best soulution, you know.

henrikakselsen’s picture

Try to use sudo with all your drush commands to see if that does the trick. Similar discussion here: http://drupal.org/node/1296594

jwilson3’s picture

Sudo works for me, very annoying. So much so that I've created a bash alias for my .bashrc file.

alias drush='sudo drush'
Danny Englander’s picture

I've had my dev site up and running using Drush for weeks and never had this issue until today when I updated a single module on my site, Entity Translation. After I updated that module, I started to experience the issue described here. I am just wondering if anyone else here is using that module? I can use sudo drush cc all but get asked for my password every time.

jwilson3’s picture

Update to my previous comment #5, the alias for sudo was so annoying that I tracked down the root cause of the issue (in my case) to be the capitalization of the project folder I was working in. I changed the faulty capitalization and the problems went away.

Note that there are a couple different reasons this could be happening. Another one includes having the same module located in two different places within a single Drupal installation. Both of these issues are discussed on #644126: drush loads duplicate command files.

ronan’s picture

Status: Active » Closed (works as designed)

AHA! A solution. Thanks @jwilson3.

Everybody having this issue please read #7 and the post it links to.

Danny Englander’s picture

As far as the capitalization of the project folder name goes, simply changing it to lowercase is not an option for me as the name of my folder derives from the Git Repo name which happens to be capitalized. I do not have any duplicated modules either but as I mentioned I did not have this issue until I updated Entity Translation. I suppose I should try to dig in to that and perhaps file an issue there if I have time to run some definitive tests.

ohthehugemanatee’s picture

Reporting that this issue still exists. I have a capital letter in the name of the folder ABOVE my project folder (~/Sites/sitename), and no duplicate module folders anywhere. I only seem to have this problem on my local install (MAMP), but then I don't use drush directly on the dev server very often so it's possible it's there as well. Anyway, a capital letter in a folder name is a stupid reason to break so badly...

If you're really frustrated, you can comment out the offending function from backup/migrate. The problem comes from backup_migrate_destination_db, which is the province of /includes/destinations.db.inc . It provides the ability to backup directly to another database, ie a database that exists solely for keeping your backup. A more specific version is /includes/destinations.db.mysql.inc , which does the same when the backup holding DB is a mysql db. Nice and convenient, but for those of us who just use this module for convenient DB/filesdir downloads, it's not critical. comment out lines 55-68 of includes/destinations.inc (or just apply the attached patch), and you lose the error. It's not a real fix, but it solves the problem for now.

EDIT: Or just read the linked thread above ( http://drupal.org/node/1296594#comment-5443454 ), and learn that the problem is MAMP using a different version of PHP than Drush... which is a problem in your environment that should be fixed anyway.

kenorb’s picture

Status: Closed (works as designed) » Needs review
kenorb’s picture

Status: Needs review » Needs work
kenorb’s picture

Assigned: henrikakselsen » Unassigned
kenorb’s picture

Version: 7.x-2.2 » 7.x-2.7

Backtrace:

$ time drush -y cc all
PHP Fatal error:  Cannot redeclare class backup_migrate_destination_db in sites/all/modules/backup_migrate/includes/destinations.db.inc on line 298
PHP Stack trace:
PHP   1. {main}() /usr/lib/php/pear/drush/drush.php:0
PHP   2. drush_main() /usr/lib/php/pear/drush/drush.php:16
PHP   3. _drush_bootstrap_and_dispatch() /usr/lib/php/pear/drush/drush.php:61
PHP   4. drush_dispatch() /usr/lib/php/pear/drush/drush.php:92
PHP   5. call_user_func_array() /usr/lib/php/pear/drush/includes/command.inc:175
PHP   6. drush_command() /usr/lib/php/pear/drush/includes/command.inc:175
PHP   7. _drush_invoke_hooks() /usr/lib/php/pear/drush/includes/command.inc:208
PHP   8. call_user_func_array() /usr/lib/php/pear/drush/includes/command.inc:334
PHP   9. drush_cache_command_clear() /usr/lib/php/pear/drush/includes/command.inc:334
PHP  10. drush_op() /usr/lib/php/pear/drush/commands/core/cache.drush.inc:91
PHP  11. call_user_func_array() /usr/lib/php/pear/drush/includes/drush.inc:798
PHP  12. drush_cache_clear_both() /usr/lib/php/pear/drush/includes/drush.inc:798
PHP  13. drupal_flush_all_caches() /usr/lib/php/pear/drush/commands/core/cache.drush.inc:253
PHP  14. menu_rebuild() includes/common.inc:7442
PHP  15. menu_router_build() includes/menu.inc:2713
PHP  16. call_user_func() includes/menu.inc:2744
PHP  17. backup_migrate_menu() includes/menu.inc:2744
PHP  18. backup_migrate_crud_menu() sites/all/modules/backup_migrate/backup_migrate.module:159
PHP  19. backup_migrate_crud_type_load() sites/all/modules/backup_migrate/includes/crud.inc:58
PHP  20. backup_migrate_item->__construct() sites/all/modules/backup_migrate/includes/crud.inc:46
PHP  21. backup_migrate_profile->get_default_values() sites/all/modules/backup_migrate/includes/crud.inc:235
PHP  22. _backup_migrate_profile_default_profile() sites/all/modules/backup_migrate/includes/profiles.inc:206
PHP  23. backup_migrate_filters_settings_default() sites/all/modules/backup_migrate/includes/profiles.inc:163
PHP  24. backup_migrate_filters_invoke_all() sites/all/modules/backup_migrate/includes/filters.inc:166
PHP  25. call_user_func_array() sites/all/modules/backup_migrate/includes/filters.inc:90
PHP  26. backup_migrate_filter_backup_restore->backup_settings_default() sites/all/modules/backup_migrate/includes/filters.inc:90
PHP  27. backup_migrate_get_destinations() sites/all/modules/backup_migrate/includes/filters.backup_restore.inc:37
PHP  28. backup_migrate_crud_get_items() sites/all/modules/backup_migrate/includes/destinations.inc:188
PHP  29. backup_migrate_item->all_items() sites/all/modules/backup_migrate/includes/crud.inc:197
PHP  30. backup_migrate_backup_migrate_destinations() sites/all/modules/backup_migrate/includes/crud.inc:624
PHP  31. backup_migrate_filters_invoke_all() sites/all/modules/backup_migrate/includes/destinations.inc:142
PHP  32. call_user_func_array() sites/all/modules/backup_migrate/includes/filters.inc:90
PHP  33. backup_migrate_filter_backup_restore->destinations() sites/all/modules/backup_migrate/includes/filters.inc:90
PHP  34. backup_migrate_filter_backup_restore->_get_destination_types() sites/all/modules/backup_migrate/includes/filters.backup_restore.inc:22
PHP  35. require_once() sites/all/modules/backup_migrate/includes/filters.backup_restore.inc:162
PHP  36. backup_migrate_include() sites/all/modules/backup_migrate/includes/destinations.db.mysql.inc:3
liza’s picture

am getting the same error message as #14 when i run cron from the site. no errors when i run it from drush. am on Drupal 7.23 and BAM 7.x-2.7.

idiaz.roncero’s picture

Same error here with Drush, MAMP and Mac, even if I aplied many of the suggested solutions:

  • MAMP and Drush use the same PHP version, which is > 5.3.3
  • For me, Backup & Migrate works fine when installed from the UI
  • However, the "Cannot redeclare class backup_migrate_destination_db" error appears (and crashes) almost almost every drush command
  • When the error lets the drush command do its job, it usually causes either the site (on MAMP, remember) to crash or the modules to appear listed but not working (you can't access its configuration, options, etc...)
  • Sudo seems to bypass the problem, but this is not a solution
  • Uninstalling B&M makes drush work perfectly

This is only FYI and to help identify the causes of the problem. I tried many things but I have no clue.

amcc’s picture

If you're on a mac you are probably running your site from within the Sites directory which has a capital S.

My problem stemmed from not typing a capital s when cd'ing into the site directory

so 'cd ~/sites/mysite.dev' gave me errors
but 'cd ~/Sites/mysite.dev' fixed it

heathergaye’s picture

Issue summary: View changes

Thankyou, #17! Worked for me. How on earth did you work that out??

amcc’s picture

Just swore at the computer a lot and tried to work out where the hell i had a capital (as mentioned above). I think this might be the root of quite a few issues here.

jaymallison’s picture

lol @#17 - I was in sites instead of Sites as well. Ridiculous.

jwilson3’s picture

#17++ Yes. the question is why is drush case sensitive on an os that is case insensitive.

BassPlaya’s picture

Version: 7.x-2.7 » 7.x-3.0
Issue tags: +drush fatal error

#17 doesn't work for me. I'm using: /Users/Me/Sites/www.d7sandbox.dev

I've disabled backup_migrate, uninstalled it, tossed the entire directory out, downloaded it and then enabled it through the Drush command "drush en backup_migrate".
This gave me the following error:

MyName-MacBook-Pro:www.d7sandbox.dev Me$ drush en backup_migrate
The following extensions will be enabled: backup_migrate
Do you really want to continue? (y/n): y
PHP Fatal error: Cannot redeclare class backup_migrate_source_db in /Users/Me/Sites/www.d7sandbox.dev/sites/all/modules/backup_migrate/includes/sources.db.inc on line 318

Fatal error: Cannot redeclare class backup_migrate_source_db in /Users/Me/Sites/www.d7sandbox.dev/sites/all/modules/backup_migrate/includes/sources.db.inc on line 318
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Cannot redeclare class backup_migrate_source_db in
/Users/Me/Sites/www.d7sandbox.dev/sites/all/modules/backup_migrate/includes/sources.db.inc,
line 318
MyName-MacBook-Pro:www.d7sandbox.dev Me$

jwilson3’s picture

/Users/Me

On my machine, it is /Users/me (lowercase).... maybe this makes a difference?

BassPlaya’s picture

@jwilson3 not really as I changed my own name in the code above to 'Me' simply for privacy reasons.
I have backup_migrate installed on a sandbox site and I don't get that error. Maybe it might have to do with 1) the version or 2) an update process which went awry. I'll investigate this a little further and come back to this.

BassPlaya’s picture

could it be because I'm using drush version: 7.0-dev that I'm still seeing this annoying message? And because of this message, it doesn't allow me to clear my caches, even more annoying.
Any help?

robbdavis’s picture

CD into Sites still didn't work for me. Drush 7.0-dev threw the Fatal error listed above. The only fix so far is to rename Sites to sites. If you're looking for an easy way to do that on a Mac, try Path Finder... it's free for 30 days and it's actually a great finder replacement.

R.

Stolzenhain’s picture

Just so I understand this correctly: cd'ing to lower-cased folders in the OSX terminal doesn't fix the issue as long as you have original uppercase folder filenames?

fb-multimedia’s picture

I was using a path:
'/users/myaccount/Sites/' in my drush aliases.drushrc.php config.
changed it to :
'/Users/myaccount/Sites/ '
fix the issue.
So check the uppercase and lowercase to be exact on your path.
hope this help.

DamienMcKenna’s picture

Version: 7.x-3.0 » 7.x-3.x-dev
Status: Needs work » Needs review
FileSize
784 bytes

So it sounds like this is a "works as designed" issue caused by people running Drush commands on a different path than Drupal is using? Or maybe the DRUPAL_ROOT usage in backup_migrate_include_path() should be wrapped around drupal_realpath()?

henrikakselsen’s picture

yog_kulkarni’s picture

Check uppercase and lowercase in your path. I checked the case and gave the exact path. It worked.

couturier’s picture

Can anyone verify if this is still an issue with the 7.x-3.2 version released September 27, 2017?

DamienMcKenna’s picture

DamienMcKenna’s picture

Status: Needs review » Postponed