Not sure what's happening here.
Upon content creation, whether core content (page) or cck content, a taxonomy term 2 (special) is being added.
However the content type has not yet been "registered" with the taxonomy module.

After registered the content type and attempting to change the tag to something meaningful I get the following errors:

I go to edit mode then preview mode and get the following errors:

* warning: Illegal offset type in isset or empty in /home/{username}/public_html/modules/taxonomy/taxonomy.module on line 1011.
* warning: Illegal offset type in /home/{username}/public_html/modules/taxonomy/taxonomy.module on line 1012.
* warning: Illegal offset type in /home/{username}/public_html/modules/taxonomy/taxonomy.module on line 1015.
* warning: Illegal offset type in /home/{username}/public_html/modules/taxonomy/taxonomy.module on line 591.

After saving the errors disappear.

I thought the admininstration might be interfering, so it shut off. No difference.
I thought the content taxonomy module might be interfering, so i shut it off. No difference.

My website is on the web and on my laptop. One major difference is the CCK version. On the web it is: Content Construction Kit (CCK) 6.x-3.x-dev (2009-Aug-30)
On my laptop i have: Content Construction Kit (CCK) 6.x-3.x-dev (2009-Jul-12)

I posted at the Drupal project as well: http://drupal.org/node/569396#comment-2009586

Comments

markus_petrux’s picture

Project: Content Construction Kit (CCK) » Content Taxonomy
Version: 6.x-3.x-dev » 6.x-1.0-rc2
Component: content.module » Autocomplete - Freetagging
Priority: Critical » Normal

I think this is related to Content Taxonomy module. CCK does not touch node taxonomies.

Even when you have disabled Content Taxonomy module, there may be records in the {term_node} table that are loaded at nodeapi('load') time or something similar, but these tags are not correctly processed at some point, and the taxonomy code related to node preview is firing this PHP notice because what it thinks it is a tid, it is not. It is probably an array.

I also found this issue but never had the time to fully debug to find the cause. In the end, for other reasons, we're never telling Content Taxonomy to save the tags in {term_node} table, and this PHP notice in taxonomy module has not happened to us since then.

It should be something wrong in Content Taxonomy or Drupal core taxonomy.

markus_petrux’s picture

Looking at Content Taxonomy module, on top of its hook_form_alter() implementation we can see the following snippet:

    if (!is_array($form['taxonomy'])) {
      // empty taxonomy arrays can cause errors on preview
      if ($form_state['post']['op'] == t('Preview')) {
        $form['taxonomy'] = array('#tree' => TRUE);
        $form['taxonomy']['key'] = array('#type' => 'value', '#value' => '');
        return;
      }
    }

Probably this needs to be reviewed as there may be more cases when something needs to be done in order to avoid these PHP notices in taxonomy module.

markus_petrux’s picture

I think what happens is that taxonomy_nodeapi('load') loads records from {term_node} to $node object, so $node->taxonomy is populated with terms as objects. When the related vocabulary is not related to the node type, taxonomy module does not populate the $form['taxonomy'] array, and $form['#node']->taxonomy remains populated with terms as objects. This is what is causing the PHP notices here.

So, probably, Content Taxonomy module would have to deliverately override $form['taxonomy'] in this case as well, but this is a bit complex because it should only override stuff related to the proper vocabularies and not other that might not be related to Content Taxonomy fields.

mh86’s picture

TomSherlock, which version of Content Taxonomy are you using?
I have been working on this issue and it should be fixed with Content Taxonomy RC2!

markus_petrux’s picture

@mh86: This issue happens to me using 6.x-1.x-dev.

The problem is that taxonomy module populates $node->taxonomy at nodeapi('load') time (because it load from {term_node} regardless of the fact that the vocabulary may or may not be attached to a content type), but it does not populate $form['taxonomy'] at hook_form_alter() time when the vocabulary is not attached to a content type. Then, during node preview, the taxonomy module does $node->taxonomy = taxonomy_preview_terms($node);, but it *thinks* $node->taxonomy has been populated from $form['taxonomy'] where terms are not objects but arrays of terms or tids.

Since no one has populated $form['taxonomy'], $node->taxonomy still contains the *objects* loaded during nodeapi('load'), and that breaks taxonomy_preview_terms() causing these PHP notices because here the format of terms is expected to be as arrays, not objects.

It seems to me this particular use-case is not covered in content_taxonomy_form_alter().

tomsherlock’s picture

@mh86, i'm working with Content Taxonomy 6.x-1.0-rc2.

mh86’s picture

Hi!

thanks for the information and long explanations.

with the explanations I was able to reproduce the problem. It seems like, when using the option 'save to term_node', the vocabulary should be associated with the content type (in vocabulary settings) - this removes at least the errors. I have to figure out, how we can solve this issue, even if someone doesn't associate the right content type.

Saving the values to the term_node table has always been problematic, the interaction with the taxonomy system at this point is really ugly, but many people need this option. I'm really happy, that this has been (or is going to be) removed in Drupal 7.

mh86’s picture

Status: Active » Closed (duplicate)

marking this issue as duplicated now, because of #391906: "Illegal offset type in" warnings on node preview.