CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • civicrm_class_loader debugging
Pages: [1]

Author Topic: civicrm_class_loader debugging  (Read 2666 times)

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
civicrm_class_loader debugging
January 20, 2014, 10:00:50 am
I had a lengthy battle trying to resync my production database back to my development environment this week where I kept getting that nasty WSOD with the "PHP Fatal error:  Cannot redeclare class CRM_Core_ClassLoader" issue.

All the testing I was doing as well as searching around the forum was confirming that the issue was related to this kind of migration. In the end, I found that to fix I  had to approach it the following way:

- pull down the db
- manually flush the drupal cache
- delete the variable civicrm_class_loader from variable table
- issue drush cc all
- I was still getting the WSOD, which at this point didn't make sense because the drush cc had been successful where previously it had failed and output my error. So the one other addition I had added was the civicrm_multiday_event module. I then issued drush dis civicrm_multiday_event -y, then again cleared the cache, and then finally everything was good to go. Then re-enabled civicrm_multiday_event without a problem.

I want to try to pinpoint what the issue is and try to help figure out a way to make this easier. I'm on 4.4.3.

I found this on github https://github.com/civicrm/civicrm-drupal/pull/88 which lead me to http://issues.civicrm.org/jira/browse/CRM-13737 that suggests the civicrm_class_loader variable was just added in CiviCRM 4.4 a couple months ago.

So I'm trying to determine:
- is there some kind of code I could add as a patch to civicrm_multiday_event that would force a reload of that variable in these situations where it was holding everything up?
- or is this something that should be attempted to be handled on the civi side itself?
- Why did not just deleting that variable fix everything anyway?

Trying to wrap my head around where things are going wrong here, so pointers would be great. I have a setup where I'm ready to test/debug further. Thanks.

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: civicrm_class_loader debugging
February 07, 2014, 08:06:27 am
Hi Emily,

I opened an issue here:
http://issues.civicrm.org/jira/browse/CRM-14186

And opened a pull-request on CiviCRM 4.4 for Drupal 7:
https://github.com/civicrm/civicrm-drupal/pull/118

The patch uses the CiviCRM API to flush the cache (to reduce code duplication) and also explicitly deletes the Drupal variable that was causing the issue (this should probably be done somewhere in CiviCRM core, but wanted to at least have a fix for now, since this issue has been open for some time).

Can you review/test?

Thanks,
Mathieu
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
Re: civicrm_class_loader debugging
February 07, 2014, 09:15:25 am
Thanks, Mathieu! I will get this tested out on Monday and report back!

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
Re: civicrm_class_loader debugging
February 11, 2014, 06:25:32 am
I am posting comments on the Civi issue until we get it successfully tested/complete, then will post that update back here.

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
Re: civicrm_class_loader debugging
April 18, 2014, 11:28:03 am
Although this has been fixed, I have been testing with it and still see the issue on my server. I'm using memcache, and I think that's part of the issue. I no longer get fatal errors from this so that's certainly good. But almost daily I get a drush fatal error that will say:

Code: [Select]
HP Fatal error:  Cannot redeclare class CRM_Core_ClassLoader in/sites/all/modules/civicrm/CRM/Core/ClassLoader.php on line 36
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                    [error]
Error: Cannot redeclare class CRM_Core_ClassLoader in /sites/all/modules/civicrm/CRM/Core/ClassLoader.php, line 36
Drush was not able to start (bootstrap) Drupal.                                                                                                                                       [error]
Hint: This error can only occur once the database connection has already been successfully initiated, therefore this error generally points to a site configuration issue, and not a
problem connecting to the database.

I can't use drush cc all or drush vdel civicrm_class_loader to fix; the only way I can resolve is to reload memcache. Then all is fine until the next time.

I'm not sure what this means or if others are seeing this; I certainly have a temporary solution as it only affects drush, but it is less than ideal obviously.

Cyberflyer

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
  • It's a piece of cake, Ezra!!
    • North Star Community Foundation
  • CiviCRM version: 4.5.6
  • CMS version: Drupal 7.34 / Commons 7.x-3.20
  • MySQL version: 5.5.13
  • PHP version: 5.4.38
Re: civicrm_class_loader debugging
March 12, 2015, 03:18:22 pm
So I convinced my main critical client that moving to Drupal 7 would result in fewer bug hunts and more productivity.

