Backport #2530634: Value of last_render_text leaks into the next Dropbutton.

This is the code I'm using at the moment.
Is $this->view->row_index equivilant to $values->index?

views_handler_field.inc

  class views_handler_field extends views_handler {
    ...
    public $additional_fields = array();

+   protected $last_render_index;
+
    /**
     * Construct a new field handler.
     */
    ...
    public function advanced_render($values) {
+     // Clean up values from previous render calls.
+     if ($this->last_render_index != $this->view->row_index) {
+       $this->last_render_text = '';
+     }
+
      ...
+     // If we rendered something, update the last render index.
+     if ((string) $this->last_render !== '') {
+       $this->last_render_index = $this->view->row_index;
+     }
+
      return $this->last_render;
    }
    ...
  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MustangGB created an issue. See original summary.

MustangGB’s picture

Status: Needs work » Needs review
FileSize
1.36 KB

This has been working great for me for the last couple of years, so here's a patch.

DamienMcKenna’s picture

Status: Needs review » Reviewed & tested by the community
Parent issue: » #3118500: Plan for Views 7.x-3.25
Related issues: +#2530634: Value of last_render_text leaks into the next Dropbutton

Thanks MustangGB. Let's include it in the next release.

renatog’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
27.18 KB

There are some extra spaces on this line

renatog’s picture

Status: Needs work » Needs review
FileSize
1.35 KB

The same patch, I'd just updated extra spaces

renatog’s picture

Status: Needs review » Reviewed & tested by the community

Keeping the status because the patch's logic is the same

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks!

MustangGB’s picture

Thanks.

Status: Fixed » Closed (fixed)

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