Opened 6 years ago
Last modified 6 years ago
#47465 new defect (bug)
current_action function - return types
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | minor | Version: | 5.3 |
Component: | Administration | Keywords: | reporter-feedback needs-patch |
Focuses: | Cc: |
Description
I received a PHP notice "Array to string conversion" that led me to the current_action() function in class-wp-list-table.php.
This function can return an array as a valid value. For example this request will return an array:
http://localhost/site/?action[]=1&action[]=2
But in this case:
PHPDoc is incorrect. Should be:
@return string|false|array
or/and
this may break some of the scripts that use this function. simply because they use the result value as a string. Possible solution: add an additional check: IF array THAN take only the first value of the result.
Thanks!
Attachments (1)
Change History (4)
#2
@
6 years ago
- Keywords reporter-feedback added
Hi @madeinua, welcome to WordPress Trac! Thanks for the ticket.
As noted in the documentation, WP_List_Table::current_action()
returns the action selected from the Bulk Actions dropdown.
I haven't found any instances in core where $_REQUEST['action']
is an array. Do you have any examples that can be reproduced on a clean install, other than by directly editing the URL?
If some plugin uses $_REQUEST['action']
as an array for its own purposes, that sounds like a plugin issue, it should prefix the variable accordingly, e.g. my_plugin_action
.
Solution patch