Make WordPress Core

Ticket #35069: 35069.2.diff

File 35069.2.diff, 1.3 KB (added by swissspidy, 9 years ago)
  • src/wp-includes/pluggable.php

    diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
    index 5b441d8..0025c59 100644
    function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() 
    245245         */
    246246        $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );
    247247
     248        if ( ! is_array( $atts ) ) {
     249           return $atts;
     250        }
     251
    248252        if ( isset( $atts['to'] ) ) {
    249253                $to = $atts['to'];
    250254        }
  • tests/phpunit/tests/mail.php

    diff --git tests/phpunit/tests/mail.php tests/phpunit/tests/mail.php
    index 229ff23..bb5e438 100644
    class Tests_Mail extends WP_UnitTestCase { 
    288288
    289289                $this->assertNotContains( 'quoted-printable', $GLOBALS['phpmailer']->mock_sent[0]['header'] );
    290290        }
     291
     292        /**
     293         * @ticket 35069
     294         */
     295        public function test_wp_mail_bail_early() {
     296                $this->assertTrue( wp_mail( WP_TESTS_EMAIL, 'Foo', 'Bar' ) );
     297
     298                add_filter( 'wp_mail', '__return_false' );
     299                $this->assertFalse( wp_mail( WP_TESTS_EMAIL, 'Foo', 'Bar' ) );
     300                remove_filter( 'wp_mail', '__return_false' );
     301
     302                add_filter( 'wp_mail', '__return_empty_string' );
     303                $this->assertSame( '', wp_mail( WP_TESTS_EMAIL, 'Foo', 'Bar' ) );
     304                remove_filter( 'wp_mail', '__return_empty_string' );
     305        }
    291306}