Fatal error: Call to undefined function: block_list()

Submitted by tomo on December 17, 2012 - 11:28am

On a Drupal 6 site where I had copied over a database to be used with a freshly checked out tree, I suddenly got this fatal error which stopped any page from loading:

Fatal error: Call to undefined function: block_list() in .../theme.inc on line 935

I'm not sure how it happens. And even after it happens, it's not always immediately a problem. It can be a problem that manifests itself when migrating or copying a database from one site to another. And for some reason, the exact same database worked on another site.

In my case, the problem was the filenames for some core modules and themes and you can see if that's your problem by running this query:

SELECT count(*) FROM system WHERE filename LIKE '%modules/modules%' OR filename LIKE '%themes/themes%';

If that returns anything (like a filename like 'modules/modules/block/block.module') then you have a problem which you can fix by running:

UPDATE system SET filename = replace(filename, 'themes/themes', 'themes');
UPDATE system SET filename = replace(filename, 'modules/modules', 'modules');

tomo

You can get a similar error when editing the menu/admin menu:

"Fatal error: require_once() [function.require]: Failed opening required 'modules/modules/menu/menu.admin.inc' (include_path='.:/XXX/lib/php/pear') in XXX/includes/menu.inc on line 346"

This is caused by the menu_router table being corrupted in a similar way. The solution is to run this query:

UPDATE menu_router SET file = replace(file, 'modules/modules', 'modules');

© 2010-2014 Saigonist.