The problem is quite simple.

If for some reason, a developper forget to add a "return $schema" or return a null value at the end of an hook_schema implementation, the cache 'schema' entry will be left empty at the next rebuild (update.php or when you clean the cache table). As this cache entry is used for every modules, this means that there is no schema available at all anymore (node, etc.) and result is an unusable site.

Drupal core should add a test for this :

--- drupal-6.4/includes/common.inc	2008-08-13 19:59:12.000000000 -0400
+++ drupal/includes/common.inc	2008-09-08 05:54:04.000000000 -0400
@@ -3058,8 +3058,10 @@
       // Invoke hook_schema for all modules.
       foreach (module_implements('schema') as $module) {
         $current = module_invoke($module, 'schema');
-        _drupal_initialize_schema($module, $current);
-        $schema = array_merge($schema, $current);
+        if (!empty($current)) {
+        	_drupal_initialize_schema($module, $current);
+        	$schema = array_merge($schema, $current);
+        }
       }

Comments

mikejoconnor’s picture

Version: 6.4 » 6.x-dev
Status: Needs review » Reviewed & tested by the community

I ran in to this same issue today, and came up with nearly the same solution. I used is_array(), however that method is slower than empty(). This patch does solve the problem as long as the user doesn't return something other than an array.

Damien Tournoud’s picture

Version: 6.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Needs review

This needs to be discussed and go in 7.x first.

Damien Tournoud’s picture

Status: Needs review » Closed (duplicate)