#48472 closed defect (bug) (fixed)
The "wp_generate_attachment_metadata" filter is not fired when the initial upload request fails but the upload was completed successfully by retrying to create image sub-sizes
Reported by: | azaozz | Owned by: | azaozz |
---|---|---|---|
Milestone: | 5.3 | Priority: | normal |
Severity: | normal | Version: | trunk |
Component: | Upload | Keywords: | has-patch needs-testing 2nd-opinion fixed-major |
Focuses: | Cc: | ||
PR Number: |
Description
After #47872 it became possible to successfully complete an uploaded image post-processing even when the initial upload request resulted in a server error/PHP running out of resources.
However when that happens the wp_generate_attachment_metadata
filter is never reached and is not fired as expected. As this is the de-facto "upload is now completed successfully" hook, it causes problems in both updating/filtering the metadata on successful uploads and when using it to trigger additional post-processing.
Attachments (1)
Change History (10)
#2
@
11 days ago
In 48472.diff:
- Run the
wp_generate_attachment_metadata
filter at the end inwp_update_image_subsizes()
when new metadata was generated and additional image sub-sizes were created. This ensures consistent behavior with earlier WP versions. - Add another arg in the
wp_generate_attachment_metadata
filter to add context. - Fix some inline docs and ensure the new image meta is always saved before starting post-processing.
#3
@
11 days ago
- Keywords has-patch needs-testing 2nd-opinion added
For easier testing thinking to commit this to trunk (5.4) now. Backporting to the 5.3 branch will ideally happen in couple of days, after more testing/review/second opinion.
#4
@
11 days ago
- Owner set to azaozz
- Resolution set to fixed
- Status changed from new to closed
In 46621:
#5
@
11 days ago
- Keywords fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopen for merging to the 5.3 branch.
Moving to 5.3 for consideration.
There was a discussion and several regression reports in #core-media on Slack.
The consensus was that a hook needs to be fired after an image is uploaded successfully and all sub-sizes were created. Before #47872
wp_generate_attachment_metadata
was always fired in these cases. Firing it at the end ofwp_update_image_subsizes()
(when new metadta was generated and additional image sub-sizes created) seems to make the most sense and is backwards compatible.