[wp-trac] [WordPress Trac] #47872: Try to create image sub-sizes again when uploading fails with a PHP fatal error
WordPress Trac
noreply at wordpress.org
Sat Oct 26 19:26:00 UTC 2019
#47872: Try to create image sub-sizes again when uploading fails with a PHP fatal
error
-------------------------------------------------+-------------------------
Reporter: azaozz | Owner: azaozz
Type: enhancement | Status: closed
Priority: high | Milestone: 5.3
Component: Upload | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch needs-testing has- | Focuses:
screenshots close has-dev-note |
-------------------------------------------------+-------------------------
Comment (by azaozz):
Replying to [comment:36 GregLone]:
> Currently we optimize the images asynchronously with a queue system
after all thumbnails are created.
Yes, this is by far the better option. And not only in another thread, but
at a later time, something like 10 min later perhaps? The reason is that
the user may be uploading multiple images at the same time. Then if
optimization starts right after the first image was successfully uploaded,
it will most likely coincide with the post-processing of the second image
and may hit any resource limitations on the server regardless that it's in
another thread. Basically optimizing image A's sub-sizes while image B's
sub-sizes are being created.
Generally (if I'm imagining how this works correctly) optimized and non-
optimized images are interchangeable. The optimization replaces the non-
optimized image sub-size file with an optimized file. So it seems best to
perform the optimization a bit later, when the server is not under heavy
load.
I agree, having a definitive "upload is now done and all sub-sizes are
created" hook will be helpful. However it's not very straightforward to
pass that "context" to `wp_update_image_subsizes()`. Looking at the AJAX
action is not enough as files may be uploaded through the REST API.
At the same time it would be good to catch all uses of
`wp_update_image_subsizes()` regardless if it is run while re-trying after
an error during upload or at a later time. Thinking adding an `action` at
the bottom there would make this work better for optimization of the new
sub-sizes, or perhaps other actions that plugins want to perform when
more/new sub-sizes are created.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47872#comment:38>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list