I have 4 installs of Drupal Commons 7.x-3.20 running on Drupal core 7.34, with CiviCRM    4.5.6 running on two machines, a local MacBookPro running OS 10.6.8 and AN/MidPhase hosting running Linux.  Both are running PHP 5.4.38.

I selected 4.5.6 to get the latest features.

I decided that moving to drush would make me admin like a boss, so I've got drush 7-dev installed on both machines.

Set up the aliases to give me these four in a project:
Code: [Select]
  @nscf.work
  @nscf.test
  @nscf.stage
  @nscf.live

Then discovered that getting drush to ssh is a pain, but I solved that by building and installing a keypair and drush @nscf status gives all the right answers in a long list.  I figured I'd just start testing commands, so I did:
Code: [Select]
drush @nscf cc all
And got these errors:
Code: [Select]
nscf.live  >> Drush command terminated abnormally due to an unrecoverable error.   [error]

Error: Call to undefined function module_exists() in /home/nscfpin0/nscfd7-new/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php, line 868

nscf.live  >> Fatal error: Call to undefined function module_exists() in /home/nscfpin0/nscfd7-new/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 868

nscf.live is the remote install.

Code: [Select]
nscf.test  >> <span style='color: #ff0000'>
nscf.test  >> Fatal error: Cannot redeclare class CRM_Core_ClassLoader in /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/CRM/Core/ClassLoader.php on line 36
nscf.test  >>
nscf.test  >> Call Stack:
nscf.test  >>     0.0007     238856   1. {main}() /Users/username/.composer/vendor/drush/drush/drush.php:0
nscf.test  >>     0.0007     239416   2. drush_main() /Users/username/.composer/vendor/drush/drush/drush.php:11
nscf.test  >>     0.2526    8035080   3. Drush\Boot\DrupalBoot->bootstrap_and_dispatch() /Users/username/.composer/vendor/drush/drush/drush.php:71
nscf.test  >>     0.6716   43192744   4. drush_dispatch() /Users/username/.composer/vendor/drush/drush/lib/Drush/Boot/DrupalBoot.php:68
nscf.test  >>     0.8850   45957512   5. call_user_func_array:{/Users/username/.composer/vendor/drush/drush/includes/command.inc:178}() /Users/username/.composer/vendor/drush/drush/includes/command.inc:178
nscf.test  >>     0.8850   45957848   6. drush_command() /Users/username/.composer/vendor/drush/drush/includes/command.inc:178
nscf.test  >>     0.8854   45958640   7. _drush_invoke_hooks() /Users/username/.composer/vendor/drush/drush/includes/command.inc:210
nscf.test  >>     1.0018   53315728   8. call_user_func_array:{/Users/username/.composer/vendor/drush/drush/includes/command.inc:359}() /Users/username/.composer/vendor/drush/drush/includes/command.inc:359
nscf.test  >>     1.0018   53316064   9. drush_cache_command_clear() /Users/username/.composer/vendor/drush/drush/includes/command.inc:359
nscf.test  >>     1.0042   53319152  10. drush_op() /Users/username/.composer/vendor/drush/drush/commands/core/cache.drush.inc:143
nscf.test  >>     1.0043   53319640  11. drush_call_user_func_array() /Users/username/.composer/vendor/drush/drush/includes/drush.inc:687
nscf.test  >>     1.0043   53319736  12. drush_cache_clear_both() /Users/username/.composer/vendor/drush/drush/includes/drush.inc:700
nscf.test  >>     1.0071   53320912  13. drupal_flush_all_caches() /Users/username/.composer/vendor/drush/drush/commands/core/drupal/cache.inc:90
nscf.test  >>     3.9041   60136424  14. menu_rebuild() /Users/username/sites/nscf/nscfd7-test/includes/common.inc:7518
nscf.test  >>     3.9047   60137056  15. menu_router_build() /Users/username/sites/nscf/nscfd7-test/includes/menu.inc:2722
nscf.test  >>     4.0477   67060824  16. call_user_func:{/Users/username/sites/nscf/nscfd7-test/includes/menu.inc:2753}() /Users/username/sites/nscf/nscfd7-test/includes/menu.inc:2753
nscf.test  >>     4.0477   67060824  17. user_menu() /Users/username/sites/nscf/nscfd7-test/includes/menu.inc:2753
nscf.test  >>     4.0478   67103448  18. _user_categories() /Users/username/sites/nscf/nscfd7-test/modules/user/user.module:1821
nscf.test  >>     4.0478   67103560  19. module_invoke_all() /Users/username/sites/nscf/nscfd7-test/modules/user/user.module:3378
nscf.test  >>     4.0482   67106376  20. call_user_func_array:{/Users/username/sites/nscf/nscfd7-test/includes/module.inc:895}() /Users/username/sites/nscf/nscfd7-test/includes/module.inc:895
nscf.test  >>     4.0482   67106544  21. civicrm_user_categories() /Users/username/sites/nscf/nscfd7-test/includes/module.inc:895
nscf.test  >>     4.0482   67106600  22. civicrm_initialize() /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/drupal/civicrm_user.inc:131
nscf.test  >>     4.0482   67107040  23. _civicrm_registerClassLoader() /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/drupal/civicrm.module:206
nscf.test  >>     4.0488   67131552  24. require_once('/Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/CRM/Core/ClassLoader.php') /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/drupal/civicrm.module:335
nscf.test  >>
nscf.test  >> </span>
nscf.test  >> Drush command terminated abnormally due to an unrecoverable error.                                                                                                             [error]
Error: Cannot redeclare class CRM_Core_ClassLoader in /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/CRM/Core/ClassLoader.php, line 36

