I'm not 100% sure if this is a problem or not, but seems to be triggering issues in other modules that also use the taxonomy terms on node updates/inserts.
I have a Photo node type that I'm using with fupload (one image per node) and uses a taxonomy term to sort into photo galleries. After upload I click the "next" button and it takes me to the page where I can enter a title, description, and select the appropriate term. After I submit this page it updates the node with these values, however, the $node->taxonomy array doesn't appear to be formatted properly.
In the update operation in nodeapi the taxonomy array looks as follows (after running through fupload):
array(0 => array(4 => '4'));
Where 4 is the tid.
However, when I run an update on an existing node that doesn't use fupload the taxonomy array looks like:
array(3 => array(4 => '4'));
Where 3 is the vocabulary ID and 4 is the tid.
So it seem that code in the fupload module is causing the vid to be reset to 0.
I think where this is happening is in images.previewlist.imagefield.inc (around line 279):
if (isset($form_state['values']['taxonomy_' .$fid])) {
$node->taxonomy = isset($form_state['values']['taxonomy_' .$fid]) ? array_merge($form_state['values']['taxonomy_' .$fid], $node->taxonomy) : $node->taxonomy;
}
It runs an array merge that seems to be causing it to fail. In my case $node->taxonomy is empty so this is:
array_merge(array(3 => array(4 => '4')), array());
The isset() call seems redundant here, so maybe this code could be rewritten as:
if (isset($form_state['values']['taxonomy_' .$fid])) {
$node->taxonomy = !empty($node->taxonomy) ? array_merge($form_state['values']['taxonomy_' .$fid], $node->taxonomy) : $form_state['values']['taxonomy_' .$fid];
}
I've changed this on my own copy and it appears to be working nicely now.
Comment | File | Size | Author |
---|---|---|---|
#1 | taxonomy_imagefield_save_535148.patch | 1.19 KB | hadsie |
Comments
Comment #1
hadsie CreditAttribution: hadsie commentedhere's a patch for this issue.
Comment #2
grandcat CreditAttribution: grandcat commentedAlso thank you for this patch. Will check this.
Comment #3
grandcat CreditAttribution: grandcat commentedComitted to HEAD. Thanks in advanced.