Problem/Motivation

In ResourceController we currently call $response->addCacheableDependency() 5 times, sometimes the parameters are arrays and therefore we need to loop through many times.

Proposed resolution

Create a helper addCacheableDependency method which accepts the response object, and an array of parameters.

protected function addCacheableDependency($response, $parameters) {
  if (is_array($parameters)) {
    foreach ($parameters as $parameter) {
        $this->addCacheableDependency($response, $parameter);
    }
  }
  else {
    $response->addCacheableDependency($parameters);
  }
}

We can then call this once in the controller with a huge array of arrays of arrays.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

timmillwood created an issue. See original summary.

vadim.hirbu’s picture

jeqq’s picture

Status: Active » Needs review
jeqq’s picture

The last submitted patch, 2: update_how_addCacheableDependency_called-2636116-2.patch, failed testing.

The last submitted patch, 2: update_how_addCacheableDependency_called-2636116-2.patch, failed testing.

The last submitted patch, 4: 2636116-4.patch, failed testing.

The last submitted patch, 4: 2636116-4.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 7: 2636116-7.patch, failed testing.

  • jeqq committed 28f8979 on 8.x-1.x authored by vadim.hirbu
    Issue #2636116 by jeqq, vadim.hirbu: Update how addCacheableDependency...
  • jeqq committed 5e3271b on 8.x-1.x
    Issue #2636116 by jeqq, vadim.hirbu: Fix parameter type.
    
jeqq’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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