[wp-trac] [WordPress Trac] #58448: inconsistency in the $items parameter to the handle_bulk_actions-{$screen} action

WordPress Trac noreply at wordpress.org
Sat Jun 3 00:54:38 UTC 2023


#58448: inconsistency in the $items parameter to the handle_bulk_actions-{$screen}
action
----------------------------+-----------------------------
 Reporter:  pbiron          |      Owner:  (none)
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 The [https://developer.wordpress.org/reference/hooks/handle_bulk_actions-
 screen/ handle_bulk_actions-{$screen}] action is fired when custom bulk
 actions are applied on various screens that have list tables.

 On `/wp-admin/plugins.php`, `$items` is an array of plugin paths relative
 to `WP_PLUGINS_DIR` (e.g., `classic-editor/classic-editor.php`).

 On all the other screens, the `$items` parameter passed to the action's
 callback is an array of IDs (e.g., post IDs, term IDs, comment IDs, etc).
 The inconsistency this ticket is about that on some screens the IDs in
 `$items` are  ints and on other screens they are strings.

 Specifically, `/wp-admin/edit.php` (Posts list table), `/wp-
 admin/upload.php` (Media list table), and `/wp-admin/edit-comments.php`
 (Comments list table), the IDs are cast to ints via something like
 `array_map( 'intval', (array) $post_ids )` before
 `handle_bulk_actions-{$screen}` is fired.

 However, on all the other screens (`/wp-admin/edit-tags.php`, `/wp-admin-
 link-manager.php` (Links list table), and `/wp-admin/users.php`) the IDs
 are strings.

 I think it would be easier on developers (e.g., plugin authors) if when
 `$items` is an array of IDs, all IDs were ints.

 I don't know if this case be changed at this stage due to BC
 considerations.  But if it can be, I'd be happy to add a patch to that
 effect.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58448>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list