When retrieving the rendered values for tokens on a field, the method that allows you to add additional tokens is called once for every field in the view definition, which is just wasted processing.

From views_handler_field:

  function get_render_tokens($item) {
    ...

    // Now add replacements for our fields.
    foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) {
      if (isset($handler->last_render)) {
        $tokens["[$field]"] = $handler->last_render;
      }
      else {
        $tokens["[$field]"] = '';
      }
      $this->add_self_tokens($tokens, $item);   // <-- this should be outside the loop

      // We only use fields up to (and including) this one.
      if ($field == $this->options['id']) {
        break;
      }
    }
    ...
  }

Granted, work on work on Views seems to be dedicated to Views 3, but since the upgrade path from 2 to 3 still isn't worked out, I figured I'd toss this out there.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kevin.dutra’s picture

Status: Active » Needs review
FileSize
695 bytes

Here's a simple patch to bring that out of the loop.

dawehner’s picture

Version: 6.x-2.x-dev » 8.x-3.x-dev

This totally makes sense, but i'm not sure whether this change will be added to 6.x-2.x
as especially 6.x-2.x is in a only-critical-bugs-modus.

Let's approach the usual port worflow

xjm’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 8.x-3.x-dev » 8.x-dev
Component: Code » views.module
Status: Needs review » Needs work
krishworks’s picture

Status: Needs work » Needs review
FileSize
1.01 KB

applied patch in #1 on 8.x

aspilicious’s picture

Status: Needs review » Reviewed & tested by the community

Looks good...

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Status: Fixed » Closed (fixed)

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