Make WordPress Core


Ignore:
Timestamp:
09/23/2020 12:25:47 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Users: Check if the user ID passed as selected to wp_dropdown_users() corresponds to an existing user.

This avoids a few PHP notices if the include_selected parameter was specified and a non-existing user ID was passed.

Props campusboy1987.
Fixes #51370.

File:
1 edited

Legend:

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

    r47122 r49036  
    131131
    132132    /**
     133     * @ticket 51370
     134     */
     135    public function test_include_selected_with_non_existing_user_id() {
     136        $found = wp_dropdown_users(
     137            array(
     138                'echo'             => false,
     139                'selected'         => PHP_INT_MAX,
     140                'include_selected' => true,
     141                'show'             => 'user_login',
     142            )
     143        );
     144
     145        $this->assertNotContains( (string) PHP_INT_MAX, $found );
     146    }
     147
     148    /**
    133149     * @ticket 38135
    134150     */
Note: See TracChangeset for help on using the changeset viewer.