WordPress.org

Make WordPress Core

Opened 2 months ago

Closed 2 months ago

#47936 closed defect (bug) (fixed)

Users can only be deleted when the current user is selected.

Reported by: kbrownkd Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: trunk
Component: Users Keywords: has-patch
Focuses: Cc:
PR Number:

Description

Steps to reproduce:

  1. Attempt to delete 1 or more users. Do not select the current user.
  1. The Delete Users page displays:

You have specified these users for deletion:
There are no valid users selected for deletion.

With debugging enabled, the following warnings are displayed:

Notice: Undefined variable: all_userids in wp-admin/users.php on line 279
Warning: count(): Parameter must be an array or an object that implements Countable in wp-admin/users.php on line 279

Notice: Undefined variable: all_userids in wp-admin/users.php on line 288
Warning: Invalid argument supplied for foreach() in wp-admin/users.php on line 288

  1. Go back to the user deletion page.
  1. Select the current user and at least one other user for deletion and attempt to delete them. Observe that the deletion of the selected users proceeds as expected and without warnings.

This bug occurs because the variable $all_userids is declared only when the current user is selected for deletion. See lines 237 and 238 in wp-admin/users.php

Attachments (1)

47936.diff (461 bytes) - added by kbrownkd 2 months ago.

Download all attachments as: .zip

Change History (3)

@kbrownkd
2 months ago

#1 @SergeyBiryukov
2 months ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

Hi @kbrownkd, welcome to WordPress Trac! Thanks for the ticket.

Good catch! Introduced in [45806].

#2 @SergeyBiryukov
2 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 45890:

Users: Adjust [45806] to make sure $all_userids is always defined.

Props kbrownkd.
Fixes #47936.

Note: See TracTickets for help on using tickets.