nscf.test is local server.

I have memcache installed, but I do NOT have memcache modules enabled and there is no traffic showing on my memcache admin.

My civicrm.drush.inc comes from Civicrm 4.5.6 and appears to have the fixes in to use the API to flush the cache and delete the class loader variable. Memecache cannot be a factor, it is not enabled.

Drupal had an issue at https://www.drupal.org/node/1907884

Emilyf and others say the problem is solved, but I ran into it with the first drush command I issued.

Any further work on what is actually the cause and how to solve it?  If it was solved in 4.4, has 4.5.6 regressed?

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: civicrm_class_loader debugging
March 12, 2015, 04:08:53 pm
Hi,

To help diagnose if this is the same issue as previously discussed, can you check the value of the civicrm_class_loader variable? Since 4.4.x, if I recall correctly, this variable now stores a relative path, so the issue previously discussed should not occur. If it did, you can workaround it during your upgrade by deleting the variable.

In the process you describe, at what point in the migration are you? i.e. presumably Drupal 6 has been upgraded to 7, but was CiviCRM upgraded?

Thanks,
Mathieu

PS: the Drupal issue you link to is specific to provision_civicrm, part of Aegir, a Drupal install/upgrade management system (http://www.aegirproject.org/). It was affected by the new classloader variable because when doing upgrades, Aegir will migrate the DB from one code base (/var/www/drupal-7.34) to another code base (/var/www/drupal-7.35), so the variable had to be reset in the process.
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

Cyberflyer

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
  • It's a piece of cake, Ezra!!
    • North Star Community Foundation
  • CiviCRM version: 4.5.6
  • CMS version: Drupal 7.34 / Commons 7.x-3.20
  • MySQL version: 5.5.13
  • PHP version: 5.4.38
Re: civicrm_class_loader debugging
March 13, 2015, 07:24:04 am
First off, thanks for the reply.

Secondly, I took a long look at the process of migrating through the upgrades from Drupal 6 to 7 for both Drupal Commons and CiviCRM combined preserving the data and gave up.

I'm in the process of fresh installs of the Commons/CiviCRM technology base and will try to use Feeds and what not to export/import the data.  I did not trust my currently running D6 installs to be solid, which is why I am learning drush and automating my workflow.

Third, in the Drupal DB, the variable "civicrm_class_loader" value field is defined as a longblob, hence is binary and not directly editable in PHPMyAdmin.  I downloaded the binary, opened it up in BBEdit and found this string inside:   

Code: [Select]
s:28:"/../CRM/Core/ClassLoader.php";
Which appears to be a relative reference.

That ascertained, I deleted the variable, went to terminal and issued this:

Code: [Select]
drush @nscf.test status

Which gave me this:

Code: [Select]
Drupal version                  :  7.34                                                                                                                                             
 Site URI                        :  nscfd7.test                                                                                                                                     
 Database driver                 :  mysql                                                                                                                                           
 Database hostname               :  localhost                                                                                                                                       
 Database port                   :                                                                                                                                                   
 Database username               :  nscfpin0                                                                                                                                         
 Database name                   :  nscf_d7_test                                                                                                                                     
 Database                        :  Connected                                                                                                                                       
 Drupal bootstrap                :  Successful                                                                                                                                       
 Drupal user                     :                                                                                                                                                   
 Default theme                   :  commons_origins                                                                                                                                 
 Administration theme            :  adaptivetheme_admin                                                                                                                             
 PHP executable                  :  /opt/local/bin/php                                                                                                                               
 PHP configuration               :  /opt/local/etc/php54/php.ini /Users/username/.composer/vendor/drush/drush/drush.ini                                                             
 PHP OS                          :  Darwin                                                                                                                                           
 Drush version                   :  7.0-dev                                                                                                                                         
 Drush temp directory            :  /tmp                                                                                                                                             
 Drush configuration             :  /Users/username/.drush/drushrc.php                                                                                                             
 Drush alias files               :  /Users/username/.drush/dev.aliases.drushrc.php /Users/username/.drush/ldl.aliases.drushrc.php /Users/username/.drush/nscf.aliases.drushrc.php
                                    /Users/username/.drush/tan.aliases.drushrc.php                                                                                                 
 Drupal root                     :  /Users/username/sites/nscf/nscfd7-test                                                                                                         
 Site path                       :  sites/default                                                                                                                                   
 File directory path             :  sites/default/files                                                                                                                             
 Temporary file directory path   :  /tmp       

I then issued this:

Code: [Select]
drush @nscf.test cc all
and got this:

Code: [Select]
Fatal error: Cannot redeclare class CRM_Core_ClassLoader in /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/CRM/Core/ClassLoader.php on line 36

Call Stack:
    0.0007     238056   1. {main}() /Users/username/.composer/vendor/drush/drush/drush.php:0
    0.0007     238616   2. drush_main() /Users/username/.composer/vendor/drush/drush/drush.php:11
    0.2555    8024200   3. Drush\Boot\DrupalBoot->bootstrap_and_dispatch() /Users/username/.composer/vendor/drush/drush/drush.php:71
    0.6629   43181032   4. drush_dispatch() /Users/username/.composer/vendor/drush/drush/lib/Drush/Boot/DrupalBoot.php:68
    0.8818   45945432   5. call_user_func_array:{/Users/username/.composer/vendor/drush/drush/includes/command.inc:178}() /Users/username/.composer/vendor/drush/drush/includes/command.inc:178
    0.8818   45945768   6. drush_command() /Users/username/.composer/vendor/drush/drush/includes/command.inc:178
    0.8822   45946560   7. _drush_invoke_hooks() /Users/username/.composer/vendor/drush/drush/includes/command.inc:210
    1.9382   53317800   8. call_user_func_array:{/Users/username/.composer/vendor/drush/drush/includes/command.inc:359}() /Users/username/.composer/vendor/drush/drush/includes/command.inc:359
    1.9382   53318136   9. drush_cache_command_clear() /Users/username/.composer/vendor/drush/drush/includes/command.inc:359
    1.9406   53321224  10. drush_op() /Users/username/.composer/vendor/drush/drush/commands/core/cache.drush.inc:143
    1.9406   53321712  11. drush_call_user_func_array() /Users/username/.composer/vendor/drush/drush/includes/drush.inc:687
    1.9407   53321808  12. drush_cache_clear_both() /Users/username/.composer/vendor/drush/drush/includes/drush.inc:700
    1.9748   53322984  13. drupal_flush_all_caches() /Users/username/.composer/vendor/drush/drush/commands/core/drupal/cache.inc:90
    8.1949   60142848  14. menu_rebuild() /Users/username/sites/nscf/nscfd7-test/includes/common.inc:7518
    8.1981   60143600  15. menu_router_build() /Users/username/sites/nscf/nscfd7-test/includes/menu.inc:2722
    8.4490   67066848  16. call_user_func:{/Users/username/sites/nscf/nscfd7-test/includes/menu.inc:2753}() /Users/username/sites/nscf/nscfd7-test/includes/menu.inc:2753
    8.4490   67066848  17. user_menu() /Users/username/sites/nscf/nscfd7-test/includes/menu.inc:2753
    8.4490   67109496  18. _user_categories() /Users/username/sites/nscf/nscfd7-test/modules/user/user.module:1821
    8.4490   67109608  19. module_invoke_all() /Users/username/sites/nscf/nscfd7-test/modules/user/user.module:3378
    8.4495   67112424  20. call_user_func_array:{/Users/username/sites/nscf/nscfd7-test/includes/module.inc:895}() /Users/username/sites/nscf/nscfd7-test/includes/module.inc:895
    8.4495   67112592  21. civicrm_user_categories() /Users/username/sites/nscf/nscfd7-test/includes/module.inc:895
    8.4495   67112648  22. civicrm_initialize() /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/drupal/civicrm_user.inc:131
    8.4495   67113088  23. _civicrm_registerClassLoader() /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/drupal/civicrm.module:206
    8.4514   67138776  24. require_once('/Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/CRM/Core/ClassLoader.php') /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/drupal/civicrm.module:335

</span>Drush command terminated abnormally due to an unrecoverable error.                                                                                                                           [error]
Error: Cannot redeclare class CRM_Core_ClassLoader in /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/CRM/Core/ClassLoader.php, line 36

Checking in the DB, the variable "civicrm_class_loader" did not exist.

Finally, looking at my civicrm.drush.inc file residing in ~/.drush/civicrm.drush.inc which is in effect cause I'm doing all of this from my bash login root, I find this code in version 4.4

Code: [Select]
/**
 * Implements hook_drush_cache_clear.
 */
function civicrm_drush_cache_clear(&$types) {
  if (_civicrm_init(FALSE)) {
    $types['civicrm'] = 'drush_civicrm_cacheclear';
  }
}

/**
 * Cache clear callback
 *
 * Warning: do not name drush_civicrm_cache_clear() otherwise it will
 * conflict with hook_drush_cache_clear() and be called systematically
 * when "drush cc" is called.
 */
function drush_civicrm_cacheclear() {
  _civicrm_init();

  // Clear the classloader cache variable
  // Should be done in CiviCRM core so that the system flush always deletes
  // the variable, however, it needs to be done early enough before the
  // ClassLoader initialization. FIXME.
  variable_del('civicrm_class_loader');

  // Flush all caches using the API
  $params = array('version' => 3);
  if (drush_get_option('triggers', FALSE)) {
    $params['triggers'] = 1;
  }

  if (drush_get_option('sessions', FALSE)) {
    $params['session'] = 1;
  }

  // Need to set API version or drush cc civicrm fails
  $params['version'] = 3;
  $result = civicrm_api('System', 'flush', $params);

  if ($result['is_error']) {
    drush_log(dt('An error occured: !message', array('!message' => $result['error_message'])), 'error');
    return;
  }

  drush_log(dt('The CiviCRM cache has been cleared.'), 'ok');
}

I'm a bit puzzled as too why the variable is stored as a blob, but it seems to contain what you expect.

And do I need to issue
Code: [Select]
drush_civicrm_cacheclear() somehow when I want to
Code: [Select]
drush @nscf.test cc all ?

Any thoughts appreciated.

Cyberflyer

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
  • It's a piece of cake, Ezra!!
    • North Star Community Foundation
  • CiviCRM version: 4.5.6
  • CMS version: Drupal 7.34 / Commons 7.x-3.20
  • MySQL version: 5.5.13
  • PHP version: 5.4.38
Re: civicrm_class_loader debugging
March 13, 2015, 07:38:41 am
Everything I am doing is to box-stock installs of Drupal Commons and CiviCRM 4.5.6.

Since I began Commons has issued some upgrades which I have not applied as I want to learn to have drush do this kind of thing for me from the command line.   

All modules are as enabled by the Drupal Commons Profile install.

Memcache modules are not enabled, but Entity cache 7.x-1.2 is.

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: civicrm_class_loader debugging
March 13, 2015, 09:33:09 am
Hi,

Quote from: Cyberflyer on March 13, 2015, 07:24:04 am
Finally, looking at my civicrm.drush.inc file residing in ~/.drush/civicrm.drush.inc which is in effect cause I'm doing all of this from my bash login root, I find this code in version 4.4

This is probably not the cause of the classloader issue, you do not need to copy civicrm.drush.inc in your ~/.drush directory. When you run drush with a context (drush @nscf.test status), it will scan the modules of that site and load drush modules in it. You can test by running "drush @nscf.test help | grep civicrm". You may need to run "drush cc drush" if you do any changes to drush sub-modules (i.e. removing ~/.drush/civicrm.drush.inc).

Quote
I'm a bit puzzled as too why the variable is stored as a blob, but it seems to contain what you expect.

And do I need to issue
Code: [Select]
drush_civicrm_cacheclear() somehow when I want to
Code: [Select]
drush @nscf.test cc all ?

"drush @nscf.test cc all" will run drush_civicrm_cacheclear(), because civicrm registers as a cache in drush, i.e. you can also do "drush cc civicrm".

The blob is kind of normal because Drupal serialises data in its settings.

Sorry I'm not really sure what the root cause of the issue is. You may have an incorrect path in your civicrm.settings.php, but for the rest, clearning the cache usually does the trick (files civicrm/template_c, Config.IDS.ini, etc).

Mathieu
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

Cyberflyer

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
  • It's a piece of cake, Ezra!!
    • North Star Community Foundation
  • CiviCRM version: 4.5.6
  • CMS version: Drupal 7.34 / Commons 7.x-3.20
  • MySQL version: 5.5.13
  • PHP version: 5.4.38
Re: civicrm_class_loader debugging
March 13, 2015, 09:57:23 am
Once again, thanks for the reply.

Here is a clue for you.

I removed ~/.drush/civicrm.drush.inc

Launched a fresh terminal instance from my root.  Navigated to nscf.test folder where the install is.

Issued a
Code: [Select]
drush @nscf.test cc all
Same result: 
Code: [Select]
Fatal error: Cannot redeclare class CRM_Core_ClassLoader in /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/CRM/Core/ClassLoader.php on line 36
Issued a
Code: [Select]
drush cc civicrm

Nice result:
Code: [Select]
The CiviCRM cache has been cleared.       [ok]
'civicrm' cache was cleared.

Issued another
Code: [Select]
drush @nscf.test cc all

Same bad result:

Code: [Select]
rush command terminated abnormally due to an unrecoverable error.                   [error]
Error: Cannot redeclare class CRM_Core_ClassLoader in /Users/larrylowe/sites/nscf/nscfd7-test/sites/all/modules/civicrm/CRM/Core/ClassLoader.php, line 36

On a hunch, I navigated to:   My Server Root/nscfd7-test/sites/all/modules/civicrm


issued a
Code: [Select]
drush @nscf.test cc all

Same bad result:

Code: [Select]
rush command terminated abnormally due to an unrecoverable error.                   [error]
Error: Cannot redeclare class CRM_Core_ClassLoader in /Users/larrylowe/sites/nscf/nscfd7-test/sites/all/modules/civicrm/CRM/Core/ClassLoader.php, line 36

so I cannot use
Code: [Select]
drush @nscf.test cc all

I will look into providing some alias to cc all or modifying it,  or some kind of work around, but I think something needs to be done to the shipping civicrm/drupal/drush/civicrm.drush.inc, which is now in force, to respond nicely to a drush @nscf.test cc all

I am guessing that (civiCRM init) is TRUE if I've gone so far to navigate to the module to run the cc all command.

Code: [Select]
/**
 * Implements hook_drush_cache_clear.
 */
function civicrm_drush_cache_clear(&$types) {
  if (_civicrm_init(FALSE)) {
    $types['civicrm'] = 'drush_civicrm_cacheclear';
  }
}

I will strive to develop a work around and report here.

Any thoughts you might have would be useful.

Cyberflyer

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
  • It's a piece of cake, Ezra!!
    • North Star Community Foundation
  • CiviCRM version: 4.5.6
  • CMS version: Drupal 7.34 / Commons 7.x-3.20
  • MySQL version: 5.5.13
  • PHP version: 5.4.38
Re: civicrm_class_loader debugging
March 13, 2015, 10:17:15 am
Update:

I checked the civicrm.settings.php file, which was created by the install and not modified by me and all the paths seemed correct.

I deleted everything inside /default/files/civicrm/templates_c and tried again. 

drush cc civicrm  worked as advertised.

drush @nscf.test cc all  failed as usual.

Cyberflyer

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
  • It's a piece of cake, Ezra!!
    • North Star Community Foundation
  • CiviCRM version: 4.5.6
  • CMS version: Drupal 7.34 / Commons 7.x-3.20
  • MySQL version: 5.5.13
  • PHP version: 5.4.38
Re: civicrm_class_loader debugging
March 13, 2015, 10:28:46 am
Code: [Select]
Fatal error: Cannot redeclare class CRM_Core_ClassLoader in /Users/username/sites/nscf/nscfd7-test/sites/all/modules/civicrm/CRM/Core/ClassLoader.php on line 36

Core class loader.php, line 36 on:
Code: [Select]
class CRM_Core_ClassLoader {

  /**
   * We only need one instance of this object. So we use the singleton
   * pattern and cache the instance in this variable
   * @var object
   * @static
   */
  private static $_singleton = NULL;

I have a near identical install one directory over at @nscf.work  Is this the issue?

https://github.com/civicrm/civicrm-drupal/pull/118

https://issues.civicrm.org/jira/browse/CRM-14186

Code: [Select]
This is absolutely critical and should get fixed. Because of this bug it's very difficult to have two Drupal CiviCRM instances on the same machine, one for live and one for staging/development. That is my exact setup, and when I updated to 4.4.4 the staging site started throwing the "Fatal error: Cannot redeclare class CRM_Core_ClassLoader" error. It took a lot of searching to find a solution. The "drush vdel civicrm_class_loader" command did the trick.
So I do a
Code: [Select]
drush vdel civicrm_class_loader and a
Code: [Select]
drush @nscf.test vdel civicrm_class_loader and got:

Code: [Select]
civicrm_class_loader not found.

Looking into civicrm.drush.inc I find this:
Code: [Select]
function drush_civicrm_cacheclear() {
  _civicrm_init();

  // Clear the classloader cache variable
  // Should be done in CiviCRM core so that the system flush always deletes
  // the variable, however, it needs to be done early enough before the
  // ClassLoader initialization. FIXME.
  variable_del('civicrm_class_loader');

FIXME. in the comments stood out.

Over to you.

Cyberflyer

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
  • It's a piece of cake, Ezra!!
    • North Star Community Foundation
  • CiviCRM version: 4.5.6
  • CMS version: Drupal 7.34 / Commons 7.x-3.20
  • MySQL version: 5.5.13
  • PHP version: 5.4.38
Re: civicrm_class_loader debugging
March 13, 2015, 11:01:51 am
Looking at drush cache-clear I see this:

Code: [Select]
/**
 * Command callback for drush cache-clear.
 */
function drush_cache_command_clear($type = NULL) {
  if (!drush_get_option('cache-clear', TRUE)) {
    drush_log(dt("Skipping cache-clear operation due to --cache-clear=0 option."), 'ok');
    return TRUE;
  }
  $types = drush_cache_clear_types(drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL));

  if (!isset($type)) {
    // Don't offer 'all' unless Drush has bootstrapped the Drupal site
    if (!drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
      unset($types['all']);
    }
    $type = drush_choice($types, 'Enter a number to choose which cache to clear.', '!key');
    if (empty($type)) {
      return drush_user_abort();
    }
  }
  // Do it.
  drush_op($types[$type]);
  if ($type == 'all' && !drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
    drush_log(dt("No Drupal site found, only 'drush' cache was cleared."), 'warning');
  }
  drush_log(dt("'!name' cache was cleared.", array('!name' => $type)), 'success');
}

What stands out is the comment:
Code: [Select]
// Don't offer 'all' unless Drush has bootstrapped the Drupal site
Makes me think that when Drush has bootstrapped the Drupal site, class CRM_Core_ClassLoader got declared once.

Then when civicrm_drush_cache_clear does it's check to see if _civicrm_init(FALSE) is true, it does not realize drush cc has already bootstrapped the Drupal site.  And at that point CRM_Core_ClassLoader got declared.  Hence the you can't declare it again error.

Not sure how to side-step that, however.

Some other check than
Code: [Select]
if (_civicrm_init(FALSE)) would seem in order.

Does that help?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • civicrm_class_loader debugging

This forum was archived on 2017-11-26.