From 00ff6675a27fa79258fe2d4ac8e6db93ba2e0ae9 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 7 Jan 2015 22:48:22 +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. Built from https://develop.svn.wordpress.org/trunk@31070 git-svn-id: http://core.svn.wordpress.org/trunk@31051 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image-edit.php | 6 ++++-- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php index cdb1cf8e98..f8a9d507f7 100644 --- a/wp-admin/includes/image-edit.php +++ b/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; } diff --git a/wp-includes/version.php b/wp-includes/version.php index a61d23176a..07c5836780 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31069'; +$wp_version = '4.2-alpha-31070'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.