diff --git a/core/authorize.php b/core/authorize.php index 4752799..073770a 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -21,6 +21,7 @@ */ use Drupal\Core\DrupalKernel; +use Drupal\Core\Form\EnforcedResponseException; use Drupal\Core\Url; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpFoundation\Request; @@ -169,7 +170,13 @@ function authorize_access_allowed(Request $request) { } elseif (!$batch = batch_get()) { // We have a batch to process, show the filetransfer form. - $content = \Drupal::formBuilder()->getForm('Drupal\Core\FileTransfer\Form\FileTransferAuthorizeForm'); + try { + $content = \Drupal::formBuilder()->getForm('Drupal\Core\FileTransfer\Form\FileTransferAuthorizeForm'); + } + catch (EnforcedResponseException $e) { + $e->getResponse()->send(); + exit; + } } } // We defer the display of messages until all operations are done. diff --git a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php index b6b43e1..3d95cc8 100644 --- a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php +++ b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php @@ -7,7 +7,6 @@ use Drupal\Core\Render\Element; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; /** * Provides the file transfer authorization form. @@ -226,10 +225,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // Now run the operation. $response = $this->runOperation($filetransfer); - if ($response instanceof RedirectResponse) { - $response->send(); - } - elseif ($response instanceof Response) { + if ($response instanceof Response) { $form_state->setResponse($response); } }