Notice: Undefined index: tid in hs_taxonomy_field_formatter_prepare_view() (line 402 of /modules/contrib/hierarchical_select/modules/hs_taxonomy.module).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NancyDru created an issue. See original summary.

NancyDru’s picture

Reverting to beta3 solved the problem.

madan879’s picture

Assigned: Unassigned » madan879
madan879’s picture

Assigned: madan879 » Unassigned

Hi @NancyDru,

I have checked 7.x-3.0-beta4 version as you mentioned issue. But I am not getting any error messages.

Could you please elaborate the scenario, how to got this issue. That will helpful to trace this issue and I will try to fix it..

Thanks

NancyDru’s picture

I believe it was caused by a Rule that sends an Views email. I'll try to get more info from the guy who wrote it.

sistro’s picture

I've got same issue, reverting to beta3 fixed also for me.

I believe it was caused by a Rule that sends an Views email. I'll try to get more info from the guy who wrote it.

I don't know if I understand what you mean, but I'm using Rules too but i've got this error in a view without any rules.

NancyDru’s picture

@sistro: Okay, maybe it's just a Views thing. Can you post your view, please, so the developer can test with it?

balajidharma’s picture

FileSize
161.34 KB

Able to replicate issue in Classified advertising distribution.

Tid issue

d0t101101’s picture

I have just hit this bug too after upgrading from 7.x-3.0-beta2 to 7.x-3.0-beta6. May be rolling back to beta3 as a workaround. I've been unable to figure out when/where it occurs yet, seems intermittent, but will report any discovered details here.
Thanks!

JudyPJHsu’s picture

I'm on 7.x-1.0 and am getting the exact same error.

d0t101101’s picture

@catch & @stefan.r:

Fairly certain this patch introduced this problem with every version beyond beta3 (not sure about previous versions!). Initially the views which exhibited the issue in my DEV environment had time based caching enabled, which explains why it happened intermittently. After disabling views caching, I got this error consistently.

My temporary solution is to check that a tid is set in hs_taxonomy.module before continuing, like so:

