The following error appears when attempting a fresh install of Drupal 6.9 with the category module placed in /sites/all/modules/

[Sun Feb 01 14:52:50 2009] [error] [client ****] PHP Fatal error: Cannot redeclare taxonomy_schema() (previously declared in /****/sites/all/modules/category/wrappers/taxonomy/taxonomy.install:9) in /****/modules/taxonomy/taxonomy.install on line 285

Install proceeds correctly with category module directory removed.

Comments

higherform’s picture

Status: Active » Closed (fixed)

I realized the problem as soon as I took a break... category module was under /sites/all/modules/ instead of /modules/.

Consider adding a warning message if category is installed to the wrong directory?!?

EastWan’s picture

Version: 6.x-2.0-alpha4 » 6.x-2.0-beta2
Category: bug » task
Priority: Critical » Minor
Status: Closed (fixed) » Needs review

Same problem here. It would be *really* helpful to add a warning message or at least make it clearer in the INSTALL.txt because you always read "Step 1 - put the module in sites/all/modules" and so you kind of skip this. Adding a "Warning: Do not put in the sites/*/module folder" would certainly help a lot of people!

Thanks!

EastWan’s picture

Component: Code » Wrapper modules
Category: task » bug
Priority: Minor » Normal
Status: Needs review » Active

Well, I thought it worked this way. But it doesn't. I used a fresh install, so category wrappers were not installed.

But once you have one site running and install the wrappers (so they are read as .install and not .install.php) and then go to install another site, you get the before mentioned error.

This only seems to happen when adding a new site. I'm not familiar whether there is a way to prevent Drupal from accessing taxonomy_schema() in the taxonomy file (since the wrapper does all the work, it seems sort of useless loading that file). I feel a bit uncomfortable messing with the core taxonomy.install file (adding a if(!function_exists) could help for instance, or having the script rename the core taxonomy.install to taxonomy.install.php) - but clearly, there must be a better way?

EastWan’s picture

Title: Unable to install due to redeclare » Taxonomy Wrapper enabled on one site breaks other sites that don't use Category module

Okay, there's more problems coming up. I used function_exists() to only include the core taxonomy.module's taxonomy_schema when category isn't there.

Simply wrap the function taxonomy_schema() in module/taxonomy/taxonomy.install with:

if (!function_exists("taxonomy_schema"))
{
  ...
}

So far, so good. But this results in calls to category specific functions (like category_link()), although you are not using category on that subsite.

So, basically, this module breaks your entire Drupal site when you have Category including its taxonomy wrapper activated on another site but not on that particular site. (That is, the category/wrappers directory includes taxonomy.module instead of taxonomy.module.php).

The solution that worked for me was to check whether category is activated and include the original taxonomy.module if this is not the case.

In modules/category/wrappers/taxonomy.module wrap all the functions in this file with:

// check if category module is enabled
if (module_exists("category"))
{
...
} 
// include original taxonomy.module otherwise
else include($_SERVER['DOCUMENT_ROOT']."/modules/taxonomy/taxonomy.module");

This module should really not be so convinced of itself to think that it will always be enabled, thereby not causing these problems ;-).