Answers.Body: <p>It sounds as though there is either a cached path to ClassLoader.php somewhere or there are two copies of the CiviCRM code under your modules directories. Various scenarios and solutions are discussed in this forum post: <a href="http://forum.civicrm.org/index.php/topic,25529.0.html" rel="nofollow noreferrer">svn installation says "Cannot redeclare class CRM_Core_ClassLoader"</a> Please post back here rather than on the forum, though.</p>
  
  <p>If you're sure that there aren't multiple copies of CiviCRM under /home/mydomain/www/backup/ then the most likely fix is to clear the Drupal variable <code>civicrm_class_loader</code>, e.g. using drush:</p>
  
  <pre><code>drush vset civicrm_class_loader ''
  </code></pre>
  
  <p>There's a good chance the fatal error will prevent the use of drush. In that case, you can delete the row from Drupal's <code>variable</code> table where <code>name</code> = 'civicrm_class_loader'. It's possible the variables are cached in addition -- you may need to clear Drupal's cache tables manually. (A targeted approach -- in Drupal 6, anyway -- is to delete the row from Drupal's <code>cache</code> table where <code>cid</code> = 'variables'.)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-18T07:09:52.230Z
Answers.Text: thanks for the pointer to multiple civi codebases ;-) Three of them!!
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-30T20:02:21.233Z
Answers.Text: @davejenx you came to the rescue again. This was exactly what we needed to do
Answers.UserDisplayName: Jon-man
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-21T09:54:01.280Z
Answers.Text: I found that it calls 2 files:  
  /beta/sites/all/modules/civicrm/CRM/Core/ClassLoader.php  
  and  
  /backup/sites/all/modules/civicrm/CRM/Core/ClassLoader.php.   But I don't know how to remove the calling to beta ClassLoader.php
Answers.UserDisplayName: vences
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-21T09:59:08.487Z
Answers.Text: As those two files are in different Drupal trees, this suggests that there's a cached path. Does clearing the civicrm_class_loader variable solve the problem?
Answers.UserDisplayName: davejenx
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-21T10:03:28.977Z
Answers.Text: I deleted the civicrm_class_loader row in drupal 'variable' table but it doesn't helps
Answers.UserDisplayName: vences
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-21T10:24:17.130Z
Answers.Text: Are you using a PHP opcode cache, e.g. APC or Opcache? If so, try restarting PHP. Also try clearing Civi caches again. Did you mean "define( 'CIVICRM_DSN' ) : change to backup_civicrmdb" (you wrote "backup_civicrm".) Are there any other references to the beta dbs or paths in backup's settings.php or civicrm.settings.php ?
Answers.UserDisplayName: davejenx
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-21T11:23:47.200Z
Answers.Text: Also if you haven't done so already, go to Administer -> System Settings -> Cleanup Caches and Update Paths. Correct the base directory there if necessary. Clear caches again for good measure. Verify that paths are correct at Administer -> System Settings -> Directories.
Answers.UserDisplayName: davejenx
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-16T09:39:23.507Z
Answers.LastActivityDate: 2018-01-09T20:48:54.943Z
Answers.LastEditDate: 2018-01-09T20:48:54.943Z
Answers.UserDisplayName: davejenx
Answers.Body: <p>You can also get this error if you do something (ahem) really confused like have two copies of your Drupal site on the same machine that both point to the same CiviCRM codebase/database.</p>
  
  <p>Of course you'd have to be stupid to do that. *blush*</p>
  
  <p>I had the hard-coded strings in my <code>civicrm.settings.php</code> file pointing to paths in the other Drupal codebase. Just recording here in case it helps anyone else.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-30T09:30:51.277Z
