Make WordPress Core

Changeset 32692


Ignore:
Timestamp:
06/04/2015 05:28:07 PM (10 years ago)
Author:
boonebgorges
Message:

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

Props Oxymoron.
Fixes #32566.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r32614 r32692  
    15511551    // Send to the administration and to the post author if the author can modify the comment.
    15521552    $emails = array( get_option( 'admin_email' ) );
    1553     if ( user_can( $user->ID, 'edit_comment', $comment_id ) && ! empty( $user->user_email ) ) {
     1553    if ( $user && user_can( $user->ID, 'edit_comment', $comment_id ) && ! empty( $user->user_email ) ) {
    15541554        if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) )
    15551555            $emails[] = $user->user_email;
  • trunk/tests/phpunit/tests/comment.php

    r32364 r32692  
    149149        }
    150150    }
     151
     152    /**
     153     * @ticket 32566
     154     */
     155    public function test_wp_notify_moderator_should_not_throw_notice_when_post_author_is_0() {
     156        $p = $this->factory->post->create( array(
     157            'post_author' => 0,
     158        ) );
     159
     160        $c = $this->factory->comment->create( array(
     161            'comment_post_ID' => $p,
     162        ) );
     163
     164        $this->assertTrue( wp_notify_moderator( $c ) );
     165    }
    151166}
Note: See TracChangeset for help on using the changeset viewer.