"Illegal offset type in" warnings on node preview.

ErwanF - March 5, 2009 - 12:38
Project:Content Taxonomy
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Issue tags:checkbox, option, options, widget
Description

This is my first bug report on Drupal and furthermore I'm french so I hope I'm doing this correctly. I'm working with Drupal 6.9 on a local installation. If the Content Taxonomy Options module is activated, I get the same following lines repeated many times on a preview of a Übercart product class node :

"# warning: Illegal offset type in isset or empty in C:\wamp\www\XXXX\modules\taxonomy\taxonomy.module on line 1015.
# warning: Illegal offset type in C:\wamp\www\XXXX\modules\taxonomy\taxonomy.module on line 1016.
# warning: Illegal offset type in C:\wamp\www\XXXX\modules\taxonomy\taxonomy.module on line 1019.
# warning: Illegal offset type in C:\wamp\www\XXXX\modules\taxonomy\taxonomy.module on line 592."

When published anyway, some Taxonomy terms added through CCK fields vanished. This trouble disapears when I unactivate this particular module. I use many modules but I can give a complete of partial list if needed.

#1

ErwanF - March 5, 2009 - 13:19

Erratum
- I made a confusion between two modules. The module I am talking about is CT Options, not Option widgets.
- "When published anyway, some Taxonomy terms added through CCK fields vanished." After a new check, this is not exact. Terms disapear if the module is unactivated, which sounds more logical.

#2

mh86 - March 16, 2009 - 18:50

maybe it's a conflict with the ubercart module.
do you get the same error messages with a different own content type and content taxonomy fields?

#3

cbow - March 16, 2009 - 19:40

I was getting the same message (no Ubercart). It started after upgrading from d6.9 to d6.10. I "solved" to problem by going into the CT field for my content-type then unchecking the "Save values additionally to the core taxonomy system (into the 'term_node' table)." option, saving, re-checking, saving.

#4

mh86 - March 16, 2009 - 20:04

thanks for this information. I'm still running drupal 6.8 on my local installation.
I'm going to update my installation and check this issue again

#5

mh86 - March 16, 2009 - 20:15

updated my drupal installation and still not getting any error
maybe it has been fixed with this issue (fixed today)

#6

ErwanF - March 20, 2009 - 15:33

I didn't try with another content type. Actually I wonder if it is a trouble with Taxonomy Image and/or PathAuto modules. This was temporarly "Solved" by not using a CCK Taxonomy field to display an image from Taxonomy image and unactivating PathAuto for the moment. I'm obviously new in Drupal community and still have trouble to fully understand Taxonomy image module... I'm sorry if this doesn't sound very clear. I will try to do better next time... Anyway thanks for your replies.

#7

ErwanF - March 23, 2009 - 13:55

Back and going on trying to find the answer. This issue occurs on another of my content types too, though this one isn't linked at all with Übercart.
You must know that I want to display all the terms associated with this content type on this content type by using CCK fields (because I don't like the default taxonomies' display). As a result, the area named "vocabularies" become empty on my content type edit page (see my attachment, with this "vocabularies" area in French).

But according to my latest trials, this can't be empty, otherwise I get this precise following message again (x 5):

    * warning: Illegal offset type in isset or empty in C:\wamp\www\dkpd\modules\taxonomy\taxonomy.module on line 1015.
    * warning: Illegal offset type in C:\wamp\www\dkpd\modules\taxonomy\taxonomy.module on line 1016.
    * warning: Illegal offset type in C:\wamp\www\dkpd\modules\taxonomy\taxonomy.module on line 1019.
    * warning: Illegal offset type in C:\wamp\www\dkpd\modules\taxonomy\taxonomy.module on line 592.

The string talking about a "line 1015" may miss a content in this precise area. So I created a test vocabulary named "trial", I populated it with two terms, "trial 1" and "trial 2", then I associated this vocabulary with this buggy content type, in order to have something in the "vocabularies" area (obviously not displayed anywhere else with a CCK field). Now it works fine (no warning anymore on my preview page)! But since I display those test terms in a CCK field (leaving the vocabularies area empty again), I get the same issue. Now I know that I need some content in this vocabularies area. So I think I will delete my last CCK field, keep this test taxonomy and hide it using the Taxonomy Hide module... Any better idea?

