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) »
  • svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
Pages: [1]

Author Topic: svn installation says "Cannot redeclare class CRM_Core_ClassLoader"  (Read 6579 times)

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
August 01, 2012, 06:49:45 pm
Installing from svn (4.2) today, all seemed to go well, but this error comes up when accessing civicrm:

Fatal error: Cannot redeclare class CRM_Core_ClassLoader in /home/as/_allen/temp/civicrm-4.2/CRM/Core/ClassLoader.php on line 37

debug_backtrace() shows the file was being require_once()'d in civicrm.settings.php (which I copied from the svn 4.2 version of templates/CRM/common/civicrm.settings.php.tpl), in the last two lines.  Commenting out the last two lines seems to fix this problem.

Am I doing something wrong, or is this an issue to be patched in SVN?

Thanks,
Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
August 01, 2012, 07:17:35 pm
Hmm, that error probably means that 'require_once' isn't actually requiring the class a single time -- the file is probably loaded multiple times.

A few questions/ideas:

a) Which CMS?

b) When you print debug_backtrace(), could you also print get_include_path()? Examine the list to see if there are two versions of Civi.

c) Are you doing anything funny with symlinks which might make it possible for one file ("CRM/Core/ClassLoader.php") to appear with two different paths? (I had a similar problem once when cobbling together CiviCRM from SVN with WordPress -- because I tried using symlinks to put it together.)

d) Are you using any custom modules or scripts which might bootstrap CiviCRM in their own way? (e.g. scripts which include civicrm.settings.php directly or xavier's class.api.php)

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
August 03, 2012, 11:46:09 am
Hi Tim,

Thanks for the ideas. Actually, just commenting out those lines wasn't really a useful solution; it works for the non-civicrm Drupal home page, but of course breaks any real CiviCRM content.

a) Drupal 7.15
b) Looks normal to me:
.:/var/www/domains/devel/d7/sites/all/modules/civicrm:/var/www/domains/devel/d7/sites/all/modules/civicrm/packages:.:/usr/share/php:/usr/share/pear
c) `find -type l` shows no symlinks on this site except for a couple of modules that are uninstalled.
d) No custom modules, just a minimum set of Drupal core modules and CiviCRM:
as@as:/var/www/domains/devel/d7$ drush pm-list | grep Enabled | grep Module
 Administration  Administration menu (admin_menu)                           Module  Enabled        7.x-3.0-rc1
 CiviCRM         CiviCRM (civicrm)                                          Module  Enabled        4.1         
 Core            Block (block)                                              Module  Enabled        7.15       
 Core            Color (color)                                              Module  Enabled        7.15       
 Core            Comment (comment)                                          Module  Enabled        7.15       
 Core            Contextual links (contextual)                              Module  Enabled        7.15       
 Core            Dashboard (dashboard)                                      Module  Enabled        7.15       
 Core            Database logging (dblog)                                   Module  Enabled        7.15       
 Core            Field (field)                                              Module  Enabled        7.15       
 Core            Field SQL storage (field_sql_storage)                      Module  Enabled        7.15       
 Core            Field UI (field_ui)                                        Module  Enabled        7.15       
 Core            File (file)                                                Module  Enabled        7.15       
 Core            Filter (filter)                                            Module  Enabled        7.15       
 Core            Help (help)                                                Module  Enabled        7.15       
 Core            Image (image)                                              Module  Enabled        7.15       
 Core            List (list)                                                Module  Enabled        7.15       
 Core            Menu (menu)                                                Module  Enabled        7.15       
 Core            Node (node)                                                Module  Enabled        7.15       
 Core            Number (number)                                            Module  Enabled        7.15       
 Core            Options (options)                                          Module  Enabled        7.15       
 Core            Overlay (overlay)                                          Module  Enabled        7.15       
 Core            Path (path)                                                Module  Enabled        7.15       
 Core            RDF (rdf)                                                  Module  Enabled        7.15       
 Core            Search (search)                                            Module  Enabled        7.15       
 Core            Shortcut (shortcut)                                        Module  Enabled        7.15       
 Core            System (system)                                            Module  Enabled        7.15       
 Core            Taxonomy (taxonomy)                                        Module  Enabled        7.15       
 Core            Text (text)                                                Module  Enabled        7.15       
 Core            Toolbar (toolbar)                                          Module  Enabled        7.15       
 Core            Update manager (update)                                    Module  Enabled        7.15       
 Core            User (user)                                                Module  Enabled        7.15       
 Development     Devel (devel)                                              Module  Enabled        7.x-1.0   


Still looking...

- Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
August 03, 2012, 11:49:54 am
OK, problem found and fixed.  Adding this code to the top of CRM/Core/ClassLoader.php shows some interesting results:
Code: [Select]
foreach (get_included_files() as $file) {
  echo "$file<BR>";
}

