* warning: array_merge() [function.array-merge]: Argument #2 is not an array in C:\www\webapps\drupal\update.php on line 309.
* warning: Invalid argument supplied for foreach() in C:\www\webapps\drupal\update.php on line 542.

CommentFileSizeAuthor
#4 taxonomy_context_hook_update_2.patch1.07 KBAgileware
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kingandy’s picture

Hmm ... you should NEVER call hook_install from inside a hook_update_N. (This is because the behaviour of hook_install may change in a later update, and potentially people could try updating both hook_update_N steps at once. hook_update_N should bring the database up to the state it needs to be at the time it was written, not whatever the current state happens to be.)

That said - the above is unrelated to this error, which can probably be resolved simply by adding a return array() (see hook_update_N() documentation). For preference, the array should be populated via update_sql() calls ... one for each query, so people know what's going wrong (if applicable).

Taking all of this into account, the hook should look something like this:

function taxonomy_context_update_2() {
  $ret = array();
  $ret[] = update_sql("DROP TABLE IF EXISTS {taxonomy_context_vocabulary}");
  $ret[] = update_sql("DROP TABLE IF EXISTS {taxonomy_context_term}");
  $ret[] = update_sql("DROP TABLE IF EXISTS {taxonomy_context}");
  $ret[] = update_sql("CREATE TABLE {taxonomy_context} (
                              id int(10) unsigned NOT NULL default 'term',
                              type enum ('vocabulary', 'term') NOT NULL default 'term',
                              format int(4) NOT NULL default 0,
                              KEY (id, type)
                            ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
  return $ret;
}

Obviously for best practice you'd include a switch ($GLOBALS['db_type']) { } block, but life's too short.

kingandy’s picture

One more thing: for best best practice, you'd be copying all of the data from the old tables into the new one. This is supposed to be a seamless update, after all - an alternative to uninstalling and reinstalling.

NancyDru’s picture

Status: Active » Closed (won't fix)

This is not a problem for the 6.x release. If someone wants to back-port a fix to 5.x, re-open this issue with a patch.

Agileware’s picture

Status: Closed (won't fix) » Needs review
FileSize
1.07 KB

Here is a patch that implements the fix in #1

It's against 5.x-2.0