DRUPAL-4-7 branch.

This bug was introduced by Patch #33747 by Ber and Moshe: bugfix + code improvement: clean up some of the taxonomy loading code. (original issue).

As of that patch, a node object gets a taxonomy field when loading. Function taxonomy_form_alter thinks it should be in another format, though:


    if (!isset($node->taxonomy)) {
      if ($node->nid) {
        $terms = taxonomy_node_get_terms($node->nid);
      }
      else {
        $terms = array();
      }
    }
    else {
      $terms = $node->taxonomy;
    }

    // Some code omitted
        $ntterms = isset($node->taxonomy) ? $terms : array_keys($terms);

In this case, array_key($terms) would be the way to get the right data. Perhaps we can simply always do that - but I am not sure why this test is here anyway. On the other hand, if we have a taxonomy node field, we should make sure it always has the same format, so that might be the right way to fix it anyway.

Thanks,
  Frodo

Comments

Bèr Kessels’s picture

Assigned: Unassigned » Bèr Kessels
killes@www.drop.org’s picture

I can confirm this bug exists.

riccardoR’s picture

I had the same problem, but it seems now fixed at a lower level (on theme_select) by this recently committed patch: drupal.org/node/45281

Anyway, before applying this patch, I had tried the same change that Frodo suggests and it worked:

$ntterms = array_keys($terms);

I was not able to find any reason for $ntterms to be either an array of integer or an associative array, depending on isset($node->taxonomy).

Bèr Kessels’s picture

I cannot confirm this bug. pleasemake sure it is not a duplicate of http://drupal.org/node/45281

Bèr Kessels’s picture

Status: Active » Closed (duplicate)