With this I can see that there is indeed an extra copy of civicrm code under sites/all/modules/civicrm.trunk, which sits right next to the actual civicrm module code in sites/all/modules/civicrm.  The file sites/all/modules/civicrm.trunk/ClassLoader.php file was indeed being included, and then again the file sites/all/modules/civicrm/ClassLoader.php was being included too.

Not sure how or why that happens, but I just removed that extra directory and fixed the problem.

Thanks for the help, Tim.
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
May 06, 2013, 02:51:51 pm
As an aside I hit this when a live site is copied back to a staging site where the staging site is expected to use a different civicrm folder but can reach the live site one. The drupal system table still has paths to the live one so it is finding both.

Clearing drupal menu cache fixes ('drush cc menu' or 'drush cc all')
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

jcasharpe

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 5
    • Woodlands Church
  • CiviCRM version: 4.4.6
  • CMS version: Drupal 7
  • MySQL version: MariaDB 10.0.13
  • PHP version: 5.5
Re: svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
May 10, 2013, 01:08:34 pm
I've also seen similar errors to this when using an opcode cache such as XCache. It occurs when the cache runs out of space; I had to double mine from 64Mb to 128Mb.

hebbar10

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.4.3
  • CMS version: drupal 6 and 7
  • MySQL version: 5.5.34
  • PHP version: 5.3
Re: svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
December 08, 2013, 11:06:14 pm
I had the same issue while upgrading our site from drupal 6 to drupal 7. I got this error after I enabled civicrm in upgraded drupal 7 site. Removing civicrm directory from drupal 6 modules folder fixed my problem. I hope this helps . .

Erich Schulz

  • I post frequently
  • ***
  • Posts: 142
  • Karma: 5
    • When no-one understands what you are going on about its time to start a blog
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.somthing
  • PHP version: 5.3.3
Re: svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
March 27, 2014, 04:34:55 am
so I just started getting this error... in an erm "complex" sandbox environment...

for the me the answer seems to have been a simple drupal variable clear:

    drush @contact-qld vset civicrm_class_loader ''


initially I tried this with no joy:

    echo get_include_path();

then replacing

  require_once 'CRM/Core/ClassLoader.php';

with

    if (!class_exists('CRM_Core_ClassLoader')) {
      require_once 'CRM/Core/ClassLoader.php';
    }

but still only pain...

then in modules/contrib/civicrm/drupal/civicrm.module I found this:

 310 /**
 311  * Find & register classloader and store location in Drupal variable.
 312  * Per CRM-13737 this allows for drupal code to be outside the core directory
 313  * which makes it easier for sites managing their own installation methods that
 314  * may need to cover different drupal versions
 315  */
 316 function _civicrm_registerClassLoader() {
 317   $path = variable_get('civicrm_class_loader');
 318   if (empty($path) || !file_exists($path)) {
 319     $candidates = array(
 320         dirname(__FILE__) . '/../CRM/Core/ClassLoader.php',
 321         dirname(__FILE__) . '/../civicrm-core/CRM/Core/ClassLoader.php',
 322         dirname(__FILE__) . '/../core/CRM/Core/ClassLoader.php',
 323         // ... ad nauseum ...
 324     );
 325     foreach ($candidates as $candidate) {
 326       if (file_exists($candidate)) {
 327         $path = $candidate;
 328         variable_set('civicrm_class_loader', $candidate);
 329         break;
 330       }
 331     }
 332   }
 333
 334   require_once $path;
 335   CRM_Core_ClassLoader::singleton()->register();
 336 }

« Last Edit: March 27, 2014, 04:36:45 am by Erich Schulz »

kenahoo

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 1
  • CiviCRM version: 4.1.1
  • CMS version: Drupal 7.15
  • MySQL version: 5.1.63
  • PHP version: 5.3.16
Re: svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
March 27, 2014, 07:20:26 pm
Hi Erich, very timely that you're looking into this, I'm trying to deploy a production site and I'm hitting this issue today too.

What's the drush @contact-qld vset civicrm_class_loader '' bit you're mentioning?  My drush doesn't seem to know about @contact-qld, does that come from a plugin or something?

For now I'm commenting out the require_once line in my civicrm.settings.php so the rest of the site will work.

 -Ken

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
March 27, 2014, 07:39:30 pm
I've been removing the require_once in civicrm.settings.php for a while now. Erichs command removes the variable 'civicrm_class_loader' - stored in the variable table. His site name is configured to have an alias of @contact-qld
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Erich Schulz

  • I post frequently
  • ***
  • Posts: 142
  • Karma: 5
    • When no-one understands what you are going on about its time to start a blog
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.somthing
  • PHP version: 5.3.3
Re: svn installation says "Cannot redeclare class CRM_Core_ClassLoader"
March 29, 2014, 07:27:55 pm
yes thanks Eileen!

Ken you gotta get into drush aliases - they are pretty quick to set up and make working with multiple sites a real pleasure!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • svn installation says "Cannot redeclare class CRM_Core_ClassLoader"

This forum was archived on 2017-11-26.