AttachmentSize
2009-03-23_nothingdisplayedanymoreinthevocabulariesarea.png 683 bytes

#8

skizzo - March 30, 2009 - 14:54

@mh86 Re #5 : I don't think that http://drupal.org/node/395328 solves this issue.
I upgraded from 6.x-1.0-beta6 to 6.x-1.x-dev 2009-03-17 but I still see the error. I have a simple content type with

- a Content Taxonomy CCK field, Select List widget type, nested in Standard Group, configured for vid 4
- vocabulary 4 is NOT directly assigned to my content type in admin/content/taxonomy/edit/vocabulary/4

Going into node editing, when clicking on preview I get the error
warning: Illegal offset type in isset or empty in /var/www/drupal/modules/taxonomy/taxonomy.module on line 1015.

If I now create a vid 5 and assign it to content type via admin/content/taxonomy/edit/vocabulary/5 then preview is ok, no error.
I could assign vid 4 as both Content Taxonomy field AND direct vocabulary assignment, but I assumed that this would
be a bad practice... is that assumption wrong? Thank you.

#9

richardwdoe - March 30, 2009 - 19:24

The same issue has been encountered here with Drupal 6.10, CCK 6.x-2.2 and Content Taxonomy 6.x-1.x-dev (2009-Mar-17).

To reproduce it:

  1. Create a new content type
  2. Add a content taxonomy field to the new content type
  3. Configure that field to use one of the options widgets, e.g. Select List, and enable the option "Save values additionally to the core taxonomy system".
  4. Create, preview and save a new node of this content type (should preview and save fine)
  5. Edit the node and hit Preview. This should get you the "illegal offset type" error message(s)

#10

no2e - April 20, 2009 - 04:48

Same issue for me -- did the same as richardwdoe described in #9.

    * warning: Illegal offset type in isset or empty in /www/htdocs/XXX/XXX/drupal/modules/taxonomy/taxonomy.module on line 1015.
    * warning: Illegal offset type in /www/htdocs/XXX/XXX/drupal/modules/taxonomy/taxonomy.module on line 1016.
    * warning: Illegal offset type in /www/htdocs/XXX/XXX/drupal/modules/taxonomy/taxonomy.module on line 1019.
    * warning: Illegal offset type in /www/htdocs/XXX/XXX/drupal/modules/taxonomy/taxonomy.module on line 592.

#11

richardwdoe - April 22, 2009 - 16:20

Following up on my previous comment #9, further investigation suggests that these warnings will not be displayed if you:

  • associate another taxonomy vocabulary with your content type; and
  • do not add that vocabulary to the content type's list of fields (by means of content_taxonomy's CCK fields).

In other words, if you have at least one vocabulary associated with the content type that is not handled by content_taxonomy, you will not get the warnings.

#12

ntt - April 26, 2009 - 13:47

subscribing

#13

ErwanF - April 28, 2009 - 15:38
Assigned to:ErwanF» Anonymous

Thanks, Richardwdoe. That's exactly what I found and tried to explain in #7 ;-)

#14

mh86 - May 13, 2009 - 18:21
Status:active» fixed

Hi!
Finally I was able to reproduce the problem (thanks to the detailed descriptions). The Taxonomy module was throwing the warnings on preview because of a wrong format in $node->taxonomy. This happened when every core taxonomy field got hidden. I think this problem already existed for a longer time, at least since some Content Taxonomy versions.
The problem was quite hard to debug, but I think I found a working fix (a bit strange, but ok). I committed the changes to the dev version. So, when trying the fix, be sure to have the right version. Fix will be included in the next release anyway ;)

#15

ErwanF - May 15, 2009 - 20:14

Thanks a lot for this work!

#16

fletch11 - May 18, 2009 - 17:23

not sure if this was committed to the latest (May 17) release but I'm still getting these errors as well.

thanks for all your work.

#17

malc_b - May 18, 2009 - 18:42

I was getting this but the mode I have in taxonomy fixes this. This has been reported as a taxonomy issue but isn't fixed. See http://drupal.org/node/275352#comment-1422794 for my solution. If you add

  drupal_set_message("<pre>" . print_r($tid, true) . "</pre>");

to taxonomy just be line 1011 if (!isset($terms[$tid])) you can see the majority have $tid as numeric but some are complete objects.

#18

