WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 3 months ago

#39566 assigned defect (bug)

WordPress ignoring previously approved comment for some comment authors

Reported by: rperrett Owned by: rachelbaker
Milestone: Future Release Priority: normal
Severity: major Version: 4.7
Component: Comments Keywords: needs-patch needs-unit-tests
Focuses: Cc:

Description

I seem to have a reproducible bug with the option "Comment author must have a previously approved comment".

My client has a site that heavily uses guest commenting. They have selected the option "...must have previously approved comment". This works well most of the time, however more frequently some guests (identified by email) are being flagged as not having a previously approved comment even though they do. For one author (email) in question I am able to replicate this every time.

  • All other possible comment moderation disabled.
  • Comment as the guest in question, comment moderated.
  • Log in as admin, approve the comment.
  • Comment a second time as the guest, comment moderated again (shouldn't be)
  • Disable the option "must have previously approved..."
  • Comment a third time, now the comment is approved automatically.
  • Re-enable option "must have previously approved..."
  • Comment a forth time, the comment is moderated.

This appears to be a bug to me, and I can reproduce it every time. Not sure how to troubleshoot this further from here.

Attachments (2)

comment-settings.png (20.9 KB) - added by rinkuyadav999 2 years ago.
39566.patch (1.8 KB) - added by smerriman 21 months ago.

Download all attachments as: .zip

Change History (12)

#1 @rinkuyadav999
2 years ago

I have just tested it with 4.7.1

  1. I checked "Comment author must have a previously approved comment" and saved.
  2. i post a comment.
  3. i approved it
  4. i post comment again on other post and it go live without approval in admin panel.

#2 follow-up: @lukecavanagh
2 years ago

@rperrett

Just checked on a test post in WP 4.7.1. So commented as a guest for the first time with Comment author must have a previously approved comment, enabled in the Discussion Settings. Approved the comment in the WP admin. Then commented for a second time on the same post and the comment was posted since I was approved for the first comment, when I commented as a guest.

So that seems to work as it should do, since the comment did not need to be approved again and was just posted.

On the site where comments are not being automatically approved for guest users on those comments, is there anything being used besides default comments, that might be effecting how comments work on that site?

Also what is the active theme on that site?

#3 in reply to: ↑ 2 @rperrett
2 years ago

@lukecavanagh

I'm also testing on 4.7.1, no plugins, theme is 2017.

After further testing, it appears this is happening only for email addresses registered on the site. Guest commenting is also enabled on the site.

If an email address is registered as a user in wordpress and that user is a post author... Then a comment is left by a guest using the same email address as a registered user, it goes to moderation only if the option "previously approved comment..." is selected. For guest comments using a non-registered and post author email address, the option works normally.

I can understand why you do not want guests posting with the same email address as a registered user and post author, however this appears to be changed functionality as my client only started complaining after the upgrade to 4.7.1.

#4 @smerriman
22 months ago

Just to summarise this, if a user has created an account but leaves all comments while logged out, all of their comments will require approval.

This was caused by [38738].

A simple fix is to change the check in [38738] to test if there is a comment by the user ID or with the email address.

@rachelbaker thoughts?

Last edited 22 months ago by smerriman (previous) (diff)

#5 @rperrett
21 months ago

This is still an issue with one of our users, so I gave it some more testing. The problem is that the user has always had an account but never used it, she always commented as a guest. So all her approved comments have user_id=0. Now we told her to login so she finally does (3 months later) and tries to post, however it goes to moderation as now she is commenting with a valid user_id but there are no comments approved against that user_id. (comments.php line 117)

I had a think but am not sure what changes to make to the code that don't have an adverse effect.

Rob

@smerriman
21 months ago

#6 @smerriman
21 months ago

The above patch checks whether a comment exists either by the user ID (new method) OR via the old email/username match (old method), so the best of both worlds.

Incidentally fixes an issue with escaping at the same time.

#7 @smerriman
18 months ago

  • Severity changed from normal to major

This bug has been around for 7 months with no response from developers. I've had to keep reapplying the above patch to keep our site working properly.

What needs to be done to get this moving?

#8 @rachelbaker
5 months ago

  • Milestone changed from Awaiting Review to 4.9.9
  • Owner set to rachelbaker
  • Status changed from new to assigned
  • Summary changed from Wordpress ignoring previously approved comment for some comment authors to WordPress ignoring previously approved comment for some comment authors

#9 @rachelbaker
5 months ago

  • Keywords needs-patch needs-unit-tests added

#10 @pento
3 months ago

  • Milestone changed from 4.9.9 to Future Release
Note: See TracTickets for help on using tickets.