Problem/Motivation
Comments currently include a shortcut link which allows privileged users to quickly publish them. This is especially useful if comments are configured to default to unpublished, awaiting the approval of an administrator or site moderator. However, there's no equivalent shortcut to unpublish a comment which would be useful in the opposite case (comments are published by default and spam/inappropriate comments are unpublished by moderators).
This is also an inconsistency which would be a DX improvements: having a path to unpublish comments in tests, adding a views field which provides an unpublish link, etc.
Finally, much of the current administration wording refers to "approving" comments which, in reality, is simply changing the comment's publish status. This wording should be updated on the back end to "publish" which is consistent throughout core and pairs better with "unpublish" vs. "unapprove".
Proposed resolution
Add unpublish equivalents to the current publish functionality.
Remaining tasks
Needs review and change notice.
User interface changes
All administration text referring to "approving" a comment has been changed to "publishing", user-facing text has been left alone as it is still accurate (they are waiting for their comment to be approved). The Comment Approval Queue is now titled the Comment Unpublished Queue and has moved from '/admin/content/comment/approval' to '/admin/content/comment/unpublished'. The path for publishing a comment has moved from '/comment/{comment}/approve' to '/comment/{comment}/publish' and a new path for unpublishing a comment has been added at '/comment/{comment}/unpublish'.
API changes
A new route has been added for unpublishing a comment has been added at '/comment/{comment}/unpublish'. Additionally, the existing route for publishing a comment has had its path changed from '/comment/{comment}/approve' to '/comment/{comment}/publish' for consistency. The entity access operation has changed from 'approve' to 'publish' and the comment administration overview form $type argument now accepts either 'unpublished' or 'new' vs. 'approval' or 'new'.
Original report by droplet
On the frontend it has a way to approve a comment but no way to undo it.
Suggest add AJAX-action to approve & unapproved them
| Comment | File | Size | Author |
|---|---|---|---|
| #124 | 1266306-124-interdiff.txt | 32.5 KB | manishsaharan |
| #124 | 1266306-124.patch | 32.5 KB | manishsaharan |
| #122 | Screenshot-1266306-2.png | 421.42 KB | nikhil_110 |
| #122 | Screenshot-1266306-1.png | 517.17 KB | nikhil_110 |
| #122 | 1266306-122.patch | 37.9 KB | nikhil_110 |
Issue fork drupal-1266306
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
dixon_I think that makes sense, to achieve better consistency.
Maybe it also would be a good idea to add support for contextual links, to make it even more consistent. That of course would only be added it the contextual links module is installed.
Comment #2
dixon_Comment #3
dixon_Thinking more about it, I don't know if I like the AJAX thing though. That is not a pattern core uses for that type of functionality.
Comment #4
droplet commentedNone AJAX version.
Comment #5
dixon_Here is a re-roll of the patch in #4. It fixes some spacing issues (see below) and adds test to assert the link's functionality.
Should always be blank line between functions.
Should always be blank line at end of file.
20 days to next Drupal core point release.
Comment #6
dixon_Hmm, a tab space seemed to sneak in there somehow. New patch.
Comment #7
droplet commentedcan you fix tabs spacing. thanks.
20 days to next Drupal core point release.
Comment #8
dixon_Comment #9
barbun commentedI was searching for this solution as well, that's why I wrote my custom module for D7 (Views integration provided). Thank's dixon, I took some tips from your patch;)
Also there are my patches for D7 comment.module and Views, see the link above to find references.
http://drupal.org/node/1546758
Comment #10
Bojhan commentedScreenshot please.
Comment #11
droplet commentedComment #13
Bojhan commentedThe order of those links - never made sense to me, but other than that its RTBC from a UX standpoint.
Comment #14
droplet commentedComment #15
Bojhan commentedLooks good to me.
Comment #16
sunSorry. My English dictionary (LEO) does not know the term "[to] unapprove".
There's "unapproved" (adjective), but that's not a verb, and seems to be rarely used either.
Comment #17
droplet commentedhow about "unapprove" => "disapprove".
Comment #19
sunI'm OK with "disapprove", but want to point out that the entire "approve"-based terminology we're using here is completely misleading and inappropriate. As I just mentioned in #1616324: Add view display for admin/content/comment/approval:
I'd like to see a follow-up issue that renames both of those links into "publish" (ex. approve) and "unpublish" (ex. disapprove), because it is highly confusing for users to see already approved comments re-appearing in the approval queue after unpublishing them.
Comment #20
droplet commentedfix tests
Comment #22
droplet commentedouch, new commit: #1591604: Replace drupal_access_denied() with throw AccessDeniedHttpException
Should be work this time:
Comment #23
droplet commented#22: 1266306-disapprove_comment_link.patch queued for re-testing.
Comment #25
droplet commentedComment #26
dcam commentedUpdated #22 to use drupal_container().
Comment #27
yoroy commentedI would wonder what disapprove does. Sun suggests in #19:
> I'd like to see a follow-up issue that renames both of those links into "publish" (ex. approve) and "unpublish"
> (ex. disapprove), because it is highly confusing for users to see already approved comments re-appearing
> in the approval queue after unpublishing them.
This issue seems RTBC again. The follow-up would be a nice improvement too.
Comment #28
dries commentedI'm not sure I understand why we want to debate the names in a follow-up issue when it can be done now.
I think "publish" and "unpublish" make a lot more sense.
Comment #29
yoroy commentedI wouldn't mind either. Lets see if we can incorporate those changes then.
Comment #30
dcam commentedHere's a patch that changes any comment approved/unapproved language to published/unpublished.
This meant changing the name of the "Skip comment approval" permission. The only decent name I came up with was "Automatically publish comments," but I don't like it. Every other permission name describes an action that a user is allowed/forbidden to take. "Automatically publish comments" doesn't match that pattern and could be confusing.
Comment #31
dcam commentedComment #32
sunThanks, @dcam! :)
Hm. I actually do not think we need to adjust the permission name/label in any way. The permission focuses on the interaction of a user that is posting a comment, and in that process/interaction, we're actually talking about an "approval" of a posted but initially unpublished comment.
What do you think?
Comment #33
cobadger commentedTested patch #30. Clicking on the new "unpublish" link does not unpublish the comment (comment still shows up in the "published comments" list (in admin/content/comment).
Also, using admin/content/comment to unpublish the comment does result in it being unpublished, but the now-unpublished comment does not show up in the unpublished comments list - so the list is empty, but the "Unpublished comments" counter shows a value of 1 (see attached screenshot).
Comment #34
cobadger commentedchanging status to "needs work"
Comment #35
durgeshs commentedSubmitting patch after modifying #26 by changing the label and path as commented on #28
@attached(screenshot - comment-1266306-35.png, publish-unpublish-comment-1266306-35.png).
Comment #37
durgeshs commentedSubmitting the modified test case, which were failing in the previous post.
Comment #38
jhoodI just tested patch #37 and it works as expected. Ready to RTBC?
Comment #39
dcam commentedI realize #19 only talked about using "Publish/Unpublish" terminology in the comment links, but I think if we don't standardize the terminology overall then we'll just be revisiting the issue in the future.
Comment #40
tomogden commentedBefore installing the patch, I created a comment and "approved" it.
After installing the patch in the latest code base, the "Unpublish" link appears, but it doesn't change anything when you click on it. If there is a new comment, the "Publish" link is likewise ineffective.
I wonder if something changed in related code?
Comment #41
finn lewisI tried the patch from #37, but it failed to apply, both using git apply, and using the 'patch -p1' command.
I worked through the patch and applied it manually, and it worked as described above. I can now unpubish and publish comments from the commented node.
In response to #40 - the patch changed menu callbacks so I had to clear the cache before the 'unpublish' link would work.
I've re-rolled the patch, which seems to apply ok for me now.
I hope this helps. This has come out of a Drupal Ladder (http://drupalladder.org/) sprint, so if I've made a mistake, sorry!
Comment #42
wryz commented#41: unpublished-comment-1266306-41.patch queued for re-testing.
Comment #44
unstatu commented#41: unpublished-comment-1266306-41.patch queued for re-testing.
Comment #46
unstatu commented#41 Doesn't pass the test. I have rewrite the code for the newest 8.x-dev version.
In other hand, I noticed that the internal paths for the administration items are using the Approval names instead the Published names. Also, not all the code has been updated. For example, the tests and some other paths,
Comment #47
jonhattanComment #48
techmsi commentedNeeds re-role. We're going to work on it.
Comment #49
yesct commentedyep. the most recent patch does not apply.
@techmsi did you have work on this you wanted to post? or any questions?
http://drupal.org/patch/reroll are the instructions, and I'm just going to add the tag for needs reroll.
If someone rerolls this and posts a new patch, just remove the needs reroll tag then. :)
Comment #50
benjf commentedworking on a re-roll...
Comment #51
benjf commentedThis task was larger than expected, please review!
Comment #53
star-szrI would say overall that looks quite reasonable @benjf! I guess per #28 that renaming unapprove to unpublish (and same with approve) is a part of this issue. Tagging for an issue summary update.
Small typo here: published-not-published.
Comment #54
benjf commentedthanks! fixed the typo
Comment #55
dcam commentedStatus
Comment #57
yesct commentedrerolls dont usually need interdiff, but the change from 51 to 54 is a good case for an interdiff
For instructions on creating an interdiff, see https://drupal.org/documentation/git/interdiff | Microbranching workflow: http://xjm.drupalgardens.com/blog/interdiffs-how-make-them-and-why-they-...
Comment #58
benjf commentedThanks! I only sort of understand interdiff's, but I'll read through it again.
Meanwhile, here is a new patch with the typo from #51 fixed.
Comment #60
droplet commentedI think this patch goes too deep now. Let me fix the test cases and clean up the old code.
Some code has been removed during the time. Here is the updated version. No interdiff provided since the old patch #46 is too simple and almost every line has a new change now.
Please review it again. Thanks All.
Comment #61
star-szrPatch no longer applies and needs a reroll.
Comment #62
larowlandrupal_get_token is deprecated
user_access id Deprecated
Comment #63
ajitsRe-rolling the patch from #60.
Comment #65
jibranwe can use
$this->csrfToken->validate().Comment #66
ajitsComment #67
ajitsDon't know where the tag came from.
Comment #68
ajitsPatch #63 no longer applies.
Comment #69
droplet commentedsee #65, more than reroll
Comment #70
durgeshs commented37: unpublished-comment-1266306-37.patch queued for re-testing.
Comment #72
droplet commentedComment #73
devin carlson commentedAn updated patch that renames the administration paths, test methods, access operations, etc and adds an "unpublish link" Views field for consistency but continues to leave the user-facing text alone per #32.
This could be split into multiple issues but I've included a single patch per #28.
Comment #76
ohthehugemanatee commentedRerolled the patch (CommentAccessControl.php changed to CommentAccessControlHandler.php) so it applies cleanly again. Cleared caches and it works as advertised:
* comment creation is unaffected
* comment "publish" link is visible with the new URL, comment/x/publish
* uses the newly renamed comment.publish route
* comment "unpublish" link is visible with URL comment/x/unpublish
* it does actually publish and unpublish.
This is a big patch though, so it could use some more eyeballs.
Comment #77
ohthehugemanatee commentedI thought it might be nice to actually attach the updated patch lol
Comment #78
botrisReviewing this now
Comment #79
botrisInitial roll gave 7 rejects.
Re-rolled the patch. It gave 7 conflict messages, which where all resolved manually.
Needs a new review.
Removed Novice tag as it's quite a big patch.
Comment #81
ohthehugemanatee commentedThis patch failed testbot because it couldn't install...
* CommentStorageInterface has public method updateEntityStatistics, so CommentStorage (which extends CommentStorageInterface) has to have that method, too. I added it as an empty function, because comments don't get to have comments on them. Not 100% sure if this is the right thing to do.
* It also calls undefined method ConfigEntityType::isFieldable a couple of times in comment.views.inc. This was removed in #2100343: Remove 'fieldable' key in entity definitions in favour of 'field_ui_base_route', so I replaced it with $entity_type->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface') as recommended in the change record (https://www.drupal.org/node/2346455).
It installs locally now. Submitting for testbot to give it a try.
Comment #88
ohthehugemanatee commentedRe-submitting because testbot is dying on too many MySQL connections... that's a testbot problem AFAIK. Someone correct me if I'm wrong!
Comment #92
ohthehugemanatee commentedYay! Real test failures! :D I'll work on these...
Comment #93
ohthehugemanatee commentedSo now it failed because of change record https://www.drupal.org/node/2337377 from Sept 17, introducing \Drupal\Core\Access\AccessResultInterface . I've got that addressed in a local copy, still working on testing errors in CommentAnonymousTest and CommentAdminTest. It looks like more issues with the same change. Will post with progress once I get it testing green!
Comment #94
ohthehugemanatee commentedComment #95
ohthehugemanatee commentedComment #97
ohthehugemanatee commentedFailed patching because of updates to CommentViewBuilder from #2348547: CommentViewBuilder should use static where possible, subclassing is currently too painful.
This patch has gotten enormous, and entails a renaming of the action from "approve" to "publish". That means that any time a commit affects Comment module, it risks breaking the patch. :|
Comment #99
droplet commented@see what the bot say
Comment #100
droplet commentedNice #99 is passed. Here's trying to remove irrelevant code, we focus on adding the Unpublished link only.
Comment #101
ohthehugemanatee commented@droplet - thanks for the re-test!
Can you post an interdiff please? It's hard to see the changes you made otherwise.
Comment #102
droplet commentedSure, here is it. Thanks :)
Comment #103
ohthehugemanatee commentedIn stripping out the other code, we lose some of the backend instances of "approved" language that we earlier decided to change to "published". New patch here that adds some of those back.
Here's my thinking on the language:
* comments have a status of "published" or "unpublished"
* the human process of reviewing unpublished comments is "approval"
* The action taken to a comment during approval is "publishing". Comments which do not pass approval are left "unpublished".
I wanted to make it even more consistent, but there are some cases where the language just has to describe what the human is doing (approval). ie the message "Your comment has been queued for review by site administrators and will be published after approval." perfectly describes what is going on.
The most visible remaining use of "approval" language is in the permission "Skip comment approval". This still seems appropriate to me. The only alternative I can think of is "Publish comments on submission", which is more awkward IMO. Otherwise it's just in test comments, where we could actually use either term and accurately describe what's going on.
Comment #113
klemendev commentedIs anyone aware of any contrib module adding such a functionallity for D8/D9?
Comment #118
bhanu951 commentedNeeds reroll of patch for 10.1.x version.
Comment #119
sahil.goyal commentedAs seen that latest patch is not compatible with the current version 10.1.x so i reroll the patch for the current version and made it compatible with, also attaching the reroll_diff along.
Comment #120
sahil.goyal commentedComment #121
sahilgidwani commentedI applied patch but it throws following error, I have attached screenshot for the same.
Fatal error: Class Drupal\comment\CommentStorage contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Drupal\comment\CommentStorageInterface::updateEntityStatistics) in /var/www/html/core/modules/comment/src/CommentStorage.php on line 26Comment #122
nikhil_110 commentedAttached patch against Drupal 10.1.x and Address #121 Comment.
also Some deprecated functions have changed and been removed..
Comment #124
manishsaharan commentedRemoved whitespace errors and Re rolled patch with 11.x.
Comment #125
borisson_Comment #126
bhanu951 commentedComment #128
bhanu951 commentedComment #129
smustgrave commented