WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/24/2015 11:06:03 PM (6 years ago)
Author:
ocean90
Message:

Passwords: Support the pre-4.3 behavior of wp_new_user_notification().

Hello, it's me again. A pluggable function named wp_new_user_notification(). A few months ago, after [33023], I have lost my second parameter $plaintext_pass. But thanks to [33620] I got a new one.
Bad idea - It hasn't had the same behavior as my previous parameter.
To solve that the second parameter got deprecated and reintroduced as the third parameter in [34116]. I was happy again, for a short time.
You remember my lost friend $plaintext_pass? No? Well, if its value was empty no notification was sent to the user. This behavior was still lost. And that's what this change is about: Don't notify a user if a plugin uses wp_new_user_notification( $user_id ).

You're asking if I'm happy now? Dunno, but maybe you have learned something about pluggable functions, have you?

Props danielbachhuber.
Fixes #34377.

File:
1 edited

Legend:

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

    r35732 r35735  
    10411041     * @expectedDeprecated wp_new_user_notification
    10421042     */
    1043     function test_wp_new_user_notification_old_signature_throws_deprecated_warning() {
    1044         wp_new_user_notification( self::$author_id, 'this_is_deprecated' );
    1045     }
    1046 
     1043    function test_wp_new_user_notification_old_signature_throws_deprecated_warning_but_sends() {
     1044        unset( $GLOBALS['phpmailer']->mock_sent );
     1045
     1046        $was_admin_email_sent = false;
     1047        $was_user_email_sent = false;
     1048        wp_new_user_notification( self::$contrib_id, 'this_is_a_test_password' );
     1049
     1050        /*
     1051         * Check to see if a notification email was sent to the
     1052         * post author `blackburn@battlefield3.com` and and site admin `admin@example.org`.
     1053         */
     1054        if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
     1055            $was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
     1056            $was_user_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' == $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
     1057        }
     1058
     1059        $this->assertTrue( $was_admin_email_sent );
     1060        $this->assertTrue( $was_user_email_sent );
     1061    }
     1062
     1063    /**
     1064     * Set up a user and try sending a notification using `wp_new_user_notification( $user );`.
     1065     *
     1066     * @ticket 34377
     1067     */
     1068    function test_wp_new_user_notification_old_signature_no_password() {
     1069        unset( $GLOBALS['phpmailer']->mock_sent );
     1070
     1071        $was_admin_email_sent = false;
     1072        $was_user_email_sent = false;
     1073        wp_new_user_notification( self::$contrib_id );
     1074
     1075        /*
     1076         * Check to see if a notification email was sent to the
     1077         * post author `blackburn@battlefield3.com` and and site admin `admin@example.org`.
     1078         */
     1079        if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
     1080            $was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
     1081            $was_user_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' == $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
     1082        }
     1083
     1084        $this->assertTrue( $was_admin_email_sent );
     1085        $this->assertFalse( $was_user_email_sent );
     1086    }
    10471087}
Note: See TracChangeset for help on using the changeset viewer.