diff --git a/core/modules/file/file.routing.yml b/core/modules/file/file.routing.yml index b7d2e6a660b20416b581bacbfd38b2842dc85eb9..e182c97ee1cc7d3bf02d865fff23d58b13640564 100644 --- a/core/modules/file/file.routing.yml +++ b/core/modules/file/file.routing.yml @@ -1,5 +1,5 @@ file.ajax_progress: - path: '/file/progress' + path: '/file/progress/{key}' defaults: _controller: '\Drupal\file\Controller\FileWidgetAjaxController::progress' requirements: diff --git a/core/modules/file/src/Element/ManagedFile.php b/core/modules/file/src/Element/ManagedFile.php index 1d9a742cebb0c545c017e67f0fcf1c92716b906a..0077716523f540ecec69da2426264713b679f18e 100644 --- a/core/modules/file/src/Element/ManagedFile.php +++ b/core/modules/file/src/Element/ManagedFile.php @@ -271,7 +271,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st } // Add the upload progress callback. - $element['upload_button']['#ajax']['progress']['url'] = Url::fromRoute('file.ajax_progress'); + $element['upload_button']['#ajax']['progress']['url'] = Url::fromRoute('file.ajax_progress', ['key' => $upload_progress_key]); } // The file upload field itself. diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php index 7b0cce5455237725ba261e1979c56729779ca95e..0e308df86a4dd820cd9229aa90f72ae62012b509 100644 --- a/core/modules/file/src/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php @@ -447,6 +447,12 @@ public function testWidgetElement() { // If the field has at least a item, the table should be visible. $this->assertIdentical(count($elements), 1); + + // Test for AJAX error when using progress bar on file field widget + $key = $this->randomMachineName(); + $this->drupalPost('file/progress/' . $key, 'application/json', []); + $this->assertNoResponse(500, t('No AJAX error when using progress bar on file field widget')); + $this->assertText('Starting upload...'); } }