Answers.LastActivityDate: 2017-03-30T09:30:51.277Z
Answers.UserDisplayName: artfulrobot
Answers.Body: <p>Try this (Drupal) :</p>
  
  <p>1) Comment following lines in civicrm.settings.php :</p>
  
  <pre><code>require_once 'CRM/Core/ClassLoader.php';
  CRM_Core_ClassLoader::singleton()-&gt;register();
  </code></pre>
  
  <p>2) Take backup of variable table in database &amp; delete the row with name = 'civicrm_class_loader'.</p>
  
  <p>3) With this your civicrm page should get loaded. </p>
  
  <p>4) Now clear civicrm caches or hit "<a href="http://your_site/civicrm/menu/rebuild?reset=1" rel="nofollow">http://your_site/civicrm/menu/rebuild?reset=1</a>" url.</p>
  
  <p>5) Uncomment the above lines. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-12T11:18:59.850Z
Answers.LastActivityDate: 2016-09-12T11:18:59.850Z
Answers.UserDisplayName: Subhash
Answers.Body: <p>This can also be done w/o Drush where you examine the Drupal 'variable' table in MySQL and delete the rows that contain CiviCRM 'class loader' data.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-17T15:29:13.717Z
Answers.LastActivityDate: 2015-07-17T15:29:13.717Z
Answers.UserDisplayName: CiviTeacher
Answers.Body: <p>If you're getting a Fatal Error: Cannot redeclare class CRM_Core_ClassLoader in /sites/all/modules/civicrm/CRM/Core/ClassLoader.php, line 36</p>
  
  <p>Then a </p>
  
  <pre><code>sudo -u apache drush status
  </code></pre>
  
  <p>will also result in a Fatal Error - and you will also not be able to run:</p>
  
  <pre><code>drush vset civicrm_class_loader ''
  </code></pre>
  
  <p>You're definitively looking for multicode bases: perhaps you're getting this after an upgrade and you copied your old CiviCRM code to <code>civicrm-old</code> or something like that. </p>
  
  <pre><code>rm -r civicrm-old/ 
  </code></pre>
  
  <p>will fix this. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-16T12:45:50.060Z
Answers.LastActivityDate: 2017-03-30T12:41:37.540Z
Answers.LastEditDate: 2017-03-30T12:41:37.540Z
Answers.UserDisplayName: KarinG - Semper IT
Body: <p>I had a civicrm 4.4.6 site in my drupal 7 subdomain, which is beta.mydomain.com.<br>
  I want to have a backup site to perform update on civicrm, but it shows: </p>
  
  <blockquote>
    <p>Fatal error: Cannot redeclare class CRM_Core_ClassLoader in
    /home/mydomain/www/backup/sites/all/modules/civicrm/CRM/Core/ClassLoader.php
    on line 36</p>
  </blockquote>
  
  <p>Below is my setting scenario: </p>
  
  <p>I created a subdomain, backup.mydomain.com, and copied all the files from beta site to backup site.</p>
  
  <p>In beta site, these are the database: civicrm (drupal default database)  and civicrmdb (civicrm database)</p>
  
  <p>I had copied the database, as backup_civicrm and backup_civicrmdb</p>
  
  <p>In backup site, I made the following changes:</p>
  
  <ol>
  <li><p><strong>sites/default/settings.php</strong> : change database name to backup_civicrm  </p></li>
  <li><p><strong>sites/default/civicrm.settings.php</strong> : </p>
  
  <ul>
  <li>define( 'CIVICRM_UF_DSN' ) :    change to  backup_civicrm </li>
  <li>define( 'CIVICRM_DSN' ) : change to backup_civicrm </li>
  <li>$civicrm_root = '/home/mydomain/www/backup/sites/all/modules/civicrm'; </li>
  <li>define( 'CIVICRM_TEMPLATE_COMPILEDIR', '/home/mydomain/www/backup/sites/default/files/civicrm/templates_c/' 
  );</li>
  <li>define( 'CIVICRM_UF_BASEURL' , '<a href="http://backup.mydomain.com/">http://backup.mydomain.com/</a>' );</li>
  <li>define( 'CIVICRM_MAIL_LOG', '/home/mydomain/www/backup/sites/default/files/civicrm/templates_c/mail.log' );</li>
  </ul></li>
  </ol>
  
  <p>After configuration, my backup site shows error:</p>
  
  <blockquote>
    <p>Fatal error: Cannot redeclare class CRM_Core_ClassLoader in
    /home/mydomain/www/backup/sites/all/modules/civicrm/CRM/Core/ClassLoader.php
    on line 36</p>
  </blockquote>
  
  <p>I had cleared all the files in sites/default/files/civicrm/templates_c , and it does not work.</p>
  
  <p>I found that when I change $civicrm_root to beta, it works.</p>
  
  <pre><code>$civicrm_root = '/home/mydomain/www/beta/sites/all/modules/civicrm';
  </code></pre>
  
  <p>This is weird. I need to perform upgrade on civicrm, if the root is link to beta, I'm not sure how this will affect my update.</p>
  
  <p>Am I missing out any configuration? Any idea on what is the problem?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-16T18:17:17.100Z
