Make WordPress Core

Ticket #26659: 26659-checking-added.patch

File 26659-checking-added.patch, 1.5 KB (added by drozdz, 10 years ago)

Added checking if author is not empty

  • wp-includes/pluggable.php

     
    10231023        $author  = get_userdata( $post->post_author );
    10241024
    10251025        // Who to notify? By default, just the post author, but others can be added.
    1026         $emails = array( $author->user_email );
     1026    $emails = array();
     1027    if ( ! empty( $author ) ) {
     1028        $emails[] = $author->user_email;
     1029    }
    10271030
    10281031        /**
    10291032         * Filter the list of emails to receive a comment notification.
     
    10611064        $notify_author = apply_filters( 'comment_notification_notify_author', false, $comment_id );
    10621065
    10631066        // The comment was left by the author
    1064         if ( ! $notify_author && $comment->user_id == $post->post_author ) {
     1067        if ( ! $notify_author && $comment->user_id == $post->post_author && ! empty( $author ) ) {
    10651068                unset( $emails[ $author->user_email ] );
    10661069        }
    10671070
    10681071        // The author moderated a comment on their own post
    1069         if ( ! $notify_author && $post->post_author == get_current_user_id() ) {
     1072        if ( ! $notify_author && $post->post_author == get_current_user_id() && ! empty( $author ) ) {
    10701073                unset( $emails[ $author->user_email ] );
    10711074        }
    10721075
    10731076        // The post author is no longer a member of the blog
    1074         if ( ! $notify_author && ! user_can( $post->post_author, 'read_post', $post->ID ) ) {
     1077        if ( ! $notify_author && ! user_can( $post->post_author, 'read_post', $post->ID ) && ! empty( $author ) ) {
    10751078                unset( $emails[ $author->user_email ] );
    10761079        }
    10771080