Project:Taxonomy context
Version:5.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

* 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.

Comments

#1

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:

<?php
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.

#2

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.

#3

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.

#4

Status:closed (won't fix)» needs review

Here is a patch that implements the fix in #1

It's against 5.x-2.0

AttachmentSize
taxonomy_context_hook_update_2.patch 1.07 KB
nobody click here