When working with hierarchical_select, an error occurs.

PHP Fatal error: Cannot unset string offsets in .../comment_driven_cck.module on line 353

Please see 5 screenshots.

1. When not changing a term, an error occurs.
2. When changing a term, an error occurs.
3. When changing a term to <none>, an error doesn't occur.
4. HS settings
5. Term list

Comments

Takafumi’s picture

FYI, an error occurs in both previewing and submitting.

arhak’s picture

version numbers?
- CCK
- content_taxonomy
- HS

Takafumi’s picture

It tested with the following versions:

- CCK
6.x-2.6 / latest dev

- content_taxonomy
6.x-1.0-rc2 / latest dev

- HS
6.x-3.0 / latest dev

Takafumi’s picture

FYI, I grabbed some values as follows.

about line 291:

  // wrap separated item into items
  if ($separated_item) {
    $default = array($default);
    $value = array($value);
    drupal_set_message(t('line 294: $default = @default / $value = @value', array('@default' => var_export($default, true), '@value' => var_export($value, true))));
  }

about line 345:

  // unwrap separated item from items
  if ($separated_item) {
    // pick only the first item
    // since remaning items were filled with equivalent empty CCK values
    drupal_set_message(t('line 349: $default = @default / $value = @value', array('@default' => var_export($default, true), '@value' => var_export($value, true))));
    $default = array_shift($default);
    $value = array_shift($value);
    // dismiss non-value meta
    // '_weight' should come cleared from 'presave' (_content_sort_items)
    // but it won't harm to cover it here as well (just in case)
//    unset($value['_weight'], $value['_error_element']);

results:

    * line 294: $default = array ( 0 => array ( 0 => '1', ), ) / $value = array ( 0 => '1', )
    * line 349: $default = array ( 0 => array ( 'value' => NULL, ), ) / $value = array ( 0 => '1', )
Takafumi’s picture

When term-2 is selected:

    * line 294: $default = array ( 0 => array ( 0 => '1', ), ) / $value = array ( 0 => '2', )
    * line 349: $default = array ( 0 => array ( 'value' => NULL, ), ) / $value = array ( 0 => '2', )

When "none" is selected:

    * line 294: $default = array ( 0 => array ( 0 => '1', ), ) / $value = array ( 0 => NULL, )
    * line 349: $default = array ( 0 => array ( 'value' => NULL, ), ) / $value = array ( 0 => array ( 'value' => NULL, ), )
arhak’s picture

Title: PHP Fatal error: Cannot unset string offsets » support hs_content_taxonomy widget
Status: Active » Needs review
StatusFileSize
new3.61 KB

the attached patch still has a pending limitation:
- if the vocabulary is multiple you should select save_lineage for hs_content_taxonomy
- otherwise you shouldn't select save_lineage nor dropbox
- i.e. the multiplicity of the actual taxonomy vocabulary has to match the multiplicity of hs_content_taxonomy

the multiplicity issue might be addressed as well, but after sorting this out first
and it is due to what hs_content_taxonomy states:

Important!

  • Due to limitations of CCK, there is a separate form to configure this Hierarchical Select widget's settings.
  • The Multiple values field setting is now managed by the Hierarchical Select module: it will be enabled when either the Enable the dropbox or Save term lineage settings (or both) are enabled.

also note that the attached patch intends to delegate content_taxomony widgets to comment_driven_taxo,
so whenever content_taxonomy widget issues arise they most likely will be reflected as being comment_driven_taxo issues
e.g. right now, violating the multiplicity match will display the following assertion:
Assertion failed: "$voc->multiple != HS save_lineage ..."
followed by two warning: array_diff() [function.array-diff]: Argument #X is not an array in .../comment_driven.eq.inc

we'll sort that out later,
note that it is due to hs_content_taxonomy handling multiplicity out of CCK's API

arhak’s picture

@#3 thanks

@#4-5 I really appreciate your effort to provide detailed reports
the screenshots in the original post were very explicit (images, plus their descriptions)
but this dumped data was not, and I suggest you not to waste time trying to provide details around the lines which reflected the errors, since they aren't used to be what caused it
I don't like the idea of wasting anybody's time

arhak’s picture

the proposal of patch @#6 is to delegate taxonomy widgets to comment_driven_taxo
but it seems to me that vanilla content_taxonomy uses same widgets than CCK, and therefore those shouldn't be delegated or CD_taxo shall fail

delegation should be then conditioned to the type of widget in use
currently unstable6 takes care of CCK's widgets (vanilla content_taxonomy)
but the patch proposed @#6 while addressing other kind of taxonomy widgets stops caring about CCK's widgets

Takafumi’s picture

#6 patch works fine for me though it has some limitations.
However, I also still like using core of CCK's widgets and/or Multiselect widget.
So, would you please give an option so that these widgets can be used by trade-off?

arhak’s picture

no trade-off is needed, everything can be supported (IF the proposed patch is working as expected/described)

I just made a quick patch for review, limitations are temporal,
since multiplicity issue of hs_content_taxonomy needs review,
but I trust its maintainer's judgement and code integrity,
it would be just a matter of making comment_driven support a different API (hs_content_taxonomy's multiplicity differing from vocabulary's multiplicity)

I also still like using core of CCK's widgets

when making the quick patch, I didn't realized that I was cutting off CCK's widgets, and delegated everything to comment_driven_taxo,
it would just a matter of merging both supports,
they are not incompatible at all

and/or Multiselect widget

I'm not sure what you meant
CCK's widget? hs_content_taxonomy widget?
with this patch applied you can use multiplicity of hs_content_taxonomy, the limitation is that it has to be the same multiplicity of the vocabulary (i.e. "multiple voc with multiple HS" or "single voc with single HS"), since there is an assertion guarding for that, which should be lessen (we'll get there)

in the meantime, please, be sure there won't be any surprise,
the proposed patch has to be right for the above statements to be truthful

Takafumi’s picture

StatusFileSize
new65.49 KB
new62.35 KB
new62.83 KB
new64.17 KB
new60.97 KB
new58.53 KB

Ok, it seems #6 patch works fine.
Please see some screenshots.

1-1. changes a single term
1-2. previewing it
1-3. submitted it

2-1. adds multiple term
2-2. previewing it
2-3. submitted it

arhak’s picture

Status: Needs review » Needs work

@#11 very useful, thanks a lot
I'll be back to you soon

arhak’s picture

Status: Needs work » Needs review
StatusFileSize
new8.52 KB

now it should have no limitations

it should not break any vanilla content_taxonomy widgets:
- selects
- radios/checkboxes
- autocompletion

remember that hs_content_taxonomy is being delegated to comment_driven_taxo
which has to be considered when reporting issues that might show up as comment_driven_taxo issues

arhak’s picture

Status: Needs review » Fixed

committed to HEAD

PS: HS dropbox hasn't been tested at all,
since it was being ignored (assertion mentioned at #6), now it is supported as well

Takafumi’s picture

I tested on hierarchical_select widget, content_taxonomy's widgets, and Multiselect widget;

- hierarchical select
- autocomplete
- select list
- checkboxes/radios
- Multiselect

It seems these are now working properly with comment_driven.
Thanks a lot for your great work:)

arhak’s picture

@#15 great news

BTW, the above dropbox note (#14) was valid when having dropbox without save_lineage
since save_lineage was properly supported at the time (obviously, as they were used for #11 screenshots)

BenK’s picture

Keeping track of this thread...

Status: Fixed » Closed (fixed)

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