Last updated April 29, 2009. Created on April 16, 2008.
Edited by rfay, webchick. Log in to edit this page.

You might in your Drupal travels come across the situation where doing seemingly innocuous things such as logging in or trying to view a page results in errors such as:

Fatal error: Call to undefined function taxonomy_get_vocabularies() in /modules/tagadelic/tagadelic.module on line 41

or:

Fatal error: Call to undefined function: path_set_alias() in /modules/pathauto/pathauto.module on line 435

Of course, the very first debugging step should be checking the system table and making sure that the status column is set to 1 for path.module, taxonomy.module, etc. If those modules somehow got disabled without your consent, this would cause the problem.

However, if you've eliminated this step and still are running into the issue, the next step is to take a look at the filename of these modules. Here's an excerpt from my system table:

mysql> select name, filename, status from system where type = 'module';
+------------+-------------------------------------+--------+
| name       | filename                            | status |
+------------+-------------------------------------+--------+
| taxonomy   | modules/taxonomy/taxonomy.module    |      1 |
| path       | modules/path/path.module            |      1 |
| pathauto   | modules/pathauto/pathauto.module    |      1 |
| tagadelic  | modules/tagadelic/tagadelic.module  |      1 |
+------------+-------------------------------------+--------+

All looks good, right? Except, this is a 4.7.x site (which died partially through a 5.x upgrade), and the path to the taxonomy and path modules are in fact modules/taxonomy.module and modules/path.module, not modules/taxonomy/taxonomy.module and modules/path/path.module. module_list() can't find them, and thus it never loads the files, so random fatal errors abound.

To solve the problem, try visiting the modules page (if you can), which will re-build the system tables with the correct filesystem paths. If you can't (for example, if Drupal won't even let you log in), then copy/paste the following into a file called "fix.php" in the root of your Drupal installation (same place as INSTALL.txt and friends) and run it in the web browser:

<?php
// Bootstrap Drupal.
include_once "includes/bootstrap.inc";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// Force re-load of the system table.
system_modules();
?>

If you get the error "Fatal error: Call to undefined function system_modules" then it means that even your system.module's path is incorrect in the system table. Manually set the filename of system.module (normally "modules/system/system.module") and run fix.php again. You can manually set the filename in mysql with:

update system set filename="modules/system/system.module" where name="system"

Then run fix.php again, and it should succeed.

Now, when you reload the page, everything should be back to normal (although you may want to restore from backup just in case).

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

colan’s picture

Instead of adding that code/file, you could probably just do:

drush @site-alias php-eval "system_modules();"