From 3442528240129e7c7ce43baa133074e8bafd2291 Mon Sep 17 00:00:00 2001 From: Lee Rowlands Date: Tue, 10 Oct 2017 07:45:38 +1000 Subject: [PATCH] Issue #2744663 by jholding, rivimey, John Cook, hctom, mahalingam_cs: Batch missing title on screen --- .../modules/system/src/Controller/BatchController.php | 11 +++++++++++ .../system/tests/src/Functional/Batch/PageTest.php | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/core/modules/system/src/Controller/BatchController.php b/core/modules/system/src/Controller/BatchController.php index 7975dcc43869..2e01c5bae123 100644 --- a/core/modules/system/src/Controller/BatchController.php +++ b/core/modules/system/src/Controller/BatchController.php @@ -61,11 +61,22 @@ class BatchController implements ContainerInjectionInterface { return $output; } elseif (isset($output)) { + $title = isset($output['#title']) ? $output['#title'] : NULL; $page = [ '#type' => 'page', + '#title' => $title, '#show_messages' => FALSE, 'content' => $output, ]; + + // Also inject title as a page header (if available). + if ($title) { + $page['header'] = [ + '#type' => 'page_title', + '#title' => $title, + ]; + } + return $page; } } diff --git a/core/modules/system/tests/src/Functional/Batch/PageTest.php b/core/modules/system/tests/src/Functional/Batch/PageTest.php index 9b1d4dd4ad80..b1e46a2ea5fb 100644 --- a/core/modules/system/tests/src/Functional/Batch/PageTest.php +++ b/core/modules/system/tests/src/Functional/Batch/PageTest.php @@ -50,7 +50,15 @@ class PageTest extends BrowserTestBase { // Visit an administrative page that runs a test batch, and check that the // title shown during batch execution (which the batch callback function // saved as a variable) matches the theme used on the administrative page. + // Run initial step only first. + $this->maximumMetaRefreshCount = 0; $this->drupalGet('batch-test/test-title'); + $this->assertText('Batch Test', 'The test is in the html output.'); + + // Leave the batch process running. + $this->maximumMetaRefreshCount = NULL; + $this->drupalGet('batch-test/test-title'); + // The stack should contain the title shown on the progress page. $this->assertEqual(batch_test_stack(), ['Batch Test'], 'The batch title is shown on the batch page.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');