System Message - June 1, 2009 - 18:50
Status:fixed» closed

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

#19

aidanlis - June 12, 2009 - 13:39
Version:6.x-1.0-beta6» 6.x-1.x-dev
Status:closed» active

I've just checked out the latest branch, DRUPAL-6--1, and I'm still getting the same errors. See http://drupal.org/node/275352 for related issues.

#20

druppi - June 21, 2009 - 12:42

Having same problem with 6.x-1.x-rc1.

Content Taxonomy writes taxonomy terms to core database, option widgets activated (but does not matter). Preview mode throws the described errors.

I use Content Taxonomy to have a per node type restriction / representation for taxonomy terms. In one node type it is allowed to add terms, in another node type it is not. In one node type you have single selection, in another node type you have multiple selection. I can not do without this module.

#21

crea - July 14, 2009 - 08:22

Subscribing...downloaded latest CT, and problem is still there..

#22

crea - July 14, 2009 - 14:47

@mh86: I found error with your patch: in form_alter hook you seem to unset $form['taxonomy'] while you should actually work with $form['#node']->taxonomy (as taxonomy code which is causing preview problems). Also, at the beginning of the funcion you make following check:

<?php
if (!is_array($form['taxonomy'])) {
      return;
    }
?>

and I checked that during preview $form['taxonomy'] is empty so function simply terminates at the beginning because of this check.
If I understand it correctly, during preview whole node object is prepared in $form['#node']. If I simply enter at the beginning following code:
<?php
if (isset($form_state['node_preview'])) {
  unset(
$form['#node']->taxonomy);
}
?>

then preview works without errors ( but it's ofcourse not solution, cause it disables normal non-CT vocabs too, I think).

So my conclusion: seems like entire content_taxonomy_form_alter() function needs major rework. Those $form_state's seem to be tricky and require good understanding of what is happening deep and what needs to be done. If taxonomy code behaves differently in different $form_states than we should too, but currently same code runs in CT function.

#23

crea - July 14, 2009 - 14:52
Priority:minor» normal

#24

crea - July 15, 2009 - 13:42
Title:"Illegal offset type in" warnings on node preview with Content Taxonomy Options (Option widgets) activated» "Illegal offset type in" warnings on node preview.
Version:6.x-1.x-dev» 6.x-1.0-rc1
Component:Option Widgets» Code

This happens not only with Options widget.

#25

mh86 - July 15, 2009 - 14:27
Title:"Illegal offset type in" warnings on node preview.» "Illegal offset type in" warnings on node preview with Content Taxonomy Options (Option widgets) activated
Version:6.x-1.0-rc1» 6.x-1.x-dev
Component:Code» Option Widgets

I added another few lines to prevent an empty taxonomy form array on preview. it seems like this fixes the warnings for me. I hope this is working now.

#26

mh86 - July 15, 2009 - 14:30
Title:"Illegal offset type in" warnings on node preview with Content Taxonomy Options (Option widgets) activated» "Illegal offset type in" warnings on node preview.
Version:6.x-1.x-dev» 6.x-1.0-rc1
Component:Option Widgets» Code

accidentally changed issue settings with previous comment..

#27

richardwdoe - August 13, 2009 - 13:23
Status:active» fixed

Going through the same steps I detailed in comment #9 with the dev versions dated 2009-Jul-16 and 2009-Aug-12, this issue looks to be fixed in both.

Thanks mh86.

#28

System Message - August 27, 2009 - 13:30
Status:fixed» closed

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

#29

mErilainen - October 15, 2009 - 11:12
Version:6.x-1.0-rc1» 6.x-1.x-dev

In my dev-version from Sep 13th I still get this error.

#30

mErilainen - October 15, 2009 - 11:12
Status:closed» active

and active

#31

fletch11 - October 29, 2009 - 15:11

me too... sorry

#32

roderik - December 8, 2009 - 21:10

It seems this was 'unfixed' in #552874: php undefined variable notices. The patch in #4 of that issue, fixes things for me.

@crea / #22: I have spent some hours debugging this and was thinking exactly the same as you. However, apparently mh86's changes do fix everything (and make sure that taxonomy_preview_terms() isn't called unnecessarily? I'm too tired of this to re-check that ;) )

 
 

Drupal is a registered trademark of Dries Buytaert.