Opening this as an offshoot of #1825018: CiviCRM 4.2 and higher require more SQL privileges than past versions or binary logging disabled

Migrations are failing with the following error:

Drush command terminated abnormally due to an unrecoverable error. Error: Cannot redeclare class CRM_Core_ClassLoader in
/. . . /sites/all/modules/civicrm/CRM/Core/ClassLoader.php, line 36

Setups tested so far that have given the error:
D7.15 + Civi 4.2.1 to D7.15 + Civi 4.2.2
D7.17 + Civi 4.2.6 to D7.17 + Civi 4.2.6
D7.14 + Civi 4.2.2 to D7.18 + Civi 4.2.6
D7.15 + Civi 4.2.1 to D7.19 + Civi 4.2.7
D7.15 + Civi 4.2.7 to D7.19 + Civi 4.2.7

I've test the last setup with binary logging and redis disabled but still received the error.

Comments

bgm’s picture

I modified the tests to install php5-xdebug, so that we can get a backtrace:

out: Drush command terminated abnormally due to an unrecoverable error.   [error]
out: Error: Cannot redeclare class CRM_Core_ClassLoader in /var/aegir/platforms/civicrm42d7/sites/all/modules/civicrm/CRM/Core/ClassLoader.php, line 36
out: Output from failed command : [error]
out:
out: Fatal error: Cannot redeclare class CRM_Core_ClassLoader in /var/aegir/platforms/civicrm42d7/sites/all/modules/civicrm/CRM/Core/ClassLoader.php on line 36

out: Call Stack:
out:     0.0029     735464   1. {main}() /usr/share/drush/drush.php:0
out:     0.0385    3769256   2. drush_main() /usr/share/drush/drush.php:41
out:     0.3993   18068536   3. drush_dispatch() /usr/share/drush/drush.php:101
out:     0.3998   18069008   4. call_user_func_array() /usr/share/drush/includes/command.inc:214
out:     0.3998   18069496   5. drush_command() /usr/share/drush/includes/command.inc:0
out:     0.4627   18186800   6. _drush_invoke_args() /usr/share/drush/includes/command.inc:806
out:     3.5138   18523008   7. call_user_func_array() /usr/share/drush/includes/command.inc:134
out:     3.5139   18523520   8. drush_provision_drupal_post_provision_deploy() /usr/share/drush/includes/command.inc:0
out:     8.0280   44738520   9. _provision_drupal_rebuild_caches() /usr/share/drush/commands/provision/platform/deploy.provision.inc:166
out:     8.0281   44738792  10. drush_include_engine() /usr/share/drush/commands/provision/platform/provision_drupal.drush.inc:273
out:     8.0288   44751344  11. drush_include() /usr/share/drush/includes/drush.inc:137
out:     8.0294   44762768  12. include_once('/usr/share/drush/commands/provision/platform/drupal/clear_7.inc') /usr/share/drush/includes/drush.inc:42
out:     9.2618   45780112  13. menu_rebuild() /usr/share/drush/commands/provision/platform/drupal/clear_7.inc:20
out:     9.2638   45781488  14. menu_router_build() /var/aegir/platforms/civicrm42d7_other/includes/menu.inc:2712
out:     9.2939   47226424  15. call_user_func() /var/aegir/platforms/civicrm42d7_other/includes/menu.inc:2743
out:     9.2940   47226424  16. user_menu() /var/aegir/platforms/civicrm42d7_other/includes/menu.inc:0
out:     9.2941   47288992  17. _user_categories() /var/aegir/platforms/civicrm42d7_other/modules/user/user.module:1790
out:     9.2941   47289136  18. module_invoke_all() /var/aegir/platforms/civicrm42d7_other/modules/user/user.module:3323
out:     9.2944   47293296  19. call_user_func_array() /var/aegir/platforms/civicrm42d7_other/includes/module.inc:857
out:     9.2944   47293664  20. civicrm_user_categories() /var/aegir/platforms/civicrm42d7_other/includes/module.inc:0
out:     9.2944   47293664  21. civicrm_initialize() /var/aegir/platforms/civicrm42d7_other/sites/all/modules/civicrm/drupal/civicrm_user.inc:136
out:     9.2958   47391256  22. include_once('/var/aegir/platforms/civicrm42d7_other/sites/civicrm42d7-test-migrate.aegir.example.com/civicrm.settings.php')
out: /var/aegir/platforms/civicrm42d7_other/sites/all/modules/civicrm/drupal/civicrm.module:296
out:     9.2966   47421288  23. require_once('/var/aegir/platforms/civicrm42d7/sites/all/modules/civicrm/CRM/Core/ClassLoader.php')
out: /var/aegir/platforms/civicrm42d7_other/sites/civicrm42d7-test-migrate.aegir.example.com/civicrm.settings.php:300
bgm’s picture

I think the best way to debug this, would be to apply a patch to the civicrm.settings.php *template* in CiviCRM (via makefile), so that it outputs the values of $civicrm_root and the $include_path.

This type of error has come up now and again, so it will be useful to have it automated to debug it easily in future versions.

bgm’s picture

StatusFileSize
new996 bytes

Here is a patch for the civicrm.settings.php template, so that we can have more debug information when running tests.

Attaching it here, so that I can refer to it from the tests makefile.

bgm’s picture

Patch should use drush_log() with 'ok' to be vislble.. new patch attached.

bgm’s picture

Status: Active » Needs review

I committed a patch that uses the provision_deploy() hook to regenerate the civicrm.settings.php file earlier.

The backtrace incidates that in the post_provision hook for drupal, it flushes the cache. Since CiviCRM 4.2, clearning the cache invokes some user hook that then tries to initialize CiviCRM, hence the error, since the civicrm.settings.php was still pointing to the old platform.

I can the tests and it seems to work. Also added tests on CiviCRM 4.3 alpha.

Can someone who had the error please confirm if it solves their issue as well? (if not, install php5-xdebug in order to get a backtrace)

urlisse’s picture

Status: Fixed » Needs review

I pulled the latest provision_civicrm version from git and I no longer receive the "Cannot redeclare class CRM_Core_ClassLoader" error during migration on a website that used to fail this operation. It was a D6 site running CiviCRM 4.1.7.

We have a few other sites to migrate. By the end of next week, we should take care of a few other test cases...

Thanks bgm.

bgm’s picture

Status: Needs review » Fixed
Poieo’s picture

Status: Needs review » Fixed

This release has solved the issue for me as well.

Status: Fixed » Closed (fixed)

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