#53411 closed defect (bug) (fixed)
Incorrect isset check in media bulk actions
Reported by: | david.binda | Owned by: | davidbaumwald |
---|---|---|---|
Milestone: | 5.8 | Priority: | normal |
Severity: | normal | Version: | 5.8 |
Component: | Media | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
After r51111 which makes sure that the $post_ids
variable is always set, the isset()
check later in the code is never matched.
The checks failure results in an extra redirect to wp-admin/upload.php?deleted=0
and then finally back to wp-admin/upload.php
in case there are no IDs passed to some default bulk actions (eg.: delete).
Prior this change, in case there were no IDs passed to the bulk action, the request was redirected directly to wp-admin/upload.php
.
It can be easily tested by visiting the wp-admin/upload.php
screen and submitting any bulk action w/o selecting any media.
My understanding is, that with r51111 in place, the checks in question should be updated to empty()
. See attached patch.
Related code lines:
- https://core.trac.wordpress.org/browser/trunk/src/wp-admin/upload.php?rev=51111#L151
- https://core.trac.wordpress.org/browser/trunk/src/wp-admin/upload.php?rev=51111#L172
- https://core.trac.wordpress.org/browser/trunk/src/wp-admin/upload.php?rev=51111#L187 )
Follow-up to #39589
Attachments (1)
Change History (7)
#3
@
3 years ago
- Keywords has-patch commit added
Review summary:
Yes, @davidbinda is right. The variable is now initialized and set to an empty array. This means isset()
is no longer the appropriate construct. The check in this context is for no post IDs, which means checking for an empty array. empty()
is a good guard clause as well as a valid check for this context.
- The patch looks good
- Manually tested with expected results
- Tests passing
- Linting passing
Marking for commit.
Thanks @davidbinda!
@whyisjake @hellofromtonya are you able to take a look at this one?