if (isset($item['tid']) && $item['tid'] != 'autocreate') {

I haven't seen any side effects of this, but can someone with deeper knowledge of this module, taxonomy and views please have a look?

.

d0t101101’s picture

Status: Active » Patch (to be ported)
FileSize
436 bytes

Patch attached.

d0t101101’s picture

Status: Patch (to be ported) » Needs review
NancyDru’s picture

With beta7:

Notice: Undefined index: tid in taxonomy_field_presave() (line 1900 of C:\wamp\www\Core7\modules\taxonomy\taxonomy.module).
Notice: Undefined index: tid in taxonomy_field_presave() (line 1900 of C:\wamp\www\Core7\modules\taxonomy\taxonomy.module).
Notice: Undefined index: tid in taxonomy_field_presave() (line 1900 of C:\wamp\www\Core7\modules\taxonomy\taxonomy.module).
Notice: Undefined index: tid in taxonomy_build_node_index() (line 1964 of C:\wamp\www\Core7\modules\taxonomy\taxonomy.module).
Notice: Undefined index: tid in taxonomy_build_node_index() (line 1964 of C:\wamp\www\Core7\modules\taxonomy\taxonomy.module).
Notice: Undefined index: tid in taxonomy_build_node_index() (line 1964 of C:\wamp\www\Core7\modules\taxonomy\taxonomy.module).
Notice: Undefined index: tid in taxonomy_build_node_index() (line 1964 of C:\wamp\www\Core7\modules\taxonomy\taxonomy.module).
Notice: Undefined index: tid in taxonomy_build_node_index() (line 1964 of C:\wamp\www\Core7\modules\taxonomy\taxonomy.module).
Notice: Undefined index: tid in taxonomy_build_node_index() (line 1964 of C:\wamp\www\Core7\modules\taxonomy\taxonomy.module).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'tid' cannot be null: INSERT INTO {taxonomy_index} (nid, tid, sticky, created) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3), (:db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7), (:db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11), (:db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15), (:db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19), (:db_insert_placeholder_20, :db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23), (:db_insert_placeholder_24, :db_insert_placeholder_25, :db_insert_placeholder_26, :db_insert_placeholder_27), (:db_insert_placeholder_28, :db_insert_placeholder_29, :db_insert_placeholder_30, :db_insert_placeholder_31), (:db_insert_placeholder_32, :db_insert_placeholder_33, :db_insert_placeholder_34, :db_insert_placeholder_35), (:db_insert_placeholder_36, :db_insert_placeholder_37, :db_insert_placeholder_38, :db_insert_placeholder_39); Array ( [:db_insert_placeholder_0] => 37283 [:db_insert_placeholder_1] => 1330 [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => 1465303317 [:db_insert_placeholder_4] => 37283 [:db_insert_placeholder_5] => 1323 [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => 1465303317 [:db_insert_placeholder_8] => 37283 [:db_insert_placeholder_9] => 24 [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => 1465303317 [:db_insert_placeholder_12] => 37283 [:db_insert_placeholder_13] => [:db_insert_placeholder_14] => 0 [:db_insert_placeholder_15] => 1465303317 [:db_insert_placeholder_16] => 37283 [:db_insert_placeholder_17] => 120 [:db_insert_placeholder_18] => 0 [:db_insert_placeholder_19] => 1465303317 [:db_insert_placeholder_20] => 37283 [:db_insert_placeholder_21] => 126 [:db_insert_placeholder_22] => 0 [:db_insert_placeholder_23] => 1465303317 [:db_insert_placeholder_24] => 37283 [:db_insert_placeholder_25] => 170 [:db_insert_placeholder_26] => 0 [:db_insert_placeholder_27] => 1465303317 [:db_insert_placeholder_28] => 37283 [:db_insert_placeholder_29] => 171 [:db_insert_placeholder_30] => 0 [:db_insert_placeholder_31] => 1465303317 [:db_insert_placeholder_32] => 37283 [:db_insert_placeholder_33] => 172 [:db_insert_placeholder_34] => 0 [:db_insert_placeholder_35] => 1465303317 [:db_insert_placeholder_36] => 37283 [:db_insert_placeholder_37] => 174 [:db_insert_placeholder_38] => 0 [:db_insert_placeholder_39] => 1465303317 ) in taxonomy_build_node_index() (line 1981 of C:\wamp\www\Core7\modules\taxonomy\taxonomy.module).

The above patch makes no difference.

NancyDru’s picture

This is happening during node_save(). My code for invoking that is:

  $update_node = FALSE;

  // Get the fields that are in that group.
  $x = db_query("SELECT data FROM {field_group} "
    . "WHERE group_name = 'group_associated_tracker_details' "
    . "AND bundle = 'materials' ")->fetchField();
  $data = unserialize($x);

  // Get the Tracker from which to copy data.
  $tracker = node_load($node->field_tracker[LANGUAGE_NONE][0]['target_id']);

  // Check each field.
  foreach ($data['children'] as $field_name) {
    if ($field_name == 'field_tracker') {
      continue;
    }

    // If the Tracker has data and the Material does not, copy the data.
    if (isset($tracker->{$field_name}[LANGUAGE_NONE][0])
    && !isset($node->{$field_name}[LANGUAGE_NONE][0])) {
      $node->{$field_name} = $tracker->{$field_name};
      $update_node = TRUE;
    }
  }

  // If any fields changed, save the node.
  if ($update_node) {
    node_save($node);
    if ($redirect) {
      drupal_set_message(t('Tracker data merged.'));
      // Force redisplay.
      drupal_goto("node/$node->nid");
    }
  }
stefan.r’s picture

Does the patch in #12 fix this?

NancyDru’s picture

Nope, sorry.

travelvc’s picture

[EDIT]

Sorry I have changed my position on this.

The patch in #11 doesn't work for me. When the cache is cleared the error returns even with the suggested fix from #11.

sylus’s picture

Attaching an updated patch that applies for me.

Anas_maw’s picture

Patch #19 does not works for me.

The main issue that this commit change the array index which will not be similar to items array.

I created a patch that solve this issue by getting array index from items array instead of selection array

skylord’s picture

+1 for #20 for issue investigation. I suggest to fix selection array indexes instead of deep key searching in items array (actually, array_search not needed there inside the loop). See patch attached.

skylord’s picture

Sorry, previous patch was a little wrong - try this please.

Anas_maw’s picture

@skylord

It's a good idea, I tested your patch and it's work well also.

Thanks.

SkyFlame’s picture

FileSize
67.67 KB

Some kind of this problem I've acquired while using Simplenews Module. It appears when I switch "Format of letter" (in settings of any "Newsletter category") to "HTML". With "Plain Text" it's OK because Hierarchical links (and any other links) don't work in this format of letter.

Errors

So the problem partly was solved by skylord's patch in message #22: the errors don't appear now, but in letters I send with Simplenews the Hierarchical links act like just text, not as links, and they stand in the end of letter: in node (on which based the letter) the Hierarchical links placed in the top of the node as should. Is that normal? Should they act like so? For me they damage an appearance of the letter being a text (they make no sense in this case).

UPD:
It is not for only Hierarchical links. It is for all links which are created with fields in type of content.

shi99’s picture

The patch in #22 worked for me with the latest dev.

Thanks

NancyDru’s picture

Possibly related: #2831247: Undefined index

Patch in #22 (plus going to beta7) seems to fix both problems for me.

  • skylord authored dced41e on 7.x-3.x
    Issue #2719141 by skylord, d0t101101, Anas_maw, sylus, SkyFlame,...
stefan.r’s picture

Status: Needs review » Fixed

Committed and pushed to 7.x-3.x, thanks!

Status: Fixed » Closed (fixed)

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