Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | 1808712.patch | 1.01 KB | krishworks |
#1 | redundant-token-processing-1808712-1.patch | 695 bytes | kevin.dutra |
Comments
Comment #1
kevin.dutra CreditAttribution: kevin.dutra commentedHere's a simple patch to bring that out of the loop.
Comment #2
dawehnerThis 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
Comment #3
xjmComment #4
krishworks CreditAttribution: krishworks commentedapplied patch in #1 on 8.x
Comment #5
aspilicious CreditAttribution: aspilicious commentedLooks good...
Comment #6
catchCommitted/pushed to 8.x, thanks!