Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#32566 closed defect (bug) (fixed)

wp_notify_moderator assumes the post_author userdata exists

Reported by: rachelbaker's profile rachelbaker Owned by: boonebgorges's profile boonebgorges
Milestone: 4.3 Priority: normal
Severity: normal Version: 3.1
Component: Comments Keywords: has-patch needs-testing
Focuses: Cc:

Description

When attempting to notify the moderator about a new comment that is awaiting approval, the $post->post_author userdata is assumed to exist. Which means if the $post->post_author === 0 the userdata ($user->ID) does not exist and results in a "Trying to get property of non-object" PHP notice.

https://core.trac.wordpress.org/browser/trunk/src/wp-includes/pluggable.php#L1550

The (deprecated) function wp_notify_postauthor did/does confirm that the $post->post_author userdata exists before using it.

Attachments (2)

32566.patch (1.3 KB) - added by Oxymoron 10 years ago.
32566.2.patch (729 bytes) - added by Oxymoron 10 years ago.

Download all attachments as: .zip

Change History (7)

@Oxymoron
10 years ago

#1 @Oxymoron
10 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

#2 @Oxymoron
10 years ago

Attached a patch. I believe it solves the problem in question. The main thing I am worried about it the amount of if() statements being nested. Let me know if that's an issue or if there is an issue with the patch in general and I will fix.

@Oxymoron
10 years ago

#3 @Oxymoron
10 years ago

Updated patch to better address the issue the ticket reports. Thanks to Rachel for going over the problems with my initial patch via Slack.

#4 @boonebgorges
10 years ago

  • Milestone changed from Awaiting Review to 4.3

#5 @boonebgorges
10 years ago

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

In 32692:

In wp_notify_moderator(), don't throw notice when comment belongs to a post with no author.

Props Oxymoron.
Fixes #32566.

Note: See TracTickets for help on using tickets.