Hide reply link for unpublished comments

Created on 14 February 2008, almost 17 years ago
Updated 10 September 2024, 3 months ago

Problem/Motivation

Unpublished comments have a 'Reply' link but clicking it results in a 403/Access Denied page.

Steps to reproduce

  1. Install Drupal
  2. Publish an article
  3. Post a comment on an article and unpublish it (or, post a comment as a user without permission to skip approval)
  4. View the unpublished comment as admin, see there is a Reply link
  5. Click the Reply link and see 'Access denied'

Proposed resolution

Don't show the reply link on unpublished comments.

Remaining tasks

  1. Agree on approach
  2. Write a patch with tests
  3. Review

User interface changes

Before:

After:

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

🐛 Bug report
Status

RTBC

Version

11.0 🔥

Component
Comment 

Last updated 11 days ago

Created by

🇩🇰Denmark EmanueleQuinto

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India mohit_aghera Rajkot

    Picking up again.
    - Update the PR destination and base to 10.1.x
    - Add additional test case from past patches. Both looks same to me.
    Happy to weigh in other opinions and refactor those.
    - All the test cases are passing on local now.

  • 🇮🇳India mohit_aghera Rajkot

    Hiding other patches as the one in #43 seems valid.
    PR contains all the changes done in #43

  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

    So following the steps in the issue summary with the changes from MR 879 I'm still seeing reply button for unpublished comment.

    Don't show the link, or allow admins to reply to unpublished comments?

    This is a question so is this the approach that was taken?

    Since this is changing the UI before/after screenshots in the issue summary will be needed

    Thanks.

  • Pipeline finished with Failed
    8 months ago
    Total: 181s
    #156937
  • Pipeline finished with Failed
    8 months ago
    #156944
  • Status changed to Needs review 8 months ago
  • 🇦🇺Australia pameeela

    Tested manually and this does solve the problem, admins can reply to unpublished comments with the patch.

    Before:

    After:

  • Pipeline finished with Canceled
    8 months ago
    Total: 60488s
    #156970
  • Status changed to RTBC 8 months ago
  • 🇺🇸United States smustgrave

    Took the gifs from #76 and added to the issue summary user interface section

    Ran the test-only feature too

    1) Drupal\Tests\comment\Functional\CommentAccessTest::testUnpublishedCommentReplyForCommentAdministrators
    Behat\Mink\Exception\ExpectationException: Current response status code is 403, but 200 expected.
    /builds/issue/drupal-221761/vendor/behat/mink/src/WebAssert.php:888
    /builds/issue/drupal-221761/vendor/behat/mink/src/WebAssert.php:145
    /builds/issue/drupal-221761/core/modules/comment/tests/src/Functional/CommentAccessTest.php:152
    /builds/issue/drupal-221761/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
    ERRORS!
    Tests: 3, Assertions: 54, Errors: 1.
    PHPUnit 9.6.19 by Sebastian Bergmann and contributors.
    Testing Drupal\Tests\comment\Functional\CommentInterfaceTest
    

    Coverage is definitely there

    MR does appear to address the problem described in the summary.

    Believe this is good.

  • 🇺🇸United States xjm
  • Status changed to Needs work 8 months ago
  • 🇺🇸United States xjm

    Thanks for your work on this issue! Thanks especially @pameeela for the very clear manual testing. I've updated the issue summary with those images.

    There are a few coding standards and best practices issues with the current MR (see my comments therein). I do understand that in some cases these are being copied from existing tests and/or surrounding code, but we should not do the wrong thing for the sake of consistency. (If desired, a followup can be filed to improve the best practices in the rest of these tests.)

    I think this is pretty close.

  • 🇺🇸United States xjm

    Saving issue credits.

  • 🇺🇸United States xjm

    I also just noticed no one actually ever answered @alexpott's question in #50 and #51. NW for that also.

    FWIW, I think there is a usecase here, but we should articulate specifically why this is the right approach (vs. removing the link in this case).

    If we need to escalate it for further feedback once that reply is given, I think it should go to the usability team and/or comment subsystem maintainers; this is not really a product-level decision. Thanks!

  • 🇦🇺Australia pameeela

    I was a bit unsure about the solution myself, in testing it seemed a bit odd to reply to an unpublished comment. I am not super clear on the use case for replying before approving.

    If an admin replies to an unpublished comment, the reply is unpublished as well and it has to be approved separately (even if they have permission to comment without approval). This makes sense, but you can then approve it meaning you could have a published reply to an unpublished comment. And if the original comment is deleted rather than approved, the reply is also deleted. (Why would you reply to a comment you were going to delete ? Well, exactly. But also why wouldn't you just approve the comment before replying?)

    Having said all that, the stakes here seem extremely low. But it makes more sense to me to hide the reply link until the comment is approved.

  • 🇦🇺Australia pameeela

    Updated based on the latest suggested approach.

  • 🇬🇧United Kingdom catch

    Agreed with the new proposed solution, hiding the link seems right.

  • Status changed to Needs review 3 months ago
  • 🇬🇧United Kingdom catch

    Put up an MR with test coverage.

  • 🇬🇧United Kingdom catch

    catch changed the visibility of the branch 221761-comment-admins-cannot to hidden.

  • 🇦🇺Australia pameeela

    Woohoo! Manual test passed, added updated screenshots to the IS.

  • Status changed to RTBC 3 months ago
  • 🇳🇱Netherlands Lendude Amsterdam

    Solution and test code look good, could maybe check for the reply link to exist and not just the text to be a little more specific but this works.

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Committed and pushed 6067ed426c to 11.x and 3b1e465274 to 11.0.x and f096a302e8 to 10.4.x and 71ac91d7ce to 10.3.x. Thanks!

    • alexpott committed 71ac91d7 on 10.3.x
      Issue #221761 by mohit_aghera, pameeela, dixon_, catch, ged3000, sun,...
    • alexpott committed f096a302 on 10.4.x
      Issue #221761 by mohit_aghera, pameeela, dixon_, catch, ged3000, sun,...
    • alexpott committed 3b1e4652 on 11.0.x
      Issue #221761 by mohit_aghera, pameeela, dixon_, catch, ged3000, sun,...
    • alexpott committed 6067ed42 on 11.x
      Issue #221761 by mohit_aghera, pameeela, dixon_, catch, ged3000, sun,...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024