Ticket #4108 (closed defect (bug): fixed)

Opened 5 years ago

Last modified 2 years ago

comments awaiting moderation sometimes not displayed

Reported by: wnorris Owned by: rob1n
Priority: normal Milestone: 2.2
Component: General Version: 2.1.3
Severity: normal Keywords: has-patch tested commit
Cc:

Description

comments awaiting moderation are displayed in the list of comments only for the person that posted the comment along with some text stating that it is awaiting moderation. The problem is the logic used to determine if the current visitor is the author of the comment... the only check is that the name and email address cookies coming from the browser match those on the comment. Users that are logged in, but do not have the name and email cookies set will be unable to view their unmoderated comments.

The attached patch will allow logged in users view their comments awaiting moderation. There is a TODO in the code to use the API instead of raw selects... perhaps that does need to be done at some point, but this at least addresses the short term.

Attachments

comment-template.diff Download (816 bytes) - added by wnorris 5 years ago.
initial patch

Change History

wnorris5 years ago

initial patch

  • Keywords has-patch added
  • Milestone changed from 2.4 to 2.3

comment:2 follow-up: ↓ 3   foolswisdom5 years ago

wnorris, it seems that empty($comment_author) should by the if, and your new code the else if because empty should be the most likely condition.

comment:3 in reply to: ↑ 2   wnorris5 years ago

Replying to foolswisdom:

wnorris, it seems that empty($comment_author) should by the if, and your new code the else if because empty should be the most likely condition.

actually that won't work, at least for the use case I have that led me to find this -- my  openid plugin. Imagine I make a comment with my OpenID and it goes into the moderation queue. Because I authenticated with OpenID and very likely did not provide a name or email in the comment form, I would be displayed the already approved posts and be sent on my way, which is exactly what is happening now. First it needs to check if I'm logged in... if so, then it should display my comments still awaiting moderation regardless of what cookies I may have on my machine... I've already authenticated and that should trump everything else.

Very good point. I guess I subscribe to the school of do what is most likely put first. Based on what you wrote, then the first condition should still be empty($comment_author) but be changed to empty($comment_author) && !$user_ID. I don't think that is over optimization b/c currently ~90% of visiters don't comment (or have a login), maybe that will change with the adoption of OpenID (but not soon).

  • Keywords tested added
  • Milestone changed from 2.3 to 2.2

Never mind my previous comment, the sql queries run are ~ the same O.

This still doesn't address one edge case, and I'm not sure that there's an easy way to do so... if you don't have "require name and email" enabled, and the user is not logged in, wordpress currently has absolutely nothing to track the user by. One possible solution would be a simple tracking cookie that is independent of the comment field data, but I'm sure that would come with some controversy, and justifiably so.

  • Keywords commit added
  • Owner changed from anonymous to rob1n

I don't think that edge case is worth fixing. Anonymous posting is by definition not linked to anything.

  • Status changed from new to closed
  • Resolution set to fixed

(In [5238]) Tweak displaying comments awaiting moderation to their authors. Props wnorris. fixes #4108

Note: See TracTickets for help on using tickets.