From 1940cf7d542407ffa0975d1cb6e51198cc445f8c Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 14 Oct 2019 20:05:01 +0000 Subject: [PATCH] Media: Do not store error messages in the image meta. The initial idea was to (be able to) display these errors in the UI but it wasn't implemented as these errors are mostly helpful for low-level bedugging. Fixes #40439. Built from https://develop.svn.wordpress.org/trunk@46507 git-svn-id: http://core.svn.wordpress.org/trunk@46304 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image.php | 42 ++++++------------------------------- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 37 deletions(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 41efa0ad13..53d9043402 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -277,10 +277,10 @@ function wp_create_image_subsizes( $file, $attachment_id ) { wp_update_attachment_metadata( $attachment_id, $image_meta ); } else { - // TODO: handle errors. + // TODO: log errors. } } else { - // TODO: handle errors. + // TODO: log errors. } } elseif ( ! empty( $exif_meta['orientation'] ) && (int) $exif_meta['orientation'] !== 1 ) { // Rotate the whole original image if there is EXIF data and "orientation" is not 1. @@ -309,7 +309,7 @@ function wp_create_image_subsizes( $file, $attachment_id ) { wp_update_attachment_metadata( $attachment_id, $image_meta ); } else { - // TODO: handle errors. + // TODO: log errors. } } } @@ -396,7 +396,7 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) { $rotated = $editor->maybe_exif_rotate(); if ( is_wp_error( $rotated ) ) { - // TODO: handle errors. + // TODO: log errors. } } @@ -405,41 +405,12 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) { $new_size_meta = $editor->make_subsize( $new_size_data ); if ( is_wp_error( $new_size_meta ) ) { - $error_code = $new_size_meta->get_error_code(); - - if ( $error_code === 'error_getting_dimensions' ) { - // Ignore errors when `image_resize_dimensions()` returns false. - // They mean that the requested size is larger than the original image and should be skipped. - continue; - } - - if ( empty( $image_meta['subsize_errors'] ) ) { - $image_meta['subsize_errors'] = array(); - } - - $error = array( - 'error_code' => $error_code, - 'error_message' => $new_size_meta->get_error_message(), - ); - - // Store the error code and error message for displaying in the UI. - $image_meta['subsize_errors'][ $new_size_name ] = $error; + // TODO: log errors. } else { - // The sub-size was created successfully. - // Clear out previous errors in creating this subsize. - if ( ! empty( $image_meta['subsize_errors'][ $new_size_name ] ) ) { - unset( $image_meta['subsize_errors'][ $new_size_name ] ); - } - - if ( empty( $image_meta['subsize_errors'] ) ) { - unset( $image_meta['subsize_errors'] ); - } - // Save the size meta value. $image_meta['sizes'][ $new_size_name ] = $new_size_meta; + wp_update_attachment_metadata( $attachment_id, $image_meta ); } - - wp_update_attachment_metadata( $attachment_id, $image_meta ); } } else { // Fall back to `$editor->multi_resize()`. @@ -447,7 +418,6 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) { if ( ! empty( $created_sizes ) ) { $image_meta['sizes'] = array_merge( $image_meta['sizes'], $created_sizes ); - unset( $image_meta['subsize_errors'] ); wp_update_attachment_metadata( $attachment_id, $image_meta ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 925a40416a..80f92ac9ab 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-beta3-46506'; +$wp_version = '5.3-beta3-46507'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.