I have a content type that has two taxonomy vocabs associated with it. If I use the autocategorise button on one then it gives an SQL error for each node:

warning: Invalid argument supplied for foreach() in /[folder names here]/sites/all/modules/autocategorise/auto_categorise.module on line 114.

And then clears all the terms set for the other vocabulary on each node.

So now I have to edit every single node and re-establish the term for that vocabulary.

Comments

the fatman’s picture

I'm getting the same error and have only one vocabulary defined.

I disabled the vocab index module, made no difference.

Daren Schwenke’s picture

Same error.

Edit: I think I get it. If you don't have any synonyms defined for your terms, you get this error.

auto_categorise_nodeapi calls
get_array_for_matching
which has the following code:
SELECT t.tid, s.name
FROM {term_data} AS t LEFT JOIN term_synonym AS s
ON t.tid = s.tid
WHERE vid = %d AND s.name IS NOT NULL
ORDER BY s.tid", $vid);
This pulls in the synonyms for matching.
Since function _apply_terms_to_node simply loops through the terms, it will error if you have no synonyms defined as the array passed in is then undefined.

Replaced

  foreach ($terms as $tid=>$term){
    foreach ($term as $synonym){
      if (is_int(strpos($haystack, strtolower($synonym)))){
        $matches[]=$tid;
        //if the vocab is not multiple we exit after the first match
        if (!$multiple){
          break;
        }
      }
    }
  }

with:

  if ( is_array($terms) ) {
    foreach ($terms as $tid=>$term){
      foreach ($term as $synonym){
        if (is_int(strpos($haystack, strtolower($synonym)))){
          $matches[]=$tid;
          //if the vocab is not multiple we exit after the first match
          if (!$multiple){
            break;
          }
        }
      }
    }
  }

and this error went away. You can also just add a synonym to a term and it will go away.
After all, this is the intention of the module.

Daren Schwenke’s picture

Status: Active » Needs review
matslats’s picture

Status: Needs review » Closed (fixed)

Thanks for all your contributions, I was absent for a while.
All these issues are sorted out in 1.3