2

The internal entity cache is interfering with display modes on my site. I have a view that is displaying a node with a custom display mode, 'slideshow'. When I look at the view from a page that displays the entity in a different display mode along side the slideshow block, the node is rendered as that mode and not slideshow, but the other nodes in the block display using 'slideshow'.

hacking core, and rewriting node.module:

node_load_multiple($nids = array(), $conditions = array(), $reset = FALSE)

to

node_load_multiple($nids = array(), $conditions = array(), $reset = TRUE)

resolves the issue. Under performance, caching is on for anonymous users. This is occurring while logged in. I've tried entitycache in the past, but it is not installed. Drush cc all does nothing. I'm open to any ideas that may help.

Here is the offending part of a backtrace that I managed to pull up:

It looks like somewhere in theme.inc the wrong template is being chosen:

10 (Array, 4 elements) file (String, 52 characters )
/home/mysite/git/mysite/includes/them...
/home/mysite/git/mysite/includes/theme.inc line (Integer) 1185
function (String, 21 characters ) theme_render_template | (Callback)
theme_render_template(); 
args (Array, 2 elements) 
0 (String, 70 characters ) sites/all/themes/mysite/templates/ds/ds-...
  sites/all/themes/mysite/templates/ds/ds-1col--node-post.tpl.php 
1 (Array, 86 elements)

It only affects the node being rendered currently, which isn't a post and shouldn't be using that template when it shows up in the slideshow block. I've grepped around for theme_hook_suggestions but haven't found any.

---EDIT--- I've tracked it down to this code in views:

 function pre_render($values) {
    $nids = array();
    foreach ($values as $row) {
      $nids[] = $row->{$this->field_alias};
    }
    $this->nodes = node_load_multiple($nids);
  }

  function render($row) {
    if (isset($this->nodes[$row->{$this->field_alias}])) {
      $node = $this->nodes[$row->{$this->field_alias}];
      $node->view = $this->view;
      $build = node_view($node, $this->options['view_mode']);

      return drupal_render($build);
    }

For what ever reason, node_load_multiple is returning the current node being viewed with the type set to 'post', instead of the correct content type. Why would there be malformed nodes in the site's internal cache?

2
  • Is caching disabled in the view? Check by editing the view and looking under Advanced:Other:Caching. I would also check the call to node_load_multiple and make sure it is being called with the correct $reset parameter, rather than changing the core default.
    – Triskelion
    Mar 9, 2013 at 17:36
  • Caching is disabled on the view
    – Arosboro
    Mar 9, 2013 at 20:05

1 Answer 1

2

node_load_multiple() is using entity_load() and should not interfere with the rendering of your node because it only handles the loading from database, not rendering.

The node controller is the DefaultEntityController which implements a static cache, which (as of code) does not respect conditions used by loading. This might interfere. Are you using special conditions here? how does the $conditions array look like?

Are you using views to render that specific page? then it could be problem with contextual arguments and caching see: How to get Views caching working with contextual filters?

2
  • I'm using views to render the block, but the page is displayed without views.
    – Arosboro
    Mar 9, 2013 at 20:09
  • The arguments to node load, are 314 (nid), NULL, and FALSE.
    – Arosboro
    Mar 9, 2013 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.