Opened 5 months ago
Last modified 2 months ago
#50972 reviewing defect (bug)
media_handle_sideload() does not allow $post_data to override the post_date that gets used by wp_upload_dir
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.7 | Priority: | normal |
Severity: | minor | Version: | 5.3 |
Component: | Media | Keywords: | has-patch needs-unit-tests |
Focuses: | Cc: |
Description
Now that $post_id is an optional attribute to media_handle_sideload() it should be possible to override the $time passed to wp_handle_sideload() via the optional $post_data array.
My use case is calling media_handle_sideload() via a custom plugin, only after the existing library is checked for duplicates is the post actually created so there is no $post_id to reference (yet).
Attachments (2)
Change History (11)
#2
@
5 months ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 5.6
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
#3
@
5 months ago
Hi there!
isset( $post_data )
value is always true when it was empty array or non empty array.
Update the patch without checking it.
#4
@
5 months ago
I always assume that someone's going to do something wrong like try to pass in null or false as an argument. So in my opinion it's safer to at least check. One step further would be a check for is_array().
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
3 months ago
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
3 months ago
#8
@
3 months ago
- Milestone changed from 5.6 to 5.7
It was mentioned in the recent Media meeting that the sideloading functions could benefit from a refactor to allow testing as it is currently hard to test the same way that media_sideload_image
was and did not receive tests.
Being so late in beta cycle it's probably best to move this out of the 5.6 milestone. If anyone feels differently please feel free to move it back in.
#50971 was marked as a duplicate.