I have a CCK Content Taxonomy Field whose values are additionally saved to core taxonomy.
My vocabulary's display option is set to "None (hidden)". Node preview throws the following error:

Invalid argument supplied for foreach() in /var/www/drupal/sites/all/modules/term_display/term_display.module on line 164.

I am not into coding: a software developer suggested replacing "isset" with "is_array" in line 155
to handle nodes with no taxonomy terms assigned to them.

Comments

rstamm’s picture

Status: Active » Postponed (maintainer needs more info)

Can't reproduce, need more info about field settings.

AlexisWilke’s picture

skizzo,

Did you mean "Content Taxonomy"? (and not CCK Content Taxonomy Field since the latter is not available for D6)

Can you please share the setup you have with that CCK field? That way we may be able to replicate the problem.

Thank you.
Alexis

skizzo’s picture

Yes, "Content Taxonomy". After all the error may be unrelated to Term Display, or it could be module interaction. I have two vocabularies assigned to my Content Type.

[Taxonomy setting] Vocabulary SECTION - Display style: "Hidden"
[Content Type setting]: Content Taxonomy Field; Widget type "Select List"; Required: Yes; 1 value;
save values additionally into the 'term_node' table: Yes; Vocabulary: SECTION; Display field: Yes
[Taxonomy setting] Vocabulary TAGS -- Display style: "Default" , Multiple Select: Yes

I can now create, preview and save a node without any error report (for the sake of testing I disregard the two vocabulary input form elements, I only use the Content Taxonomy field). I now enable a separate auto-tagging module, which adds a "Hide vocabulary in input form" option to all vocabularies.

[Taxonomy setting] Vocabulary SECTION - Hide vocabulary: Yes  (as I am using the Content Taxonomy Field instead)
[Taxonomy setting] Vocabulary TAGS - Hide vocabulary: Yes  (as the nodes are autotagged)

If I now try to create content, select Content Taxonomy Field, and click on Preview, the system throws:

 Invalid argument supplied for foreach() in term_display.module on line 165.
 Invalid argument supplied for foreach() in taxonomy.module on line 574.
Invalid argument supplied for foreach() in taxonomy.module on line 574.

The first error disappears applying the line 155 fix described in OP (other errors are still there).
All three errors disappear disabling the autotagging module

AlexisWilke’s picture

There is a suspicious line of code in content_taxonomy, to my point of view.

The following creates an empty entry.

The comment is correct that if there isn't anything (no taxonomy) then the taxonomy module is not going to save anything and thus deletion won't work. However, the NULL is of the wrong type and I think that's what generates the problem. Yet, I could not reproduce the errors you are seeing... So there could be yet another module that tweaks the $node->taxonomy field.

        // the $node->taxonomy array should never be empty, because in this case the 
        // taxonomy nodeapi doesn't call taxonomy_node_save which handles removing
        // and inserting of terms
        if (empty($node->taxonomy)) {
          $node->taxonomy[$field['vid']] = NULL;
        }

P.S. I do an update as I mentioned the wrong module in my post (i.e. I was blaming Term Display instead of Content Taxonomy...)

AlexisWilke’s picture

Skizzo,

I did some more testing, but the Content Taxonomy potential problem does NOT occur when you just Preview a page. So the problem must be somewhere else...

Are you sure that the three modules you mentioned here are the only ones that deal with terms and taxonomies?

Could you search your list of modules for ->taxonomy and see whether you have another module that could be tweaking that variable...

Thank you.
Alexis Wilke

skizzo’s picture

I disabled a couple of taxonomy related modules (Taxonomy Manager and Taxonomy Image) to no avail. I do not understand why the error shows up only with Preview... If I create and save the node right away, without any preview, then there is no error, so it has something to do with the way Preview works. I could send you the export of my Content Type, if that helps reproducing the issue... Thanks.

AlexisWilke’s picture

Could you tell us what version you are using for the following modules (I put my current version between parenthesis):

Drupal (6.13)
MO Auto add terms (1.4)
Content Taxonomy (1.0-rc1)
Term Display (1.x-dev)

Thank you.
Alexis

skizzo’s picture

Drupal (6.13)
MO Auto add terms (1.4)
Content Taxonomy (1.x-dev 2009-07-16)
Term Display (1.x-dev 2009-06-19)

AlexisWilke’s picture

Okay... I tested with Content Taxonomy 1.x-dev and still no error...

I wanted to create another site, so I could try to only install these few modules and see whether I get the error...

More later.
Alexis Wilke

skizzo’s picture

@Alexis: to play it safe I decided to simplify my setup, so I don't get the error anymore. I leave this issue open as a reminder in case you want to figure out what the problem was. Feel free to close in case you cannot reproduce it. Thx.

AlexisWilke’s picture

What did you remove to not get the error anymore? 8-)

Thank you.
Alexis

skizzo’s picture

Category: bug » support
Status: Postponed (maintainer needs more info) » Closed (fixed)

well, the settings for the autotagging vocabulary (TAGS in #3) is actually the same. I simplified the setup by not using Content Taxonomy for the other vocabulary (SECTION in #3) and I haven't seen the error since then. I am closing this issue as now I cannot follow up anymore. Will re-open if I stumble into it again.