From 3fdc11be2925ca9ea3321b8212d3d31a33fa8ee1 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 7 Jan 2015 22:47:32 +0000 Subject: [PATCH] Image file editor: fix a wrong error message when restoring an edited image and IMAGE_EDIT_OVERWRITE is set. Props tiqbiz, fixes #30167. git-svn-id: https://develop.svn.wordpress.org/trunk@31070 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/image-edit.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php index cdb1cf8e98..f8a9d507f7 100644 --- a/src/wp-admin/includes/image-edit.php +++ b/src/wp-admin/includes/image-edit.php @@ -567,7 +567,7 @@ function stream_preview_image( $post_id ) { function wp_restore_image($post_id) { $meta = wp_get_attachment_metadata($post_id); $file = get_attached_file($post_id); - $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); + $backup_sizes = $old_backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); $restored = false; $msg = new stdClass; @@ -629,7 +629,9 @@ function wp_restore_image($post_id) { } } - if ( !wp_update_attachment_metadata($post_id, $meta) || !update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes) ) { + if ( ! wp_update_attachment_metadata( $post_id, $meta ) || + ( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) ) { + $msg->error = __('Cannot save image metadata.'); return $msg; }