Hi@all,

the static cache of the function eva_get_views doesn't work if there are no views available. This couse the function to be fully executed each time it is called and this behavior slows down the (my) site dramatically as soon as multiple entities (in my case there are > 80) are viewed during one request.

Solution:
The static cache variable $used_views shold be set even if no views were found (e.g. to an empty array).

Comments

mkadin’s picture

Hmmm...isn't your solution exactly what's being done in the end of eva_get_views() ...

 // Now spit back the data.
  if (isset($type) & isset($used_views)) {
    return isset($used_views[$type]) ? $used_views[$type] : array();
  }
  else {
    return isset($used_views) ? $used_views : array();
  }
braindrift’s picture

@mkadin: Thanks for your reply.

In the end of eva_get_views just an empty array is being returned but the $used_views is being left null. I'm recommending to set (initialize) $used_views to an empty array so the code (lines 131-154) is not executed multiple times during the same request if no views are returned

$views = views_get_applicable_views('uses hook entity view');

on line 137.

dendie

mkadin’s picture

Status: Active » Needs review
StatusFileSize
new453 bytes

Makes sense to me...this look good?

mkadin’s picture

StatusFileSize
new396 bytes

Whoops...wrong spot...i meant to put it here.

braindrift’s picture

I think the first one (#3) was better.
Reason: if eva_get_views is called with $reset = FALSE and $used_views is set in line 121 (like it's done in patch #4), the if block on line 131 will not be executed although it should.

braindrift’s picture

Status: Needs review » Needs work
mkadin’s picture

Status: Needs work » Fixed

Wow, can't believe I never committed this. committed to HEAD. Might be a while before we see a new package though.

Status: Fixed » Closed (fixed)

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