Opened 15 months ago
Last modified 3 months ago
#58789 new defect (bug)
Not countable. row_actions @ /wp-admin/includes/class-wp-list-table.php
Reported by: | Nate1 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | major | Version: | 6.2 |
Component: | Administration | Keywords: | has-patch has-unit-tests needs-testing |
Focuses: | Cc: |
Description (last modified by )
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 (5)
#1
@
11 months ago
- Component changed from General to Administration
- Description modified (diff)
- Keywords needs-patch added
#2
@
11 months 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.
This ticket was mentioned in PR #6801 on WordPress/wordpress-develop by @m1r0.
4 months ago
#3
- Keywords has-patch has-unit-tests added; needs-patch removed
Trac ticket: https://core.trac.wordpress.org/ticket/58789
#5
@
4 months ago
Thanks m1r0 I check this GitHub pull request. It's helpful.
Also, To handle this more robustly, I can modify the code to ensure $actions is always treated as an array before attempting to count its elements by using this codes
protected function row_actions( $actions, $always_visible = false ) { // Ensure $actions is an array if ( ! is_array( $actions ) ) { $actions = array(); } $action_count = count( $actions ); if ( $action_count === 0 ) { return ''; } // Continue processing $actions as needed... }
By implementing these changes, thus avoiding errors related to null or non-array values. This should help in resolving the issue where $actions is "not countable" across sites.
I think the problem might come from the
user_row_actions
filter returningfalse
or an empty string, and then the$actions
variable would be set but uncountable. Mayberow_actions()
could checkis_countable
instead.