A rather difficult bug, resetting all other taxonomy fields when a content_taxonomy field is present. To replicate, change any other taxonomy fields, submit the node, and then recheck the taxonomy fields. No changes are saved. This happens on the first save or preview, but not on subsequent previews, where the other taxonomy fields are saved correctly. Surprisingly, this only appeared on our live server, but not on my local build.

I tracked it down to _content_taxonomy_unset():

function _content_taxonomy_taxonomy_unset(&$form, $vids) {
  if (empty($vids) || empty($form)) {
    return;
  }
  foreach ($form as $key => &$value) {
    if ($key == 'tags') {
      _content_taxonomy_taxonomy_unset($value, $vids);
    }
    elseif (is_object($value) && in_array($value->vid, $vids)) {
      unset($form[$key]);
    }
    elseif (in_array($key, $vids)) {
      unset($form[$key]);
    }
  }
}

Not passing $value by reference in the foreach loop solves this problem:

  foreach ($form as $key => $value) {

instead of ...

  foreach ($form as $key => &$value) {

But how does this affect the wider picture? Are there unexpected implications?

Comments

mh86’s picture

at the moment, the &$value has been removed, because it requires php5 ( it's only in the dev version)
but I have to check whether this causes any other problems

mh86’s picture

Status: Active » Fixed

I think this issue should be fixed with the last commits.
Concerning the different behaviour on your servers, this might have been related to different php versions

Status: Fixed » Closed (fixed)

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