From 03f278a894e5cc9d3541498ea5159ff739c15c0e Mon Sep 17 00:00:00 2001
From: "lee.5151" <lee.5151@osu.edu>
Date: Mon, 28 Nov 2022 13:00:16 -0500
Subject: [PATCH] Upgrading drupal/media_entity_file_replace (1.0.0 => 1.1.0)

---
 composer.lock                                 | 16 ++++++-------
 vendor/composer/installed.json                | 18 +++++++-------
 vendor/composer/installed.php                 | 10 ++++----
 .../media_entity_file_replace.info.yml        |  8 +++----
 .../media_entity_file_replace.module          | 17 +++++++------
 .../Functional/MediaEntityFileReplaceTest.php | 24 +++++++++----------
 6 files changed, 48 insertions(+), 45 deletions(-)

diff --git a/composer.lock b/composer.lock
index 9f77354148..7805eb7166 100644
--- a/composer.lock
+++ b/composer.lock
@@ -5405,26 +5405,26 @@
         },
         {
             "name": "drupal/media_entity_file_replace",
-            "version": "1.0.0",
+            "version": "1.1.0",
             "source": {
                 "type": "git",
                 "url": "https://git.drupalcode.org/project/media_entity_file_replace.git",
-                "reference": "8.x-1.0"
+                "reference": "8.x-1.1"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://ftp.drupal.org/files/projects/media_entity_file_replace-8.x-1.0.zip",
-                "reference": "8.x-1.0",
-                "shasum": "a22fb6b946dade434301b85c249d8621d0fc6654"
+                "url": "https://ftp.drupal.org/files/projects/media_entity_file_replace-8.x-1.1.zip",
+                "reference": "8.x-1.1",
+                "shasum": "4462d41e80de7880e556eb677cd1831a44470dac"
             },
             "require": {
-                "drupal/core": "^8.7.7 || ^9"
+                "drupal/core": "^9 || ^10"
             },
             "type": "drupal-module",
             "extra": {
                 "drupal": {
-                    "version": "8.x-1.0",
-                    "datestamp": "1618180544",
+                    "version": "8.x-1.1",
+                    "datestamp": "1665518899",
                     "security-coverage": {
                         "status": "covered",
                         "message": "Covered by Drupal's security advisory policy"
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index ffdd21e445..d2b15f0c21 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -5587,27 +5587,27 @@
         },
         {
             "name": "drupal/media_entity_file_replace",
-            "version": "1.0.0",
-            "version_normalized": "1.0.0.0",
+            "version": "1.1.0",
+            "version_normalized": "1.1.0.0",
             "source": {
                 "type": "git",
                 "url": "https://git.drupalcode.org/project/media_entity_file_replace.git",
-                "reference": "8.x-1.0"
+                "reference": "8.x-1.1"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://ftp.drupal.org/files/projects/media_entity_file_replace-8.x-1.0.zip",
-                "reference": "8.x-1.0",
-                "shasum": "a22fb6b946dade434301b85c249d8621d0fc6654"
+                "url": "https://ftp.drupal.org/files/projects/media_entity_file_replace-8.x-1.1.zip",
+                "reference": "8.x-1.1",
+                "shasum": "4462d41e80de7880e556eb677cd1831a44470dac"
             },
             "require": {
-                "drupal/core": "^8.7.7 || ^9"
+                "drupal/core": "^9 || ^10"
             },
             "type": "drupal-module",
             "extra": {
                 "drupal": {
-                    "version": "8.x-1.0",
-                    "datestamp": "1618180544",
+                    "version": "8.x-1.1",
+                    "datestamp": "1665518899",
                     "security-coverage": {
                         "status": "covered",
                         "message": "Covered by Drupal's security advisory policy"
diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php
index bddb3ca2ac..10e9656d8e 100644
--- a/vendor/composer/installed.php
+++ b/vendor/composer/installed.php
@@ -3,7 +3,7 @@
         'name' => 'osu-asc-webservices/d8-upstream',
         'pretty_version' => 'dev-master',
         'version' => 'dev-master',
-        'reference' => '429f72e15c8ceea994931b8d1abf14e67c0e8c20',
+        'reference' => 'b32d6543d3f3958296e85fa3c3e6faf263f8a478',
         'type' => 'project',
         'install_path' => __DIR__ . '/../../',
         'aliases' => array(),
@@ -947,9 +947,9 @@
             'dev_requirement' => false,
         ),
         'drupal/media_entity_file_replace' => array(
-            'pretty_version' => '1.0.0',
-            'version' => '1.0.0.0',
-            'reference' => '8.x-1.0',
+            'pretty_version' => '1.1.0',
+            'version' => '1.1.0.0',
+            'reference' => '8.x-1.1',
             'type' => 'drupal-module',
             'install_path' => __DIR__ . '/../../web/modules/media_entity_file_replace',
             'aliases' => array(),
@@ -1594,7 +1594,7 @@
         'osu-asc-webservices/d8-upstream' => array(
             'pretty_version' => 'dev-master',
             'version' => 'dev-master',
-            'reference' => '429f72e15c8ceea994931b8d1abf14e67c0e8c20',
+            'reference' => 'b32d6543d3f3958296e85fa3c3e6faf263f8a478',
             'type' => 'project',
             'install_path' => __DIR__ . '/../../',
             'aliases' => array(),
diff --git a/web/modules/media_entity_file_replace/media_entity_file_replace.info.yml b/web/modules/media_entity_file_replace/media_entity_file_replace.info.yml
index 43d184a970..96c4b520cd 100644
--- a/web/modules/media_entity_file_replace/media_entity_file_replace.info.yml
+++ b/web/modules/media_entity_file_replace/media_entity_file_replace.info.yml
@@ -1,12 +1,12 @@
 name: Media Entity File Replace
 type: module
 description: Allows content editors to easily replace source files associated with any file-based media entity, preserving the original filename.
-core_version_requirement: ^8.7.7 || ^9
+core_version_requirement: ^9 || ^10
 package: Media
 dependencies:
   - drupal:media
 
-# Information added by Drupal.org packaging script on 2021-04-11
-version: '8.x-1.0'
+# Information added by Drupal.org packaging script on 2022-10-11
+version: '8.x-1.1'
 project: 'media_entity_file_replace'
-datestamp: 1618180546
+datestamp: 1665518902
diff --git a/web/modules/media_entity_file_replace/media_entity_file_replace.module b/web/modules/media_entity_file_replace/media_entity_file_replace.module
index 54efeab30f..ecee72f6c6 100644
--- a/web/modules/media_entity_file_replace/media_entity_file_replace.module
+++ b/web/modules/media_entity_file_replace/media_entity_file_replace.module
@@ -30,9 +30,9 @@ function media_entity_file_replace_help($route_name, RouteMatchInterface $route_
 function media_entity_file_replace_entity_extra_field_info() {
   $extra = [];
 
-  // Create an psuedo-field on form displays to allow site builders to control
-  // if they want to enable our custom file replacement widget on media
-  // edit forms.
+  // Create an pseudo-field on form displays to allow site builders to control
+  // if they want to enable our custom file replacement widget on media edit
+  // forms.
   if (\Drupal::service('module_handler')->moduleExists('media')) {
     $mediaTypes = \Drupal::entityTypeManager()
       ->getStorage('media_type')
@@ -59,7 +59,7 @@ function media_entity_file_replace_entity_extra_field_info() {
  *
  * Modify media edit form to add a custom replacement file form field.
  * The custom field we add here will not be automatically hidden unless the
- * entity form display has enabled the the pseudo-widget we defined in
+ * entity form display has enabled the pseudo-widget we defined in
  * media_entity_file_replace_entity_extra_field_info().
  */
 function media_entity_file_replace_form_media_form_alter(&$form, FormStateInterface $form_state, $form_id) {
@@ -114,9 +114,12 @@ function media_entity_file_replace_form_media_form_alter(&$form, FormStateInterf
     ];
     $form['replace_file']['replacement_file']['#description'] = \Drupal::service('renderer')->renderPlain($helpText);
 
+    // Inform the user that when replacing the original file, the new one
+    // must have the same extension.
+    $originalExtension = '.' . pathinfo($fileFieldItem->entity->getFilename(), PATHINFO_EXTENSION);
     $form['replace_file']['keep_original_filename'] = [
-      '#title' => t('Overwrite original file'),
-      '#description' => t('When checked, the original filename is kept and its contents are replaced with the new file. If unchecked, the filename of the replacement file will be used, and the original file may be deleted if no previous revision references it (depending on your specific site configuration).'),
+      '#title' => t('Overwrite original file (@originalExtension)', ['@originalExtension' => $originalExtension]),
+      '#description' => t('When checked, the original filename is kept and its contents are replaced with the new file, which <strong>must have the same file extension: @originalExtension</strong>. If unchecked, the filename of the replacement file will be used with any allowed file type and the original file may be deleted if no previous revision references it (depending on your specific site configuration).', ['@originalExtension' => $originalExtension]),
       '#type' => 'checkbox',
       '#default_value' => TRUE,
     ];
@@ -206,7 +209,7 @@ function _media_entity_file_replace_validate($form, FormStateInterface $formStat
   // file, and browsers use that content type when interpretting the data.
   if ($formState->getValue('keep_original_filename')) {
     $originalFileEntity = $media->get($sourceFieldName)->first()->entity;
-    $originalExtension = pathinfo($originalFileEntity->getFilename(), PATHINFO_EXTENSION);
+    $originalExtension = pathinfo($originalFileEntity->getFileUri(), PATHINFO_EXTENSION);
     $uploadValidators['file_validate_extensions'] = [$originalExtension];
   }
 
diff --git a/web/modules/media_entity_file_replace/tests/src/Functional/MediaEntityFileReplaceTest.php b/web/modules/media_entity_file_replace/tests/src/Functional/MediaEntityFileReplaceTest.php
index 6668e655fc..b1c1fe682a 100644
--- a/web/modules/media_entity_file_replace/tests/src/Functional/MediaEntityFileReplaceTest.php
+++ b/web/modules/media_entity_file_replace/tests/src/Functional/MediaEntityFileReplaceTest.php
@@ -21,7 +21,7 @@ class MediaEntityFileReplaceTest extends BrowserTestBase {
    *
    * @var array
    */
-  public static $modules = [
+  protected static $modules = [
     'system',
     'field_ui',
     'media',
@@ -132,11 +132,11 @@ public function testModule() {
     // the contents of the file have.
     $updatedDocument = $this->loadMediaEntityByName('Foobar');
     $updatedFile = $this->loadFileEntity($updatedDocument->getSource()->getSourceFieldValue($updatedDocument));
-    $this->assertEqual($updatedFile->id(), $originalFile->id());
-    $this->assertEqual($updatedFile->getFileUri(), $originalFile->getFileUri());
-    $this->assertEqual($updatedFile->getFilename(), $originalFile->getFilename());
-    $this->assertNotEqual($updatedFile->getSize(), $originalFile->getSize());
-    $this->assertEqual(file_get_contents($updatedFile->getFileUri()), 'new');
+    $this->assertEquals($updatedFile->id(), $originalFile->id());
+    $this->assertEquals($updatedFile->getFileUri(), $originalFile->getFileUri());
+    $this->assertEquals($updatedFile->getFilename(), $originalFile->getFilename());
+    $this->assertNotEquals($updatedFile->getSize(), $originalFile->getSize());
+    $this->assertEquals(file_get_contents($updatedFile->getFileUri()), 'new');
 
     // Now upload another replacement document, but this time don't overwrite
     // the original.
@@ -155,12 +155,12 @@ public function testModule() {
     // previous one.
     $updatedDocument = $this->loadMediaEntityByName('Foobar');
     $updatedFile = $this->loadFileEntity($updatedDocument->getSource()->getSourceFieldValue($updatedDocument));
-    $this->assertNotEqual($updatedFile->id(), $originalFile->id());
-    $this->assertNotEqual($updatedFile->getFileUri(), $originalFile->getFileUri());
-    $this->assertNotEqual($updatedFile->getFilename(), $originalFile->getFilename());
-    $this->assertNotEqual($updatedFile->getSize(), $originalFile->getSize());
-    $this->assertNotEqual(file_get_contents($updatedFile->getFileUri()), file_get_contents($originalFile->getFileUri()));
-    $this->assertEqual(file_get_contents($updatedFile->getFileUri()), 'foo-new');
+    $this->assertNotEquals($updatedFile->id(), $originalFile->id());
+    $this->assertNotEquals($updatedFile->getFileUri(), $originalFile->getFileUri());
+    $this->assertNotEquals($updatedFile->getFilename(), $originalFile->getFilename());
+    $this->assertNotEquals($updatedFile->getSize(), $originalFile->getSize());
+    $this->assertNotEquals(file_get_contents($updatedFile->getFileUri()), file_get_contents($originalFile->getFileUri()));
+    $this->assertEquals(file_get_contents($updatedFile->getFileUri()), 'foo-new');
     $this->assertFalse($updatedFile->isTemporary());
 
     // The old file entity should still exist, and should not be marked as
-- 
GitLab