diff --git a/core/includes/batch.inc b/core/includes/batch.inc index 89bd7e4a8851a47bab0eba55d6ea0d02aeb70113..7d905cdade5e08c7b5272c82773b3dfd9cb6e1d2 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -15,7 +15,6 @@ */ use Drupal\Component\Utility\SafeMarkup; -use Drupal\Component\Utility\String; use Drupal\Component\Utility\Timer; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Batch\Percentage; @@ -24,7 +23,6 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Renders the batch processing page based on the current state of the batch. @@ -45,7 +43,8 @@ function _batch_page(Request $request) { if (!$batch) { $batch = \Drupal::service('batch.storage')->load($request_id); if (!$batch) { - throw new NotFoundHttpException(String::format('Batch %id requested, but not found.', array('%id' => $request_id))); + drupal_set_message(t('No active batch.'), 'error'); + return new RedirectResponse(\Drupal::url('', [], ['absolute' => TRUE])); } } // Restore safe strings from previous batches. diff --git a/core/tests/Drupal/Tests/Core/Batch/BatchNotFoundTest.php b/core/tests/Drupal/Tests/Core/Batch/BatchNotFoundTest.php deleted file mode 100644 index 2105599cdb5a5f47dde68c56b91071988d99dffc..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/Tests/Core/Batch/BatchNotFoundTest.php +++ /dev/null @@ -1,76 +0,0 @@ -adminUser = $this->drupalCreateUser(array('administer users'));; - $this->userToBeDeleted = $this->drupalCreateUser(); - } - - /** - * Tests for page not found error if batch ID does not exist. - */ - public function testBatchNotFound() { - $this->drupalLogin($this->adminUser); - - // Replicate a batch process by cancelling a user. - $edit = array( - 'action' => 'user_cancel_user_action', - 'user_bulk_form[2]' => TRUE, - ); - $this->drupalPostForm('admin/people', $edit, t('Apply')); - $this->drupalPostForm(NULL, array(), t('Cancel accounts')); - - $batch_id = db_next_id(); - - $this->drupalGet('batch', array( - 'query' => array( - 'op' => 'start', - 'id' => $batch_id, - ), - )); - - $this->assertResponse(404); - } - -}