Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Views' node_preprocess hook can be passed node objects with a views object attached without the views theme system initialized. If this view uses a node_view row plugin, then function node_row_node_view_preprocess_node will be called without the required file being included.
Steps to reproduce:
- Create a block view with rendered node display, e.g. teaser
- Make this view select a particular node, e.g. node 1
- Set this view to be cached
- Place this block on a page
- Add another block, or panel or whatever with this same node rendered on the page, using any view mode, with no cache settings, loading after the cached view
- The node object passed to node_view will contain the views object and throw a fatal error in views_preprocess_node
I added a few lines to conditionally load this file if function does not exist, as you can see in the attached patch, but I am sure there is a more reasonable way to do this.
Comment | File | Size | Author |
---|---|---|---|
#3 | views-view-cached-node-conditional-include-2067459-1.patch | 590 bytes | Y.sa |
Comments
Comment #1
wesnick CreditAttribution: wesnick commentedComment #3
Y.sa CreditAttribution: Y.sa commentedSame probleme here, the patch is working.
Here is another try to pass the robot.
Comment #4
Y.sa CreditAttribution: Y.sa commentedComment #5
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 4 year old patch in #3 to views.module applied cleanly to the latest views 7.x-3.x-dev and if still relevant needs to be reviewed.