Upload: Ensure the new image meta is always saved before starting post-processing of an uploaded image, even if there was an error while scaling or rotating it.

See #48472.
Built from https://develop.svn.wordpress.org/trunk@46651


git-svn-id: http://core.svn.wordpress.org/trunk@46451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2019-11-04 17:07:03 +00:00
parent 4ef6154be2
commit 43ed67661a
2 changed files with 6 additions and 12 deletions

View File

@ -287,11 +287,6 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
if ( true === $rotated && ! empty( $image_meta['image_meta']['orientation'] ) ) {
$image_meta['image_meta']['orientation'] = 1;
}
// Initial save of the new metadata when the original image was scaled.
// At this point the file was uploaded and moved to the uploads directory
// but the image sub-sizes haven't been created yet and the `sizes` array is empty.
wp_update_attachment_metadata( $attachment_id, $image_meta );
} else {
// TODO: log errors.
}
@ -322,18 +317,17 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
if ( ! empty( $image_meta['image_meta']['orientation'] ) ) {
$image_meta['image_meta']['orientation'] = 1;
}
// Initial save of the new metadata when the original image was rotated.
wp_update_attachment_metadata( $attachment_id, $image_meta );
} else {
// TODO: log errors.
}
}
} else {
// Initial save of the new metadata when the image was not scaled or rotated.
wp_update_attachment_metadata( $attachment_id, $image_meta );
}
// Initial save of the new metadata.
// At this point the file was uploaded and moved to the uploads directory
// but the image sub-sizes haven't been created yet and the `sizes` array is empty.
wp_update_attachment_metadata( $attachment_id, $image_meta );
$new_sizes = wp_get_registered_image_subsizes();
/**

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.4-alpha-46650';
$wp_version = '5.4-alpha-46651';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.