Problem/Motivation

Title is not shown when a batch task is running. With the default admin theme (seven), there is only a star to add the page to shortcuts.

Missing title

Proposed resolution

Fix the bug and show the page title on the batch UI pages.

Remaining tasks

  1. Review the patch.
  2. Create Tests
  3. Review

User interface changes

Title showing up on batch pages.
Batch Title

API changes

N/A

Original report by @mikeryan

The batch processing page when running migrations lacks a title - add one.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because the title is not shown when it should be.
Issue priority Major because this was working in Drupal 7 and it is a major item missing on all batch pages.
Disruption Not disruptive

Comments

pushpinderchauhan’s picture

Version: » 8.x-1.x-dev
Assigned: Unassigned » pushpinderchauhan
pushpinderchauhan’s picture

Mike, What title we need to show here, please elaborate little bit more.

mikeryan’s picture

t('Running migrations') - it's actually set in the batch array, the reason this is a bug report rather than a task is for some reason the page title while the migration is running shows up as "Site-Install" (in my standard profile install of D8). I'm looking for someone to figure out why the title isn't showing as expected.

Thanks.

hussainweb’s picture

Title: Add title to batch processing » Title not shown during a batch operation
Project: Migrate Upgrade » Drupal core
Version: 8.x-1.x-dev » 8.x-dev
Component: User interface » batch system
Assigned: pushpinderchauhan » hussainweb
Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new544 bytes

The problem seems to be in Drupal core. I was able to reproduce this for Cancel User batch operation. To reproduce:
* Create a test user.
* Go to People listing page, select the checkbox for the test user and in 'With selection' dropdown, select 'Cancel the selected user account(s)'.
* This step may not matter but just in case, select 'Delete the account and its content.' on the next page and 'Cancel accounts'.
* Observe on the next page with the scrollbar that there is no title, even though the code sets it to t('Cancelling account').

Apply the patch and repeat the steps above. The title now appears. This also fixes the original issue with the Migrate Upgrade module.

mikeryan’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

That looks great, nice and simple. Just one thing - the core tests have been passing with this issue present, so we should have a test to demonstrate that failure, can you add one?

Thanks.

hussainweb’s picture

Tests have been my weakness, but I completely agree - we need one. I will see if I can do it today, otherwise, it will be over the weekend.

karolus’s picture

Just ran this test--the patch applied cleanly, and looks like a good UX improvement...

joachim’s picture

StatusFileSize
new1.95 KB

This is a very rough stab at adding testing of this, not tried it out yet -- let's see what the testbot says.

- I'm not sure where best to put it. The batch tests seem a little messy. The PageTest class describes itself as testing the batch page, but then its actual test method is about testing the theme.
- I've no idea whether the test can actually 'see' the batch page long enough for us to run an assertion on it.

mikeryan’s picture

The issue status needs to be "Needs review" for the test bot to go at it. But, first, please submit a test-only patch without the fix - we need to test the test to be sure it fails without the fix.

Thanks.

joachim’s picture

Status: Needs work » Needs review

It's probably going to fail without the fix too... let's just check that.

Status: Needs review » Needs work

The last submitted patch, 8: 2282035.8.drupal.batch-title.patch, failed testing.

hussainweb’s picture

Status: Needs work » Needs review
Issue tags: -Novice, -Needs tests +Needs issue summary update
StatusFileSize
new4.06 KB
new5.77 KB

After a long long analysis, I think I got the test running. I have attached both a test only patch (which should fail) and then the complete patch.

The challenge in writing the test was, as already pointed out, that the test can't capture the progress page where the title is shown. Other methods use batch_test_stack to store state information and that is checked later. I planned on doing the same thing but there was no way to find the title. drupal_get_title is deprecated and the snippet shown instead of drupal_get_title did not work. The only way I could get the title in the test was by using _batch_current_set. If we use that, we are not testing the right thing here.

Instead, I set about fixing why the title resolver didn't work. I made the changes in the patch. There is a call to the title resolver in code (which means the fix in #4 would be unnecessary) but that line would never get called due to the if condition. We should probably fix/remove that in a different issue.

The last submitted patch, 12: title_not_shown_batch-2282035-12-tests-only.patch, failed testing.

dawehner’s picture

