Hi

Not sure if this is a bug, or if I'm just using Views wrong. I couldn't find any issues on this, why I'm assuming the latter.

If enabling time based caching for a View, and one of the nodes in this view is deleted, the pages displaying the views dies with the following error:

• Notice: Undefined index: 4 in views_plugin_row_node_view->render() (line 102 of/www/drupal7/sites/all/modules/views/modules/node/views_plugin_row_node_view.inc).
• Notice: Undefined property: stdClass::$type in _node_extract_type() (line 370 of/www/drupal7/modules/node/node.module).
• Notice: Undefined property: stdClass::$nid in node_build_content() (line 1359 of/www/drupal7/modules/node/node.module).
• EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids()(line 7501 of /www/drupal7/includes/common.inc).

Steps to reproduce:
1.) Enable the "Front page" view.
2.) Edit it and add time-based caching 1hour/0sec under the advanced section.
3.) Create a node (e.g. Article) and check "Promote to frontpage"
4.) Goto /frontpage to see that view.
5.) Delete the node
6.) Goto /frontpage and observe the error.

It makes sense of course, that views is unable to find the deleted node. But that it results in an exception is not very neat. It may be argued where the bug lies, views or core. Clearing the cache makes the problem go away, but if this is necessary it should somehow happen automatically (although I suspect that could prevent the cache on certain sites from ever getting properly "warm").

Then again, I might just be using it wrong.

Any suggestions?

Comments

denny84’s picture

Confirmed, "Rendered Output" option when set to "Never Cache" creates this error.

denny84’s picture

StatusFileSize
new30.5 KB

Attachment

denny84’s picture

StatusFileSize
new30.5 KB

Attachment

gielfeldt’s picture

StatusFileSize
new461 bytes

The file: modules/node/views_plugin_row_node_rss.inc has this code (in views_plugin_row_node_rss->render()):

    // Load the specified node:
    $node = $this->nodes[$nid];
    if (empty($node)) {
      return;
    }

Whereas the file: modules/node/views_plugin_row_node_view.inc does not.

This means the rss style (e.g. on /rss.xml) is immune to this error, but regular node view is not.

The attached patch implements the check in modules/node/views_plugin_row_node_view.inc. If the node is deleted, it will output an empty div, so this is probably not the best solution (e.g. messes up odd/even rows, etc). However, it's better than the current way it works.

I'm thinking the best solution would be to weed out invalid entries in the pre_render() method? But this requires $values to passed by reference all the way through.

brayo4’s picture

Had similar issue trying to use views accordion on a view. when i changed the format to something else....error gone. Don't know what to make of it. using views and views accordion -dev.

brayo4’s picture

Had similar issue trying to use views accordion on a view. when i changed the format to something else....error gone. Don't know what to make of it. using views and views accordion -dev.

gielfeldt’s picture

Status: Active » Fixed

Those tickets do not address the same issue. However, this issue has been fixed by #1484336: Undefined index in views_plugin_row_node_view.inc

Status: Fixed » Closed (fixed)

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