Comments.Text: I got this error because I accidentally had 2 test sites using the same CiviCRM database. Make sure it's unique per test environment.
Comments.UserDisplayName: Christia
Tags: <drupal><backups>
Title: "Cannot redeclare class CRM_Core_ClassLoader" in backup site
ThreadText: # "Cannot redeclare class CRM_Core_ClassLoader" in backup site
  
  (Asked by: username_0 on 2015-07-16)
  
  I had a civicrm 4.4.6 site in my drupal 7 subdomain, which is beta.mydomain.com.  
  I want to have a backup site to perform update on civicrm, but it shows:
  
  > Fatal error: Cannot redeclare class CRM\_Core\_ClassLoader in
  > /home/mydomain/www/backup/sites/all/modules/civicrm/CRM/Core/ClassLoader.php
  > on line 36
  
  Below is my setting scenario:
  
  I created a subdomain, backup.mydomain.com, and copied all the files from beta site to backup site.
  
  In beta site, these are the database: civicrm (drupal default database) and civicrmdb (civicrm database)
  
  I had copied the database, as backup\_civicrm and backup\_civicrmdb
  
  In backup site, I made the following changes:
  
  1. **sites/default/settings.php** : change database name to backup\_civicrm
  2. **sites/default/civicrm.settings.php** :
  
     * define( 'CIVICRM\_UF\_DSN' ) : change to backup\_civicrm
     * define( 'CIVICRM\_DSN' ) : change to backup\_civicrm
     * $civicrm\_root = '/home/mydomain/www/backup/sites/all/modules/civicrm';
     * define( 'CIVICRM\_TEMPLATE\_COMPILEDIR', '/home/mydomain/www/backup/sites/default/files/civicrm/templates\_c/'
       );
     * define( 'CIVICRM\_UF\_BASEURL' , '<http://backup.mydomain.com/>' );
     * define( 'CIVICRM\_MAIL\_LOG', '/home/mydomain/www/backup/sites/default/files/civicrm/templates\_c/mail.log' );
  
  After configuration, my backup site shows error:
  
  > Fatal error: Cannot redeclare class CRM\_Core\_ClassLoader in
  > /home/mydomain/www/backup/sites/all/modules/civicrm/CRM/Core/ClassLoader.php
  > on line 36
  
  I had cleared all the files in sites/default/files/civicrm/templates\_c , and it does not work.
  
  I found that when I change $civicrm\_root to beta, it works.
  
  ```
  $civicrm_root = '/home/mydomain/www/beta/sites/all/modules/civicrm';
  
  ```
  
  This is weird. I need to perform upgrade on civicrm, if the root is link to beta, I'm not sure how this will affect my update.
  
  Am I missing out any configuration? Any idea on what is the problem?
  
  **Tags:** drupal, backups
  
  > **Comments:**
  > **username_1**: I got this error because I accidentally had 2 test sites using the same CiviCRM database. Make sure it's unique per test environment.  
  
  ---
  
  ## 5 answers
  
  ### Answer by username_2 on 2015-07-16. Score: 13 | Accepted answer
  
  It sounds as though there is either a cached path to ClassLoader.php somewhere or there are two copies of the CiviCRM code under your modules directories. Various scenarios and solutions are discussed in this forum post: [svn installation says "Cannot redeclare class CRM\_Core\_ClassLoader"](http://forum.civicrm.org/index.php/topic,25529.0.html) Please post back here rather than on the forum, though.
  
  If you're sure that there aren't multiple copies of CiviCRM under /home/mydomain/www/backup/ then the most likely fix is to clear the Drupal variable `civicrm_class_loader`, e.g. using drush:
  
  ```
  drush vset civicrm_class_loader ''
  
  ```
  
  There's a good chance the fatal error will prevent the use of drush. In that case, you can delete the row from Drupal's `variable` table where `name` = 'civicrm\_class\_loader'. It's possible the variables are cached in addition -- you may need to clear Drupal's cache tables manually. (A targeted approach -- in Drupal 6, anyway -- is to delete the row from Drupal's `cache` table where `cid` = 'variables'.)
  
  > **Comments:**
  > **username_0**: I found that it calls 2 files:   /beta/sites/all/modules/civicrm/CRM/Core/ClassLoader.php   and   /backup/sites/all/modules/civicrm/CRM/Core/ClassLoader.php.   But I don't know how to remove the calling to beta ClassLoader.php  
  > **username_2**: As those two files are in different Drupal trees, this suggests that there's a cached path. Does clearing the civicrm_class_loader variable solve the problem?  
  > **username_0**: I deleted the civicrm_class_loader row in drupal 'variable' table but it doesn't helps  
  > **username_2**: Are you using a PHP opcode cache, e.g. APC or Opcache? If so, try restarting PHP. Also try clearing Civi caches again. Did you mean "define( 'CIVICRM_DSN' ) : change to backup_civicrmdb" (you wrote "backup_civicrm".) Are there any other references to the beta dbs or paths in backup's settings.php or civicrm.settings.php ?  
  > **username_2**: Also if you haven't done so already, go to Administer -> System Settings -> Cleanup Caches and Update Paths. Correct the base directory there if necessary. Clear caches again for good measure. Verify that paths are correct at Administer -> System Settings -> Directories.  
  > **username_3**: thanks for the pointer to multiple civi codebases ;-) Three of them!!  
  > **username_4**: @username_2 you came to the rescue again. This was exactly what we needed to do  
  
  ---
  
  ### Answer by username_5 on 2017-03-30. Score: 4
  
  You can also get this error if you do something (ahem) really confused like have two copies of your Drupal site on the same machine that both point to the same CiviCRM codebase/database.
  
  Of course you'd have to be stupid to do that. \*blush\*
  
  I had the hard-coded strings in my `civicrm.settings.php` file pointing to paths in the other Drupal codebase. Just recording here in case it helps anyone else.
  
  
  ---
  
  ### Answer by username_6 on 2016-09-12. Score: 3
  
  Try this (Drupal) :
  
  1) Comment following lines in civicrm.settings.php :
  
  ```
  require_once 'CRM/Core/ClassLoader.php';
  CRM_Core_ClassLoader::singleton()->register();
  
  ```
  
  2) Take backup of variable table in database & delete the row with name = 'civicrm\_class\_loader'.
  
  3) With this your civicrm page should get loaded.
  
  4) Now clear civicrm caches or hit "<http://your_site/civicrm/menu/rebuild?reset=1>" url.
  
  5) Uncomment the above lines.
  
  
  ---
  
  ### Answer by username_7 on 2015-07-17. Score: 2
  
  This can also be done w/o Drush where you examine the Drupal 'variable' table in MySQL and delete the rows that contain CiviCRM 'class loader' data.
  
  
  ---
  
  ### Answer by username_8 on 2016-07-16. Score: 2
  
  If you're getting a Fatal Error: Cannot redeclare class CRM\_Core\_ClassLoader in /sites/all/modules/civicrm/CRM/Core/ClassLoader.php, line 36
  
  Then a
  
  ```
  sudo -u apache drush status
  
  ```
  
  will also result in a Fatal Error - and you will also not be able to run:
  
  ```
  drush vset civicrm_class_loader ''
  
  ```
  
  You're definitively looking for multicode bases: perhaps you're getting this after an upgrade and you copied your old CiviCRM code to `civicrm-old` or something like that.
  
  ```
  rm -r civicrm-old/ 
  
  ```
  
  will fix this.
  
  
  ---
  
  