Hi. I am seeing a sporadic bug when using hierarchical_select (latest 6.x-3.x-dev) with content_taxonomy (latest 6.x-1.x-dev).

Options used include: "Save term lineage", "Force the user to choose a term from a deepest level"

I have a hierarchy with 3-4 levels. I have it attached to a node and it works fine.

However, sometimes after creating a node and tyring to save it, I get this message:

warning: Illegal offset type in ....\sites\all\modules\content_taxonomy\content_taxonomy.module on line 166.
warning: Illegal offset type in ....\sites\all\modules\content_taxonomy\content_taxonomy.module on line 166.
warning: Illegal offset type in ....\sites\all\modules\content_taxonomy\content_taxonomy.module on line 166.
warning: Illegal offset type in ....\sites\all\modules\content_taxonomy\content_taxonomy.module on line 166.
etc...
user warning: Duplicate entry '1-389' for key 1 query: INSERT INTO term_node (nid, vid, tid) VALUES (116, 389, 1) in ...\modules\taxonomy\taxonomy.module on line 693.
warning: Illegal offset type in isset or empty in ...\modules\taxonomy\taxonomy.module on line 1023.
warning: Illegal offset type in ....\modules\taxonomy\taxonomy.module on line 1024.
warning: Illegal offset type in ....\modules\taxonomy\taxonomy.module on line 1027.
etc....
mb_eregi_replace() expects parameter 3 to be string, array given in ....\sites\all\modules\pathauto\pathauto.inc on line 184.
etc...

Even though the node has saved the hierarchy correctly, and I can then see it correctly in view mode, when I try to edit the node, I subsequently get:

warning: Invalid argument supplied for foreach() in ....\sites\all\modules\hierarchical_select\includes\theme.inc on line 372.
warning: Invalid argument supplied for foreach() in ....\sites\all\modules\hierarchical_select\includes\theme.inc on line 372.
etc.

and then the edit form loads the hierarchy without any entries at all!.

Please any thoughts on what is causing this and how to resolve? Thanks

CommentFileSizeAuthor
#12 hs_taxonomy.module-815796.patch471 bytestacituseu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Priority: Critical » Normal

The Content Taxonomy module regularly has compatibility issues. Probably something has changed that causes this. Or it could be a bug in HS, of course :)

I'm in the middle of my exam period right now, so I can't help you for another couple of weeks. Sorry.

Definitely not critical because otherwise there would be many more of these reports.

zeezhao’s picture

Did a bit more debugging via devel, and on the nodes causing the issue there are some nulls in the array for the hierarchical select field, even though no nulls in the actual heirarchy. So it looks like an issue during saving?

Please if you can recommend compatible older versions, I'll try that out. The affected nodes can only be fixed manually though.

Critical for me, as nearly live...

Hope your exams go well. Thanks.

Wim Leers’s picture

Status: Active » Postponed (maintainer needs more info)

That's the problem with Content Taxonomy: no recent stable releases, so I can't tell you to go back to version x. Just try to go back to an older -dev snapshot. Or maybe that RC from August last year works. Don't know. That module is a terrible mess.

zeezhao’s picture

Ok, I tried various combinations of old versions of both modules but no solution.

Did some debugging in hierarchical_select\includes\theme.inc where the error message appears, and there are NULLs being passed to function _hierarchical_select_options($element)

So what is not clear to me as I am very new to this code, and please maybe you can explain to me:

- If the hierarchy is correct in the "view" mode, how does a heirarchy get transformed from "view" into the "edit" mode?

- what are the likely causes if view mode is fine, for the edit mode to be corrupt?

Please let me know, if you have the information in your head, so I can track down the bug.

Thanks for your help. Hope exams are fine so far.

zeezhao’s picture

The only other thing to mention is that I am using an implementation of hook_field_access() to hide or show the hierarchical_select fields depending on certain criteria during "edit" mode for a node.

My question is that, can you forsee any issue with this?

zeezhao’s picture

Status: Postponed (maintainer needs more info) » Active

I did more debugging, and I think I have tracked down the issue.

When using hook_field_access() to hide a hierarchical_select field, for some reason, the 'tids' array contains NULLs, during preview. For instance, in an example I have:

using drupal_set_message( t( "field_xxx = " . var_export($node->field_xxx, TRUE)));

I get (when field is hidden, during preview ):

field_xxx = array ( 0 => array ( 'value' => NULL, ), 1 => array ( 'value' => '94', ), 2 => array ( 'value' => '91', ), 3 => array ( 'value' => '90', ), 'tids' => array ( 0 => array ( 'value' => NULL, ), 1 => array ( 'value' => NULL, ), ), )

instead of (when field is not hidden, during preview):

field_xxx = array ( 0 => array ( 'value' => '94', ), 1 => array ( 'value' => '91', ), 2 => array ( 'value' => '90', ), 'tids' => array ( 0 => array ( 'value' => '90', ), 1 => array ( 'value' => '91', ), 2 => array ( 'value' => '94', ), ), )

So it looks like hook_field_access has an impact.

Please I need your advice on the best way to resolve it, as I am not familiar with hierarchical_select code. Thanks for your help.

edit:
Decided to switch to a hook_form_alter() implementation as this seems more compatible with hierarchical_select. hook_field_access() implemetation does not work well hierarchical_select. Will keep you posted.

Wim Leers’s picture

And this is why Content Taxonomy is a hornet's nest. I won't spend any more time on fixing this, but I'll gladly commit a patch you provide.

zeezhao’s picture

No patch, as what I eventually did was use a hook_form_alter() implementation as this seems more compatible with hierarchical_select. I also did a bit of defensive coding to ensure values set.

In general, it seems hs/ct potentially gives issue with data storage when a user previews before saving. Hence the issue when using hook_field_access().

Wim Leers’s picture

Status: Active » Closed (cannot reproduce)
tacituseu’s picture

Status: Closed (cannot reproduce) » Active

Had same problem, caused on preview inside hs_taxonomy_form_alter() by invocation of taxonomy_preview_terms() with $node->taxonomy already containing objects. Same thing was fixed in core by #341136: Taxonomy selection loses value on button click (commit http://drupalcode.org/viewvc/drupal/drupal/modules/taxonomy/taxonomy.mod...)

Wim Leers’s picture

Status: Active » Closed (won't fix)

See the updated project page:

Note: the Content Taxonomy module integration is no longer supported. Patches are accepted and committed, but the maintainer does no longer want to fix bugs with this integration. The reason is simple. It's a nightmare. It makes one suicidal. Content Taxonomy is rotten. It needs to die. Thank god it won't be necessary to port this functionality to Drupal 7

tacituseu’s picture

Assigned: Unassigned » tacituseu
Status: Closed (won't fix) » Needs review
FileSize
471 bytes

Patch attached, it updates the part of a boilerplate copied from taxonomy_form_alter() to be in sync with what's in core now. Bug is in hs_taxonomy.module so it's not hs_content_taxonomy.module specific.

Wim Leers’s picture

Title: warning: Illegal offset type in » HS Taxonomy loses selection upon node preview (patch copied from core)
Component: Code - Content Taxonomy » Code - Taxonomy

My bad! I read too quickly over this issue — which obviously had an incorrect component. Thank you very much for the patch! :)

Committed!

http://drupal.org/cvs?commit=495052

Wim Leers’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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