WordPress.org

Make WordPress Core

Changeset 46507


Ignore:
Timestamp:
10/14/2019 08:03:01 PM (5 weeks ago)
Author:
azaozz
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image.php

    r46459 r46507  
    278278                wp_update_attachment_metadata( $attachment_id, $image_meta );
    279279            } else {
    280                 // TODO: handle errors.
     280                // TODO: log errors.
    281281            }
    282282        } else {
    283             // TODO: handle errors.
     283            // TODO: log errors.
    284284        }
    285285    } elseif ( ! empty( $exif_meta['orientation'] ) && (int) $exif_meta['orientation'] !== 1 ) {
     
    310310                wp_update_attachment_metadata( $attachment_id, $image_meta );
    311311            } else {
    312                 // TODO: handle errors.
     312                // TODO: log errors.
    313313            }
    314314        }
     
    397397
    398398        if ( is_wp_error( $rotated ) ) {
    399             // TODO: handle errors.
     399            // TODO: log errors.
    400400        }
    401401    }
     
    406406
    407407            if ( is_wp_error( $new_size_meta ) ) {
    408                 $error_code = $new_size_meta->get_error_code();
    409 
    410                 if ( $error_code === 'error_getting_dimensions' ) {
    411                     // Ignore errors when `image_resize_dimensions()` returns false.
    412                     // They mean that the requested size is larger than the original image and should be skipped.
    413                     continue;
    414                 }
    415 
    416                 if ( empty( $image_meta['subsize_errors'] ) ) {
    417                     $image_meta['subsize_errors'] = array();
    418                 }
    419 
    420                 $error = array(
    421                     'error_code'    => $error_code,
    422                     'error_message' => $new_size_meta->get_error_message(),
    423                 );
    424 
    425                 // Store the error code and error message for displaying in the UI.
    426                 $image_meta['subsize_errors'][ $new_size_name ] = $error;
     408                // TODO: log errors.
    427409            } else {
    428                 // The sub-size was created successfully.
    429                 // Clear out previous errors in creating this subsize.
    430                 if ( ! empty( $image_meta['subsize_errors'][ $new_size_name ] ) ) {
    431                     unset( $image_meta['subsize_errors'][ $new_size_name ] );
    432                 }
    433 
    434                 if ( empty( $image_meta['subsize_errors'] ) ) {
    435                     unset( $image_meta['subsize_errors'] );
    436                 }
    437 
    438410                // Save the size meta value.
    439411                $image_meta['sizes'][ $new_size_name ] = $new_size_meta;
    440             }
    441 
    442             wp_update_attachment_metadata( $attachment_id, $image_meta );
     412                wp_update_attachment_metadata( $attachment_id, $image_meta );
     413            }
    443414        }
    444415    } else {
     
    448419        if ( ! empty( $created_sizes ) ) {
    449420            $image_meta['sizes'] = array_merge( $image_meta['sizes'], $created_sizes );
    450             unset( $image_meta['subsize_errors'] );
    451421            wp_update_attachment_metadata( $attachment_id, $image_meta );
    452422        }
Note: See TracChangeset for help on using the changeset viewer.