The following Views field handlers do no check if a node's content type is webform enabled before rendering links:

  • webform_handler_field_node_link_edit
  • webform_handler_field_node_link_results

Sample Use Case

A site builder creates a view of content with various operations links. The links might include edit node, edit form, and form results. Nodes returned by the view are of various content types, which may include article, page, and webform. Only the webform content type is Webform enabled.

Results

Edit form links and form result links are printed for nodes of all content types, even those content types that are not Webform enabled.

Expected Results

Edit form links and form result links are printed only for content types that are Webform enabled.

Proposed Solution

Modify the render_link function in each handler to check if a node's content type is Webform enabled.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Chris Burge’s picture

Status: Active » Needs review
FileSize
1.36 KB
DanChadwick’s picture

Category: Bug report » Feature request

Seems like a reasonable enhancement to the intended use of these handlers, which is the content display of webforms.

DanChadwick’s picture

Status: Needs review » Fixed
FileSize
2.58 KB

#1 worked perfectly. Thank you. I tweaked it for style a bit and added a static cache for webform_node_types, which is called from various loops.

Committed to 7.x-4.x.

DanChadwick’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Category: Feature request » Task
Status: Fixed » Patch (to be ported)

  • DanChadwick committed 259e43d on 7.x-4.x
    Issue #2501437 by Chris Burge, DanChadwick: Views Field Handlers Should...
Chris Burge’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Status: Patch (to be ported) » Needs work
FileSize
795 bytes

The committed patch from #3 caused a regression.

The access check in the 'render_link' function in the 'webform_handler_field_node_link_results' class was modified to check node edit permission instead of webform results permission:

diff --git a/views/webform_handler_field_node_link_results.inc b/views/webform_handler_field_node_link_results.inc
index 885bfc2..faa8033 100644
--- a/views/webform_handler_field_node_link_results.inc
+++ b/views/webform_handler_field_node_link_results.inc
@@ -30,8 +30,8 @@ class webform_handler_field_node_link_results extends views_handler_field_node_l
    * Renders the link.
    */
   function render_link($node, $values) {
-    // Ensure user has access to edit this node.
-    if (!webform_results_access($node)) {
+    // Ensure node is webform-enabled and user has access to edit this node.
+    if (!in_array($node->type, webform_node_types()) || !node_access('update', $node)) {
       return;
     }

Patch attached to address regression.

Chris Burge’s picture

Status: Needs work » Needs review

  • DanChadwick committed 5e8ab18 on 7.x-4.x
    Issue #2501437 by Chris Burge: Fixed Views Field Handlers permission for...
DanChadwick’s picture

Category: Task » Bug report
Status: Needs review » Fixed

Thanks, Chris! Good catch. I didn't notice the access check was different.

#6 committed to 7.x-4.x.

DanChadwick’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Category: Bug report » Task
Status: Fixed » Patch (to be ported)

#3 and #6 need port to D8.

fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Category: Task » Bug report
Status: Patch (to be ported) » Fixed

Committed and pushed #3 and #6 to 8.x-4.x. Thanks.

  • fenstrat committed 453acc0 on 8.x-4.x
    Issue #2501437 by Chris Burge, DanChadwick: Views Field Handlers Should...

Status: Fixed » Closed (fixed)

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

The last submitted patch, 3: webform-webform_enabled_check-2501437-3.patch, failed testing.

Status: Closed (fixed) » Needs work

The last submitted patch, 6: webform-webform_enabled_check-2501437-6.patch, failed testing.

The last submitted patch, 3: webform-webform_enabled_check-2501437-3.patch, failed testing.

The last submitted patch, 6: webform-webform_enabled_check-2501437-6.patch, failed testing.

DanChadwick’s picture

Status: Needs work » Closed (fixed)

Yeaaah, testbot, you're living in the past, dude (or dudette). Already committed.