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) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Moving 3.2.3 from dev to staging. Fatal error: Cannot redeclare class CRM_Utils_
Pages: [1]

Author Topic: Moving 3.2.3 from dev to staging. Fatal error: Cannot redeclare class CRM_Utils_  (Read 1229 times)

ehowland

  • I’m new here
  • *
  • Posts: 25
  • Karma: 0
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6
  • MySQL version: various
  • PHP version: various
Moving 3.2.3 from dev to staging. Fatal error: Cannot redeclare class CRM_Utils_
October 10, 2010, 08:53:22 pm
I did an upgrade on my Drupal CiviCRM to 3.2.3 on my localhost (a Mac). I had some issues with a partial upgrade documented elsewhere on the forums.  After deleting the tables and indexes created by the partial upgrade the upgrade was successful.  I entered some data that had been accumulated during the upgrade. Everything is working fine.

I then moved the site to a hosting server.  Although I was coming from a Mac I did the export COPYFILE_DISABLE=true to avoid moving the Mac resource forks (no ._filename files).  I get the following message.

Fatal error: Cannot redeclare class CRM_Utils_System_Drupal in /var/www/dirdata/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 40

I believe this error might be misleading as renaming the class in Drupal.php file leads to this error:

Fatal error: Class 'CRM_Utils_System_Drupal' not found in /var/www/dirdata/sites/all/modules/civicrm/CRM/Utils/System.php(183) : eval()'d code on line 1


So there is no other declaration of that class (I also looked for another older/duplicate version of the CiviCRM directory). That would be expected since I moved all the files from a working system.

I did the migration of the database using backup_migrate. 

Since I did not exclude tables, I looked at http://wiki.civicrm.org/confluence/display/CRMDOC32/Moving+an+Existing+Installation+to+a+New+Server+or+Location

Using the information there I emptied all the cache tables and deleted all the information in the  config_backend field of the single record in the civicrm_domain table. I did it that way since I could not delete that record because of Foreign Key Restraints. Checking back later shows that the config_backend field had been regenerated from my civicrm.settings.php file.

None of these fixed the Fatal error: Cannot redeclare class CRM_Utils_System_Drupal.  I cannot run civicrm/admin/setting/updateConfigBackend&reset=1 because of the error (although it must partly work since somthing regenerates my templates_c directory and the config_backend field).

If I comment out the require_once on line 180 I get the "Fatal error: Class 'CRM_Utils_System_Drupal' not found" from line 183.

One of my colleges tried to log on and also got a "cannot redeclare error".  But it was:
Fatal error: Cannot redeclare class CRM_Core_DAO_UFGroup in /var/www/dirdata/sites/all/modules/civicrm/CRM/Core/DAO/UFGroup.php on line 444


So I am now doubting that this is really a redeclaration error. But I have no clue what the error really is.
Phpinfo reports: PHP Version 5.2.6-1


 

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Moving 3.2.3 from dev to staging. Fatal error: Cannot redeclare class CRM_Utils_
October 11, 2010, 03:58:18 am
One approach to debugging this is to start with a fresh install of all files taken ONLY from the sources, like drupal.org and civicrm.org. Do then a fresh install of Drupal and CiviCRM. Once you see that is working fine, THEN copy your databases and see.

CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Re: Moving 3.2.3 from dev to staging. Fatal error: Cannot redeclare class CRM_Utils_
October 11, 2010, 07:25:07 am
Sounds like it could be fixed by converting an include to an include_once.

Some drupal hooks get fired multiple times per page load under some circumstances.

ehowland

  • I’m new here
  • *
  • Posts: 25
  • Karma: 0
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6
  • MySQL version: various
  • PHP version: various
Re: Moving 3.2.3 from dev to staging. Fatal error: Cannot redeclare class CRM_Utils_
October 11, 2010, 08:56:16 am
The include_once or require_once would seem to be the way to go, unfortunately it is already included in the two different invocations I know about. The first form is used 11 times in just that one file (CRM/Utils/System.php).   I see from the php site that require_once can be confused by two different paths that lead to the same file.  Replacing the line 209 form with the line 180 form of the call does not help.  Would this change between different version of PHP (localhost versus hosted versions)?  As previously mentioned I seem to be on PHP 5.2.6-1.

in CRM/Utils/System.php 180 we have
        require_once( str_replace( '_', DIRECTORY_SEPARATOR, $config->userFrameworkClass ) . '.php' );
        return eval( 'return ' .
                     $config->userFrameworkClass .
                     '::url( $path, $query, $absolute, $fragment, $htmlize, $frontend );' );

and inCRM/Utils/System.php 208 we have
        if ( $config->userFramework == 'Drupal' ) {
            require_once 'CRM/Utils/System/Drupal.php';
            CRM_Utils_System_Drupal::updateCategories( );
        }

ehowland

  • I’m new here
  • *
  • Posts: 25
  • Karma: 0
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6
  • MySQL version: various
  • PHP version: various
Re: Moving 3.2.3 from dev to staging. Fatal error: Cannot redeclare class CRM_Utils_
October 26, 2010, 09:19:47 am
I did start over with a fresh Drupal 6.19 and a fresh CiviCRM 3.2.3.  It did install OK so I remain puzzled about what broke.  I was able to reload my civicrm database so that is OK as well.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Moving 3.2.3 from dev to staging. Fatal error: Cannot redeclare class CRM_Utils_

This forum was archived on 2017-11-26.