Make WordPress Core

Opened 5 months ago

Last modified 6 weeks ago

#58789 new defect (bug)

Not countable. row_actions @ /wp-admin/includes/class-wp-list-table.php

Reported by: nate1's profile Nate1 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 6.2
Component: Administration Keywords: needs-patch
Focuses: Cc:

Description (last modified by sabernhardt)

Commonly getting not countable for the users lists, across many sites not sure of the source of the issue, but easy solution seems to be to modify.

/wp-admin/includes/class-wp-list-table.php

protected function row_actions( $actions, $always_visible = false ) 
++ if(!isset($actions)) { return ''; }

$action_count = count( $actions );
if ( ! $action_count ) {
return '';
}

Change History (2)

#1 @sabernhardt
6 weeks ago

  • Component changed from General to Administration
  • Description modified (diff)
  • Keywords needs-patch added

I think the problem might come from the user_row_actions filter returning false or an empty string, and then the $actions variable would be set but uncountable. Maybe row_actions() could check is_countable instead.

$action_count = is_countable( $actions ) ? count( $actions ) : 0;

#2 @Nate1
6 weeks ago

Provided is_countable handles NULL as well as false and empty strings then that will work well. The isset call has been applied to resolve the issue on PHP 8.1.X instances I've observed.

Note: See TracTickets for help on using tickets.