When not using any arguments the current code executes and renders the same view output for every row in the parent view. Even when the parent view has regular caching enabled this still adds a lot of unnecessary code to the critical path. The attached patch adds a simple static caching layer.

This could potentially be extended to work with arguments also (by adding a 3rd dimension to the array), but that doesn't add any value unless you are adding fields multiple times (see idea in #1920730: Provide a way to retrieve values from field based views).

CommentFileSizeAuthor
#4 1920740-4.patch2.68 KBdamiankloip
static-cache.patch3.2 KBOwen Barton
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip’s picture

Status: Needs review » Needs work

I'm definitely not opposed to this idea!

+++ b/views_field_view_handler_field_view.incundefined
@@ -355,6 +355,8 @@ class views_field_view_handler_field_view extends views_handler_field {
+    static $cached = array();

We might as well just have this as a property on the class? Running is slightly different in that respect.

Owen Barton’s picture

Would moving it to the class make a difference in functionality, given that it is only used by the one function?

damiankloip’s picture

Doesn't matter that it's just used in one function I guess. It's just using a property on the class to do this instead of a static variable.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
2.68 KB

I was thinking something like this.

damiankloip’s picture

#4: 1920740-4.patch queued for re-testing.

damiankloip’s picture

Status: Needs review » Fixed

I've just gone ahead and committed the patch from #4, passes tests, and doesn't seem to break things :)

Status: Fixed » Closed (fixed)

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