I am using Content Taxonomy fields on my registration form. I receive the following error when the user submits the registration form:

    * warning: Illegal offset type in /usr/local/apache2/htdocs/modules/content_taxonomy/content_taxonomy_options.module on line 159.
    * warning: Illegal offset type in /usr/local/apache2/htdocs/modules/content_taxonomy/content_taxonomy_options.module on line 159.
CommentFileSizeAuthor
#2 content_taxonomy-illegal-offset.patch954 bytesxtfer

Comments

Aar0n’s picture

Im also getting this error.

Any update on this?

xtfer’s picture

Assigned: Unassigned » xtfer
Status: Active » Needs review
StatusFileSize
new954 bytes

There are two related problems here. At lines 134 and 141 the following code sets Taxonomy data for saving as tags when the node is submitted:

$node->taxonomy[$field['vid']][$tid] = $tid;

However in both cases $tid is an array, which can't be used in that context (thats the illegal offset) so we just need to code the Array out.

The solution is to change the code:

$handle = $tid['value'];
$node->taxonomy[$field['vid']][$handle] = $handle;

I've tested this with all 4 widget types, they all seem to deliver the array in the same format.

As a result of this patch, Taxonomy data is saved correctly.

marcvangend’s picture

I applied the patch but unfortunately it didn't work for me. I still get the same error, nothing changed.
I noticed that I only get this error when i select the "save term lineage" option.
The other settings for my vocab are:
Hierarchy: multiple
Related terms: no
Free tagging: no
Multiple select: no /* question: is this compatible with save term lineage? */
Required: yes
Weight: 1
Use the Hierarchical Select form element for this vocabulary: yes
Save lineage: Save term lineage
Level choice: Force user to choose a term from the deepest level
Label levels: enabled
Label for the root level: Select

AD-DA’s picture

Actually the patch seems related to an other error. It changes content_taxonomy.module while the error is reported in content_taxonomy_options.module.

In content_taxonomy_options.module the line 159 where the error is reported seems to be the cause of the error:
$keys[$node_field['tids']] = $node_field['tids'];

The error occurs when the category taxonomy is setup to save the lineage of the node (using hierachical select).

Changing this line to:
$keys[$node_field['tids'][0]] = $node_field['tids'][0];
removed the error, but saved only the parent in a taxonomy with 2 levels.

This need to be tested more. I've disabled in the mean time saving the lineage of the term.

matthew_ellis24’s picture

This is the problem I'm having as well. I'll keep an eye on this but I suspect this module isn't for me as it takes quite a while to load up each menu and it isn't really feasible for use if making many nodes.

AD-DA’s picture

Actually I do not have this issue anymore with the latest version of Hierarchical Select 5.x-3.x-dev

summit’s picture

Hi,

I confirm still having this issue with the latest (july 8th) version of HS.

Greetings,
Martijn

socialnicheguru’s picture

subscribing. I have this problem for everyone but the admin account does not.

also i do not have HS enabled.

I also went back to make sure that the values for required and multiple matched the taxonomy field terms in my node content type but I still get the error.

The fix in #4 above (http://drupal.org/node/234622#comment-889836) works. I hope there are no ramifications since HS is not enabled for any of these categories that I am using.

After I upgraded, this fix no longer works.

Chris

nath’s picture

I had the error in #2 and the solution in #2 helped.

magnusk’s picture

I've also seen the line 159 error.

Would new code like the following help if it replaces that one line 159? checking whether it's an array and saving the whole array of values if so:

if (is_array($node_field['tids'])) {
  foreach ($node_field['tids'] as $key => $tid) {                
    if ($tid != 0) $keys[$key] = $tid;
  }
} else {
  $keys[$node_field['tids']] = $node_field['tids'];
}
// $keys[$node_field['tids']] = $node_field['tids'];
nath’s picture

Actually, the solution in #2 doesn't help but breaks everythig. :(

robertgarrigos’s picture

I had this same problem until I decided to force the user to choose a term from a deepest level, in the Hierarchical Select widget's settings form. Otherwise, Im havig the illegal offset error message.

Update: I changed the settings again and now it's not showing the error, although it's not saving the tags properly. I guess there is a combination of settings within the vocabulary and the widget settings which prevent from showing the error. In any case, if you choose to save the cck data as tag also, this is in the taxonomy tables, it doesn't save the right data.

robertgarrigos’s picture

I see what's triggering this error but don't know yet where in the code lies the problem. This error is being triggered because the field used as hierarchical select somehow doesn't get saved as a multiple values field in the widget settigns form. There is a combination of settings that should do so but it doesn't, in fact. What I've done is commenting a line in the code of content_taxonomy_hs.module

function content_taxonomy_hs_form_alter($form_id, &$form) {
  if ($form_id == '_content_admin_field') {
    if ($form['widget']['widget_type']['#default_value'] == 'content_taxonomy_hs') {
      //$form['field']['multiple']['#attributes'] = array('disabled' => 'disabled'); <<<<<---------------------- this line commented
      $form['field']['multiple']['#description'] = t(
        'This setting is now managed by the Hierarchical Select widget
        configuration!'
      );
    }
  }
}

By commenting this line you will be able to set the multiple value for that field, and this seems to work. The real solution, however, would be finding out where in the code of this module this flag should be set and it's not.

jdotti’s picture

Subscribe.

( i duplicate this issu here http://drupal.org/node/326620 ) .

Is the solution proposed by robertgarrigos stable ?

JD

wim leers’s picture

robbertgarrigos: content_taxonomy_hs has been removed from CVS, it should never have been committed in the first place.

Use the the Hierarchical Select module itself instead, it includes support for content_taxonomy and has been revised a lot after content_taxonomy_hs was committed.

jdotti’s picture

Hi,

And do we need to delete all *hs* files from the content_taxonomy folder module ?

JD

jdotti’s picture

Hi,

At the end, i still have this message, and i don't know what to do ...

JD

reubenavery’s picture

Subscribing.. having the same problem.

matteogeco’s picture

In my case the error comes out when I select Save options -> Both in the field settings. If I select Save as tag I don't get the error...

magnus’s picture

Status: Needs review » Closed (won't fix)

Cleanup of old issues. According to maintainer: "active development is only done for the 6.x branch! 5.x is not supported any more".
Reopen issue if problem still exist in 6.x branch.