While investigating why an operation was being triggered by content moderators when they published comments but not when they unpublished comments, I found that hook_comment_unpublish()
is documented but does not actually exist.
I grepped through the Drupal 7/8 codebase for module_invoke_all('comment_unpublish'
and didn't find any results and the documentation page doesn't list any invocations.
Marking this as major since Forum, Search and Tracker implement this hook in D7 while Forum, Node and Tracker implement this in D8 but feel free to change the status. Tracker and Forum both include their own workarounds for this issue which can be removed.
Comment | File | Size | Author |
---|---|---|---|
#6 | comment-unpublish-d8-2289369-6.patch | 3.66 KB | g3r4 |
#1 | comment-unpublish-d7-2289369-1-do-not-test.patch | 6.2 KB | Devin Carlson |
#1 | comment-unpublish-d8-2289369-1-tests-only.patch | 4.49 KB | Devin Carlson |
#1 | comment-unpublish-d8-2289369-1.patch | 5.03 KB | Devin Carlson |
Comments
Comment #1
Devin Carlson CreditAttribution: Devin Carlson commentedA patch to invoke
hook_comment_unpublish()
with a test to demonstrate the issue. It also removes the workarounds that are currently in place.Comment #4
mcjim CreditAttribution: mcjim commentedWell spotted. Looks like this was never implemented in Drupal 7.
Just one thing: shouldn't we have tests in forum and tracker rather than CommentPublishTest? Not sure that's actually testing that the hooks are invoked as such, unless it's Friday afternoon and my brain's turned to mush, which is a distinct possibility.
Comment #5
larowlanI vote we remove it in favor of the more general update hook. No other entity has a published hook
Comment #6
g3r4 CreditAttribution: g3r4 commentedI've worked on a candidate patch for the removal of the content_unpublished hook since it's not being used
Comment #7
larowlanAlso #2294375: Comment publish/unpublish hooks are not invoked correctly
Comment #8
jhodgdonI'm closing that other issue as a duplicate, although is this issue covering the fact that hook_comment_publish() is being invoked on every save if the status is published (which is not how it's documented)?
Comment #9
jhodgdonI guess given the patch here, this issue is not covering the publish hook. So I reopened the other one to deal with that. Or we can close this one as a duplicate.
Comment #10
jhodgdonSorry for being so indecisive. I think we should go ahead and close this issue as a duplicate of the other one, since the other one is more comprehensive.