Make WordPress Core


Ignore:
Timestamp:
09/16/2015 09:59:16 PM (9 years ago)
Author:
boonebgorges
Message:

Don't notify post authors about spam comments.

[34106] moved post author notification to a hook, and in the process, missed
the 'spam' check. This changeset restores that check.

To make unit testing easier, the notification callbacks have been refactored
to return values: false when various conditions aren't met (eg, approved
comments should not trigger moderation emails), and the return value of the
wp_notify_*() function otherwise.

Props cfinke, kraftbj.
See #33587.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment.php

    r34172 r34250  
    260260        $this->assertTrue( wp_notify_moderator( $c ) );
    261261    }
     262
     263    /**
     264     * @ticket 33587
     265     */
     266    public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_marked_as_spam() {
     267        $p = $this->factory->post->create();
     268        $c = $this->factory->comment->create( array(
     269            'comment_post_ID' => $p,
     270            'comment_approved' => 'spam',
     271        ) );
     272
     273        $sent = wp_new_comment_notify_postauthor( $c );
     274        $this->assertFalse( $sent );
     275    }
    262276}
Note: See TracChangeset for help on using the changeset viewer.