+++ b/core/modules/system/src/Controller/BatchController.php
@@ -86,6 +86,7 @@ public function batchPage(Request $request) {
+      $page['#title'] = $output['#title'];

+++ b/core/modules/system/system.routing.yml
@@ -392,6 +392,7 @@ system.batch_page.normal:
   defaults:
     _content: '\Drupal\system\Controller\BatchController::batchPage'
+    _title_callback: '\Drupal\system\Controller\BatchController::batchPageTitle'
   requirements:
     _access: 'TRUE'
   options:
@@ -401,6 +402,7 @@ system.batch_page.json:

@@ -401,6 +402,7 @@ system.batch_page.json:
   requirements:

Are you sure you need both of them?

hussainweb’s picture

@dawehner: Actually, we don't. I started with the PHP code and then when I started writing the test, I realized that I would have to use _title_callback to get it to work. I left in the PHP code as it wouldn't really do any harm (probably just a slight chance of confusion). Do you think we should remove it?

dawehner’s picture

If it is not needed drop it, there is one less potential source of a bug.
Did you checked whether you can remove the _title_callback from the json route? This route should not have a title as it is never rendered as html.

hussainweb’s picture

StatusFileSize
new1.02 KB
new5.22 KB

I have dropped that line as per #17 and also removed _title_callback from json route. The tests only patch is still the same.

Status: Needs review » Needs work

The last submitted patch, 18: title_not_shown_batch-2282035-18.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 18: title_not_shown_batch-2282035-18.patch, failed testing.

hussainweb’s picture

Status: Needs work » Needs review
StatusFileSize
new502 bytes
new5.51 KB

I am just reverting one of the changes removed in #18 to see if that is the reason for the test failure.

hussainweb’s picture

This is quite strange. I wonder why the _title_callback on JSON path would affect the regular path. I think this needs more debugging, and might be a flag on a bigger bug.

jhedstrom’s picture

Re #23 I don't understand. In the failing test in #18, both ways of setting the page title were removed, rather than just one:

diff --git a/core/modules/system/src/Controller/BatchController.php b/core/modules/system/src/Controller/BatchController.php
index b17d26c..35f9c3d 100644
--- a/core/modules/system/src/Controller/BatchController.php
+++ b/core/modules/system/src/Controller/BatchController.php
@@ -86,7 +86,6 @@ public function batchPage(Request $request) {
       drupal_set_page_content($output);
       $page = element_info('page');
       $page['#show_messages'] = FALSE;
-      $page['#title'] = $output['#title'];
 
       $page = $this->render($page);
 
diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml
index 8c1641d..62fa09f 100644
--- a/core/modules/system/system.routing.yml
+++ b/core/modules/system/system.routing.yml
@@ -402,7 +402,6 @@ system.batch_page.json:
   path: '/batch'
   defaults:
     _controller: '\Drupal\system\Controller\BatchController::batchPage'
-    _title_callback: '\Drupal\system\Controller\BatchController::batchPageTitle'
   requirements:
     _access: 'TRUE'
     _format: 'json'
 

In #22 one was added back and the tests pass again. Am I missing something?

Status: Needs review » Needs work

The last submitted patch, 22: title_not_shown_batch-2282035-22.patch, failed testing.

anavarre’s picture

Issue tags: +Needs reroll
hussainweb’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new5.44 KB

Doing a reroll first.

hussainweb’s picture

@jhedstrom: See #15. I removed changes from the JSON route and it failed but it worked when I added it back. Like I said in #23, it was rather strange and indicative of some other bug.

Since it is 4 months, I will try removing it again to see if it still fails after the reroll passes.

Status: Needs review » Needs work

The last submitted patch, 28: title_not_shown_batch-2282035-28.patch, failed testing.

hussainweb’s picture

Status: Needs work » Needs review
StatusFileSize
new1.38 KB
new5.45 KB

Fixing the failure.

hussainweb’s picture

StatusFileSize
new502 bytes
new5.17 KB

Trying out by reverting the change I reverted in #22. This removes the _title_callback from the JSON route (which should not be necessary). This made the tests pass earlier but that was 4 months back. Let's see if this was fixed.

hussainweb’s picture

It seems that something has changed to fix the bug that we saw in #18. I think the concern in #15 has been addressed.

hussainweb’s picture

Issue summary: View changes

Adding the beta evaluation. I don't think there is anything else left here except review.

joelpittet’s picture

Status: Needs review » Needs work

I tried this with testing UI page, which is still not showing the title.

hussainweb’s picture

Status: Needs work » Needs review
StatusFileSize
new2.34 KB

@joelpittet: Can you describe how you tested this? I tested this by canceling few users and checking for title, and the title was there (as seen in attached). This was not present when run without patch.

Can you give a link to testing ui page so that I can check it there too?

joelpittet’s picture

The patch does fix that page, so nice work!

I think my issue is an older and different one but there was a title above and below the progress bar that used to update. Right now the below description is showing but the title above doesn't show up anymore.

I was just running any test. Enable testing module (simpletest) and http://d8.dev/admin/config/development/testing
and enable any test to run.

I was hoping this issue would fix that too.

hussainweb’s picture

StatusFileSize
new2.22 KB

I see it there too. This was run on simplytest.me but I don't think that should make any difference.

RavindraSingh’s picture

StatusFileSize
new17.23 KB

Applied the patch #32 still no luck .

Followed these steps to test before and after applying patch:
The problem seems to be in Drupal core. I was able to reproduce this for Cancel User batch operation. To reproduce:
* Create a test user.
* Go to People listing page, select the checkbox for the test user and in 'With selection' dropdown, select 'Cancel the selected user account(s)'.
* This step may not matter but just in case, select 'Delete the account and its content.' on the next page and 'Cancel accounts'.
* Observe on the next page with the scrollbar that there is no title, even though the code sets it to t('Cancelling account').

Apply the patch and repeat the steps above. The title still not appears
Attached is the screenshot

Title on batch processing

RavindraSingh’s picture

Status: Needs review » Needs work

Please try on fresh installation of 8.0.x

hussainweb’s picture

Status: Needs work » Needs review

Apply the patch and repeat the steps above. The title now appears
Attached is the screenshot

This means it works, right? I don't understand why you marked it as Needs work. Am I missing something?

RavindraSingh’s picture

Applied the patch but its not working as you have mentioned. Maybe I missed something. Lets wait community response if this works perfactly.

hussainweb’s picture

@RavindraSingh: I am not sure if I follow. You said and took screenshot that the title does not appear on batch page. After applying the patch, the title appears (like you confirmed in #39). That is what is supposed to happen with the patch. That is the bug we are fixing here.

RavindraSingh’s picture

Uff, updated the line. seems I did some mistake in writing. As attached screenshot on #39 doesn't show the title with counts.

jhedstrom’s picture

@hussainweb could you attach the test as a separate patch to illustrate the current breakage? Also, if folks aren't seeing the fix in manual testing, I wonder if the new test is testing the proper behavior?

joelpittet’s picture

@jhedstrom I did see the fix in manual testing of the user delete batch. I've got a different issue that I should file once I can confirm it wasn't changed on purpose for the batch in the simple test UI.

hussainweb’s picture

StatusFileSize
new5.17 KB
new4.05 KB

@jhedstrom: I am attaching the same patch as #32 and the tests only version of the patch. This should be very similar to the tests only patch in #12 as the tests haven't really changed.

#44, I didn't realize you meant that the title still didn't appear. I tested the exact same thing on simplytest.me and it worked as expected. See the screenshots below for two different batch pages (one of which is the delete user page). I too had selected 'Delete the account and it's content' option.

@joelpittet, do you mean to say you still don't see the title on any of the batch pages? I thought the above screenshot was what you wanted.

joelpittet’s picture

@hussainweb different title, it used to live in between the breadcrumbs and the progress bar and it was bold and black title for the batch not the title of the page.

hussainweb’s picture

Oh, okay. It does sound like a different issue then. However, it might be related to this. What should the text be on the tests ui page, for instance? I can do a quick check.

Status: Needs review » Needs work

The last submitted patch, 47: title_not_shown_batch-2282035-47-tests-only.patch, failed testing.

hussainweb’s picture

As expected, the tests only patch failed with just the failure we were expecting.

hussainweb’s picture

Status: Needs work » Needs review

This should still be Needs review.

joelpittet’s picture

I can't find when it was introduced and or if it was reverted/broken though it's been a while...

I did find something to help me not look completely bonkers.

The Seven style guide has what it is/was supposed to look like.

https://groups.drupal.org/node/283223#Progress

Tried a couple alphas and betas but to no avail.

hussainweb’s picture

Good find! I will see if I can dig up something about that. It might be a follow up?

hussainweb’s picture

StatusFileSize
new2.79 KB

This is how it looks on Drupal 7.

Maybe the design shown in style guide is not implemented yet? That makes it a task and not a bug report (which this is). I think this means we need to work this one out in a followup issue.

joelpittet’s picture

Status: Needs review » Needs work

Couple of comment fixes here and I think this is good to ship. Thanks for working on this @hussainweb

Yeah my thing is unrelated to this issue, sorry for the divergence.

  1. +++ b/core/modules/system/src/Tests/Batch/PageTest.php
    @@ -47,4 +47,18 @@ function testBatchProgressPageTheme() {
    +    // Visit an administrative page that runs a test batch, and check that the
    +    // theme that was used during batch execution (which the batch callback
    +    // function saved as a variable) matches the theme used on the
    +    // administrative page.
    +    $this->drupalGet('batch-test/test-title');
    

    I think this comment is a duplicate/incorrect.

  2. +++ b/core/modules/system/tests/modules/batch_test/batch_test.module
    @@ -167,6 +167,21 @@ function _batch_test_theme_callback() {
    + * Tests the progress page theme by performing a batch callback.
    

    This isn't testing the 'theme' it's testing the 'title'?

joelpittet’s picture

Issue summary: View changes
hussainweb’s picture

Status: Needs work » Needs review
Issue tags: -Needs issue summary update
StatusFileSize
new1.97 KB
new5.16 KB

Fixing comments as per #56.

RavindraSingh’s picture

Status: Needs review » Reviewed & tested by the community

its working as expected. moving this to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed bce75ca and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed bce75ca on 8.0.x
    Issue #2282035 by hussainweb, RavindraSingh, joachim: Title not shown...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

eelkeblok’s picture

This issue seems to have returned (I can't actually remember ever having seen a title when enabling a module). See #2744663: Batch missing title on screen.