While debugging CCK HEAD and trying to figure out why certain field settings would not 'take', I finally found out the default to be in drupal schema building. When refreshing, we don't start from scratch but build on the statically cached $schema. Plus the order of array_merge args ensures new entries don't override previous ones.

Provide 'how-to-reproduce' steps is not easy.
I'll be bold and promote this to critical - at least it is for CCK :-)

CommentFileSizeAuthor
schema_rebuild.patch909 bytesyched
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

'I finally found out the default to be...' => 'I finally found out the problem to be' (french faux-ami, heh)

KarenS’s picture

Status: Needs review » Reviewed & tested by the community

I also was seeing erratic results where sometimes the schema seemed to be 'stuck' on the old values when I tried to refresh it, and this may explain the problems I was seeing.

It seems clear than anytime some asks for the schema to be refreshed, the new values must override any that previously existed. And it seems equally clear that if you are asking for the schema to be refreshed we should *not* start with the cached value but with a new array.

I don't know of any use cases (yet) outside of CCK, but any module that tries to force a refresh of the schema will get bit by this bug.

I should also point out that this patch fixed a bug in CCK at http://drupal.org/node/198931.

yched’s picture

Actually, the bug about stale values staying after the refresh is fixed by the

+      $schema = array();

line. Rather straightforward, was probably simply overlooked when writing the original function.

The other part

-        $schema = array_merge($current, $schema);
+        $schema = array_merge($schema, $current);

is more about enforcing the order of precedence : results from later called hooks override previous results. I *think* this is more inline with other hook invocations in core, but should have no real impact here (no modules should claim the same tables - if they do, then the site probably has a larger conflict problem anyway).

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

I looked around this part of the code, and all seemed to be fine with this patch, so committed. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.