The code for Views integration had a handful of problems. I found these problems troubleshooting the problem in the title:

Views includes a number of filters for the Comments module. Installing Forward clobbers the Comments filters, and they vanish from the filter list.

This is particularly problematic because a number of sites with "recent comments" blocks based on a view can break on every page, and the error given does not point to the comments views at all. Had to install Trace and step back through SQL calls to hunt it down, which your average user probably may not be able to do. It would just look like the entire site was broken.

Patch enclosed. To explain the patch, I have to discuss a little more:

The problem stems from the fact that the Forward module redefined the node_comment_statistics table's Views definition. This is a remarkably bad idea. It's very poor encapsulation. The Forward module should define Views definitions for its tables and only its tables, and the Comment module (or, in this case since it's a core module, the Views module and its default includes) should be solely responsible for defining its tables.

This is particularly poor, because there's not even any checks to assure that the Comment module is enabled. And it's obviously not listed as a dependency of Forward, for good reason -- it shouldn't be.

I understand the purpose of having done this: it was to include the sort by Most Active, which takes into account the sum of forwards and comments. I really don't think that matches anyone's concept of what Most Active means, as those two would normally be pretty independent (and forwards to me equate more with page views than comments), but since the functionality was included, meaning the module owner clearly wanted it for some reason and it's not my call to remove others' functionality, I did the following:

I removed the re-definition of the comment statistics table, as it's not a Forward table.
I moved the one unique sort, the Most Active sort, into the forward_statistics table definition, and then commented out the sort.

To re-enable the sort, it is necessary to rewrite the sort handler to do the join with the comments table inside the function itself. There should also be a check to see if Comment module is enabled in the first place. But then again, if it is not, the sort should not even appear in the table definition.

What it boils down to is, Views is not designed to facilitate criteria on tables from multiple disparate modules -- all filters and sorts are module-centric by design. I would say, the idea's nice, but it's not viable, and the Most Active sort should be removed altogether. But I'll leave that to the module owner's discretion, if he/she wants to put some work into fixing the handler so that the sort works.

The patch also cleans up some minor textual issues, and fixes a minor bug in the forward_count and clickthrough_count filters where 'value' is undefined (against API specs), and 'option' is accidentally defined instead, even though there's no handler to use the options. The default handler will use the value field, not the option field.

CommentFileSizeAuthor
forward.module.HEAD_.r0.patch4.91 KBgnassar

Comments

seanr’s picture

Status: Needs review » Fixed

The most active view was done for a specific client request on a site which actually just launched yesterday: http://www.hopestreetgroup.org (see the tabbed block to the right). I have applied this patch to the module in spite of that, because I do consider it's breaking another modules features to be critical, but we do need to figure out how to provide this feature.

Views doesn't provide any way in the UI to add two counts together and sort by the sum (which is what we needed for the client since they considered both forwarding and commenting to be activity worthy of noting). Do you have any recommendations for doing this without breaking the comment statistics?

gnassar’s picture

I mulled on it for a little bit when I moved it to see if I could come up with something quick I could include in the patch, so yes, I have some thoughts. I'm going to go ahead and create a new issue for getting Most Active working, since this is already (rightly, I think) marked fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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