I enabled Page Manager and created a simple variant to display Node Content in a single Panels (7.x-3.0) column for Article types. It seems to work, but I get this notice at the top of each displayed article:

Notice: Undefined offset: 3 in _token_filter_filter_tokens() (line 36 of /home/user/website.com/sites/all/modules/token_filter/token_filter.module).

Here is the function in question:

function _token_filter_filter_tokens($text, $filter, $format, $langcode, $cache, $cache_id) {
  $data = array();
  $options = array();

  // Attempt to fetch the entity that is being viewed via a backtrace to the
  // field_attach_view($entity_type, $entity) function and parameters §if found.
  $backtrace = debug_backtrace();
  foreach ($backtrace as $caller) {
    if ($caller['function'] == 'field_attach_view') {
      $entity_type = $caller['args'][0];
      $entity = $caller['args'][1];
      $token_type = token_get_entity_mapping('entity', $entity_type);
      $data[$token_type] = $entity;
      // Use the proper language code that field_attach_view was called with.
      if ($langcode = $caller['args'][3]) {                                                  <-  THIS IS LINE 36
        $language_list = language_list();
        if (!empty($language_list[$langcode])) {
          $options['language'] = $language_list[$langcode];
        }
      }
      break;
    }
    elseif ($caller['function'] == '_drupal_bootstrap_full' || $caller == 'menu_execute_active_handler') {
      // There is no point in going back this far, so just stop.
      break;
    }
  }

  return token_replace($text, $data, $options);
}

the token_filter module is version 7.x-1.1

Any help?

Comments

merlinofchaos’s picture

Project: Chaos Tool Suite (ctools) » Token Filter
Version: 7.x-1.0-rc1 » 7.x-1.x-dev
Component: Page Manager » Code

Seems like this is token filter module's bug?

JSCSJSCS’s picture

Disabling the token_filter module does stop the error notice, but that is not the desired fixed of course. I cross posted in the token_filter issue queue. I just have to wait and see if anyone answers there. Thanks.

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

If I'm not mistaken, this has already been fixed in the latest 7.x-1.x-dev. Please give that version a try.

JSCSJSCS’s picture

Thanks Dave, the dev version did not respond with he error. :)

lee20’s picture

I had this same issue with rc1. After updating to the dev version tokens are not being replaced at all for me.

gmclelland’s picture

I just ran into this problem and the dev version seemed to fix it for me.

alfthecat’s picture

Had the same issue, dev version only partially fixed it for me. Now I don't get the notice every time but only for a certain content type. I don't really know why that is... It's a basic content type with just a term reference field added to it. Nothing else.

laszlo.kovacs’s picture

Version: 7.x-1.x-dev » 7.x-1.1
StatusFileSize
new704 bytes

This patch works for me.

voleger’s picture

Patch from #8 works great for me. Thanks!

asherry’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new373.33 KB

This patch seems logical to me, and also fixes the error for our site. I've attached some output as to the prior function that we have that isn't populating the language if that helps, not sure how much context you need.

We have a token that's inside a panels pane, so, that's panels using ctools to call token_filter.

I'm going to switch this back to needs review.

Anonymous’s picture

Patch #8 solved this issue for me.

darvanen’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Needs review » Closed (outdated)

I'm picking up the maintenance of this module, but I'm more familiar with the D8 version than D7.

The patch no longer applies to dev and the argument in use has changed as well, so I'm putting this to outdated until/unless someone finds this is still an issue on dev.

darvanen’s picture

Right, so the change in dev is from #1438810: expand token guessing to views. I'll do a bit more testing around this to see if it needs to be revived.

darvanen’s picture

Status: Closed (outdated) » Fixed

Yeah I agree with Dave, this was fixed in dev... a long time ago.

The callback we're processing now doesn't allow $langcode as an optional argument.

Status: Fixed » Closed (fixed)

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