Make WordPress Core


Ignore:
Timestamp:
08/20/2019 05:25:02 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Users: In wp_insert_user(), account for the wp_pre_insert_user_data filter returning empty data.

Props juliobox, SergeyBiryukov.
Fixes #47902.

File:
1 edited

Legend:

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

    r45607 r45858  
    962962
    963963        $this->assertWPError( $u );
     964        $this->assertSame( 'invalid_user_id', $u->get_error_code() );
     965    }
     966
     967    /**
     968     * @ticket 47902
     969     */
     970    public function test_wp_insert_user_with_empty_data() {
     971        global $wpdb;
     972
     973        add_filter( 'wp_pre_insert_user_data', '__return_empty_array' );
     974
     975        $u = self::factory()->user->create();
     976
     977        remove_filter( 'wp_pre_insert_user_data', '__return_empty_array' );
     978
     979        $this->assertWPError( $u );
     980        $this->assertSame( 'empty_data', $u->get_error_code() );
    964981    }
    965982
Note: See TracChangeset for help on using the changeset viewer.