From cdf0726eadfa17ca0d1bd6ac8eca44ca955bd995 Mon Sep 17 00:00:00 2001
From: Lee Rowlands <lee.rowlands@previousnext.com.au>
Date: Sat, 24 Apr 2021 13:37:42 +1000
Subject: [PATCH] Issue #3204763 by longwave: Fix mismatched sprintf calls

---
 .../block/src/Plugin/migrate/process/BlockVisibility.php        | 2 +-
 .../file/src/Plugin/rest/resource/FileUploadResource.php        | 2 +-
 .../src/Controller/TemporaryJsonapiFileFieldUploader.php        | 2 +-
 .../src/Normalizer/EntityReferenceFieldItemNormalizer.php       | 2 +-
 .../Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php  | 2 +-
 core/modules/views/src/Plugin/views/field/FieldPluginBase.php   | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php b/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php
index fe05cc6babf7..ac39128bcf8a 100644
--- a/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php
+++ b/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php
@@ -123,7 +123,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
         // anything else -- the block will simply have no PHP or request_path
         // visibility configuration.
         elseif ($this->skipPHP) {
-          throw new MigrateSkipRowException(sprintf("The block with bid '%d' from module '%s' will have no PHP or request_path visibility configuration.", $row->getSourceProperty('bid'), $row->getSourceProperty('module'), $destination_property));
+          throw new MigrateSkipRowException(sprintf("The block with bid '%d' from module '%s' will have no PHP or request_path visibility configuration.", $row->getSourceProperty('bid'), $row->getSourceProperty('module')));
         }
       }
       else {
diff --git a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
index e650ed145da0..e16ddba453c0 100644
--- a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
+++ b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
@@ -264,7 +264,7 @@ public function post(Request $request, $entity_type_id, $bundle, $field_name) {
     $lock_id = $this->generateLockIdFromFileUri($file_uri);
 
     if (!$this->lock->acquire($lock_id)) {
-      throw new HttpException(503, sprintf('File "%s" is already locked for writing'), NULL, ['Retry-After' => 1]);
+      throw new HttpException(503, sprintf('File "%s" is already locked for writing', $file_uri), NULL, ['Retry-After' => 1]);
     }
 
     // Begin building file entity.
diff --git a/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php b/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php
index 39ef17f38704..979c05cb8594 100644
--- a/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php
+++ b/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php
@@ -181,7 +181,7 @@ public function handleFileUploadForField(FieldDefinitionInterface $field_definit
     $lock_id = $this->generateLockIdFromFileUri($file_uri);
 
     if (!$this->lock->acquire($lock_id)) {
-      throw new HttpException(503, sprintf('File "%s" is already locked for writing.'), NULL, ['Retry-After' => 1]);
+      throw new HttpException(503, sprintf('File "%s" is already locked for writing.', $file_uri), NULL, ['Retry-After' => 1]);
     }
 
     // Begin building file entity.
diff --git a/core/modules/serialization/src/Normalizer/EntityReferenceFieldItemNormalizer.php b/core/modules/serialization/src/Normalizer/EntityReferenceFieldItemNormalizer.php
index 0bfed445c9fd..7c3bd00d019e 100644
--- a/core/modules/serialization/src/Normalizer/EntityReferenceFieldItemNormalizer.php
+++ b/core/modules/serialization/src/Normalizer/EntityReferenceFieldItemNormalizer.php
@@ -75,7 +75,7 @@ protected function constructValue($data, $context) {
       /** @var \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem $field_item */
       $field_item = $context['target_instance'];
       if (empty($data['target_uuid'])) {
-        throw new InvalidArgumentException(sprintf('If provided "target_uuid" cannot be empty for field "%s".', $data['target_type'], $data['target_uuid'], $field_item->getName()));
+        throw new InvalidArgumentException(sprintf('If provided "target_uuid" cannot be empty for field "%s".', $field_item->getName()));
       }
       $target_type = $field_item->getFieldDefinition()->getSetting('target_type');
       if (!empty($data['target_type']) && $target_type !== $data['target_type']) {
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php
index 4e83171b205b..617dce5271d7 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php
@@ -395,7 +395,7 @@ public function testDenormalizeWithTypeWithIncorrectUuid() {
    */
   public function testDenormalizeWithEmptyUuid() {
     $this->expectException(InvalidArgumentException::class);
-    $this->expectExceptionMessage('If provided "target_uuid" cannot be empty for field "test_type".');
+    $this->expectExceptionMessage('If provided "target_uuid" cannot be empty for field "field_reference".');
 
     $data = [
       'target_id' => 'test',
diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
index a8a31f4f17f4..8207fce70cb2 100644
--- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
+++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
@@ -187,7 +187,7 @@ protected function addAdditionalFields($fields = NULL) {
 
           if (empty($table_alias)) {
             trigger_error(sprintf(
-              "Handler % tried to add additional_field %s but % could not be added!",
+              "Handler %s tried to add additional_field %s but %s could not be added!",
               $this->definition['id'],
               $identifier,
               $info['table']
-- 
GitLab