commit 66c11afc086c23536dbcadea46dee4e6cb771445
Author: Assos Assos <assos+forge@centrale-marseille.fr>
Date:   Thu Jun 21 01:13:19 2018 +0200

    Weekly update of contrib modules

diff --git a/drupal7/sites/all/modules/file_entity/file_entity.file.inc b/drupal7/sites/all/modules/file_entity/file_entity.file.inc
index 683b1ca7..4949f4b6 100644
--- a/drupal7/sites/all/modules/file_entity/file_entity.file.inc
+++ b/drupal7/sites/all/modules/file_entity/file_entity.file.inc
@@ -116,14 +116,24 @@ function file_entity_file_update($file) {
       _file_entity_update_image_field_dimensions($file);
     }
 
-    // Flush image style derivatives whenever an image is updated.
-    image_path_flush($file->uri);
+    // Flush image style derivatives whenever an image is replaced.
+    if (empty($file->file_entity_skip_image_flush) && file_entity_has_file_changed($file)) {
+      image_path_flush($file->uri);
+    }
   }
 
   // Clear any related field caches.
   file_entity_invalidate_field_caches($file);
 }
 
+/**
+ * Returns whether the file has changed
+ */
+function file_entity_has_file_changed($file) {
+  return empty($file->is_new) || empty($file->original) || $file->filesize != $file->original->filesize || $file->uri != $file->original->uri;
+}
+
+
 /**
  * Implements hook_file_delete().
  */
diff --git a/drupal7/sites/all/modules/file_entity/file_entity.info b/drupal7/sites/all/modules/file_entity/file_entity.info
index 8076a4e2..0cf48a9b 100644
--- a/drupal7/sites/all/modules/file_entity/file_entity.info
+++ b/drupal7/sites/all/modules/file_entity/file_entity.info
@@ -32,8 +32,8 @@ configure = admin/config/media/file-settings
 ; We have to add a fake version so Git checkouts do not fail Media dependencies
 version = 7.x-2.x-dev
 
-; Information added by Drupal.org packaging script on 2018-05-02
-version = "7.x-2.21"
+; Information added by Drupal.org packaging script on 2018-06-14
+version = "7.x-2.22"
 core = "7.x"
 project = "file_entity"
-datestamp = "1525293788"
+datestamp = "1528996427"
diff --git a/drupal7/sites/all/modules/file_entity/file_entity.pages.inc b/drupal7/sites/all/modules/file_entity/file_entity.pages.inc
index 2e448380..864e7449 100644
--- a/drupal7/sites/all/modules/file_entity/file_entity.pages.inc
+++ b/drupal7/sites/all/modules/file_entity/file_entity.pages.inc
@@ -835,34 +835,27 @@ function file_entity_edit_submit($form, &$form_state) {
   if (!empty($form_state['values']['replace_upload'])) {
     $replacement = $form_state['values']['replace_upload'];
     // Move file from temp to permanent home.
-    if (pathinfo($replacement->uri, PATHINFO_EXTENSION) == pathinfo($file->uri, PATHINFO_EXTENSION)) {
-      if ($new_file_uri = file_unmanaged_copy($replacement->uri, $file->uri, FILE_EXISTS_REPLACE)) {
-        // Remove temporary file.
-        file_delete($replacement);
-      }
-    } else {
-      if (!empty($form_state['values']['replace_keep_original_filename'])
-      && $form_state['values']['replace_keep_original_filename']) {
-        $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($file->uri);
-      }
-      else {
-        $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($replacement->uri);
-      }
-      $replace_mode = $destination_uri == $file->uri ? FILE_EXISTS_REPLACE : FILE_EXISTS_RENAME;
-      if ($new_file_uri = file_unmanaged_copy($replacement->uri, $destination_uri, $replace_mode)) {
-        // @todo Add watchdog() about replaced file here?
+    if (!empty($form_state['values']['replace_keep_original_filename'])
+    && $form_state['values']['replace_keep_original_filename']) {
+      $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($file->uri);
+    }
+    else {
+      $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($replacement->uri);
+    }
+    $replace_mode = $destination_uri == $file->uri ? FILE_EXISTS_REPLACE : FILE_EXISTS_RENAME;
+    if ($new_file_uri = file_unmanaged_copy($replacement->uri, $destination_uri, $replace_mode)) {
+      // @todo Add watchdog() about replaced file here?
 
-        // Remove temporary file.
-        file_delete($replacement);
+      // Remove temporary file.
+      file_delete($replacement);
 
-        // Update if the uri target has changed.
-        if ($new_file_uri != $file->uri) {
-          // Store the original file uri to delete if save is successful.
-          $orphaned_uri = $file->uri;
+      // Update if the uri target has changed.
+      if ($new_file_uri != $file->uri) {
+        // Store the original file uri to delete if save is successful.
+        $orphaned_uri = $file->uri;
 
-          // Update file entity uri.
-          $file->uri = $new_file_uri;
-        }
+        // Update file entity uri.
+        $file->uri = $new_file_uri;
       }
     }
   }
diff --git a/drupal7/sites/all/modules/file_entity/tests/file_entity_test.info b/drupal7/sites/all/modules/file_entity/tests/file_entity_test.info
index 924d0eb4..8a7c0ff6 100644
--- a/drupal7/sites/all/modules/file_entity/tests/file_entity_test.info
+++ b/drupal7/sites/all/modules/file_entity/tests/file_entity_test.info
@@ -5,8 +5,8 @@ core = 7.x
 dependencies[] = file_entity
 hidden = TRUE
 
-; Information added by Drupal.org packaging script on 2018-05-02
-version = "7.x-2.21"
+; Information added by Drupal.org packaging script on 2018-06-14
+version = "7.x-2.22"
 core = "7.x"
 project = "file_entity"
-datestamp = "1525293788"
+datestamp = "1528996427"
