Use proper menu router paths for comment/*

sun - October 16, 2009 - 17:15
Project:Drupal
Version:7.x-dev
Component:comment.module
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs work
Issue tags:Contextual links, D7 API clean-up
Description

For #473268: D7UX: Put edit links on everything, we need proper argument loader path structures.

Comment module currently uses:

comment/edit/%comment
comment/delete/%comment
...

This needs to be converted into:

comment/%comment/edit
comment/%comment/delete
...

Attached patch already converts comment/delete accordingly. We at least need comment/edit to be converted equally. The "reply" and others are not necessarily required.

AttachmentSizeStatusTest resultOperations
drupal-comment-paths.patch3.97 KBIdleFailed: Failed to apply patch.View details | Re-test

#1

q0rban - October 16, 2009 - 17:51

Applied previous patch and made changes as described. Left comment/node/%node as is for now.

AttachmentSizeStatusTest resultOperations
drupal-comment-606608-1.patch8.46 KBIdleFailed: 13963 passes, 1 fail, 2 exceptionsView details | Re-test

#2

David_Rothstein - October 16, 2009 - 17:57

Subscribing.. will try to review in a bit.

#3

System Message - October 16, 2009 - 18:00
Status:needs review» needs work

The last submitted patch failed testing.

#4

David_Rothstein - October 16, 2009 - 18:08

Reviewing now (and will try to fix the test while I review, unless someone else is).

#5

q0rban - October 16, 2009 - 18:27

Let's try this again. Fixed comment_approve as it used to accept $cid as its argument, and should now be passed the $comment object. Also changed all items to local tasks and weighted them.

Not sure what is the best order for the local tasks but the order I chose is View | Edit | Approve | Delete

AttachmentSizeStatusTest resultOperations
drupal-comment-606608-5.patch9.77 KBIdleFailed: Failed to apply patch.View details | Re-test

#6

q0rban - October 16, 2009 - 18:27
Status:needs work» needs review

#7

David_Rothstein - October 16, 2009 - 18:47

Looks good to me, although:

-function comment_approve($cid) {
-  // Load the comment whose cid = $cid
-  if ($comment = comment_load($cid)) {
+function comment_approve($comment) {
+  if ($comment) {

The if ($comment) part is no longer necessary anymore since the menu system will take care of never even hitting this callback function in the case where the comment doesn't exist. So, this function can actually be simplified (similar to how the patch simplifies the callback for comment deletion).

One other thing - the immediate effect of this patch is pretty odd (see attached screenshot). However, we can probably let that slide since #473268: D7UX: Put edit links on everything would automatically take care of fixing it :)

AttachmentSizeStatusTest resultOperations
edit_comment.png70.21 KBIgnoredNoneNone

#8

Dries - October 16, 2009 - 18:56

+++ modules/comment/comment.module 16 Oct 2009 18:26:30 -0000
@@ -166,20 +166,44 @@ function comment_menu() {
+    'title' => 'Approve a comment',

Should be 'Approve comment' to be consistent with the other links. See also David's screenshot in the previous comment.

For consistency with the node system and all the rest of Drupal, it should actually be just 'Edit', 'Approve', 'Delete' instead of 'Edit comment', 'Approve comment' and 'Delete comment'.

Otherwise, this patch looks very straightforward.

#9

effulgentsia - October 16, 2009 - 19:07

Code looks good to me. Nice bonus that comment_delete_page() is no longer needed. I expect regression failures (like in forum.module), but those can be fixed once bot reports them.

#10

q0rban - October 16, 2009 - 19:16

Re-roll per #7 (removing all if/else logic from comment_approve) and #8 (Clean up titles of local tasks).

AttachmentSizeStatusTest resultOperations
drupal-comment-606608-10.patch10.17 KBIdleFailed: Failed to apply patch.View details | Re-test

#11

q0rban - October 16, 2009 - 20:00
Status:needs review» reviewed & tested by the community

#12

q0rban - October 16, 2009 - 20:01
Status:reviewed & tested by the community» needs review

whoops, I guess I should wait for someone else to mark it as RTBC. ;)

#13

sun - October 16, 2009 - 20:12
Status:needs review» reviewed & tested by the community

Very nice job, q0rban!

#14

Dries - October 16, 2009 - 20:40
Status:reviewed & tested by the community» fixed

Looks great. Committed!

#15

webchick - October 17, 2009 - 05:17
Category:task» bug report
Status:fixed» needs work

This introduced a CSRF vulnerability. Some douchebag can put <img src="http://localhost/core/comment/1/approve" /> in their comment.

We need a confirm form around the approval link.

#16

webchick - October 17, 2009 - 05:32

Also, we should give this local task a proper access callback. "Approve" should only show up if the comment is unpublished. The link does this, the local task does not.

#17

sun - October 17, 2009 - 16:15
Issue tags:+Contextual links

Tagging.

#18

andypost - October 17, 2009 - 19:44

#19

sun - November 8, 2009 - 06:44
Status:needs work» needs review

Not sure whether this works, but it should do at least 90% of what's needed.

And, I think I already mentioned elsewhere that this wasn't really introduced by this patch... so not sure whether it's superior to discuss this publicly, but anyway.

AttachmentSizeStatusTest resultOperations
drupal.comment-approve.patch2.69 KBIdleFailed: 14669 passes, 1 fail, 0 exceptionsView details | Re-test

#20

System Message - November 8, 2009 - 07:05
Status:needs review» needs work

The last submitted patch failed testing.

#21

David_Rothstein - November 9, 2009 - 04:00
Issue tags:-csrf

Yeah, the CSRF vulnerability was not introduced by this patch - I think all this patch did was change the URL at which it happens :) It looks like it was introduced (in Drupal 7 only) via #66264: Remove CSRF vulnerability from comment module and a fix is already being worked on there.

In this issue, however, we still have two followup bugs visible in the screenshot from #7:

1. The title of the page should not be "Comment permalink".
2. It's not really clear that we want all these things showing up as visible local tasks, which was a side effect of the committed patch... we don't (currently) do that with most delete links in Drupal, for example.

#22

catch - November 14, 2009 - 09:53

We also need to roll back using %node menu loaders for edit and delete links I think, since that prevents using contextual links without generating a database query per path (due to menu access checks).

#23

sun - November 14, 2009 - 13:42

@catch: The loaded %node as well as %comment should be cached. Both need to rely on node access grants.

#24

catch - November 14, 2009 - 14:01

Doh, mis-typed. %node is of course , but %comment has no static caching at all, see #611590: Statically cache comments for the other option.

 
 

Drupal is a registered trademark of Dries Buytaert.