Theme issue during Batch Process

Created on 29 June 2021, over 3 years ago
Updated 18 September 2024, 2 months ago

Problem/Motivation

Once we start the batch process to perform some action on contents. On batch progress bar page, it doesn't use current active theme for end user.
As a final result, the page design is break for users excluding admin.

Steps to reproduce

  1. Create a content listing view and integrate a view bulk operation.
  2. Set the view bulk operation configuration as shown in screenshot [Screenshot from 2021-06-29 11-04-14].
  3. Select any bulk operation.
  4. Save the View.
🐛 Bug report
Status

Fixed

Version

4.2

Component

Theming

Created by

🇮🇳India DimpleL

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇯🇴Jordan n.ghunaim Amman - Jordan

    I'm still facing this issue even when upgrading the core module to 9.5.9

  • 🇯🇴Jordan n.ghunaim Amman - Jordan

    I have applied a change to make views_bulk_operations.execute_batch routing use the admin theme, this fixes the theming issue for the bulk operations module.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    11 pass
  • Status changed to Needs review over 1 year ago
  • 🇯🇴Jordan n.ghunaim Amman - Jordan
  • Status changed to RTBC over 1 year ago
  • 🇯🇴Jordan Qusai Taha Amman

    Patch #4 working with me
    Thank you!

  • Status changed to Needs work over 1 year ago
  • 🇵🇱Poland Graber

    And what if the view having a VBO field is not on admin pages and uses the default theme instead of the admin theme?

  • 🇯🇴Jordan Rajab Natshah Jordan

    I agree with Marcin on #7
    I was sat to add the patch to our product.
    But had the same questions.

    Solution #1: Maybe VBO Edit, VBO Export, or other extending VBO solutions could have switcher for that

    Solution #1: A plugin switch checkbox in the advanced view settings, or custom cloned views could manage to change and pass the ( Default theme, or Admin theme ) to the Batch Theme Negotiator

            if (batch_theme_view_settings == 'admin') {
              return $this->configFactory->get('system.theme')->get('admin');
            }
            else {
              return $this->configFactory->get('system.theme')->get('default');
            }
    

    Maybe views already can do this with a bit of hook alters.

    I feel that this could be in Drupal core, or a contrib module to select the theme for the batch job under Advanced view settings next to Use AJAX for example.

  • Status changed to Needs review over 1 year ago
  • 🇳🇿New Zealand ericgsmith

    Adding related issue.

    Reading the issue #2911751 _admin_route: TRUE was added to views_bulk_operations.confirm and views_bulk_operations.execute_configurable on the assumption that if the user has access to the admin theme then it was fine then to use that for the configuration form.

    I think that is the same concern here - but because _admin_route: TRUE was not applied to the batch route - if you are not using a configurable plugin or a confirmation screen then you do not get the admin theme and you receive an inconsistent experience.

    So to answer:

    And what if the view having a VBO field is not on admin pages and uses the default theme instead of the admin theme?

    #4 would result in the same current behavior for the confirm and configuration forms - these would render as the admin theme if the user has permissions to see it.

    Also, what about other controllers like the confirmation and configuration form for actions that require those?

    When using confirmation option - The processor is executed in the submit handler for the ConfirmAction form so when batch_process is called the current route is views_bulk_operations.confirm which has _admin_route: TRUE so the batch uses the admin theme if you have permissions to use it.

    When using action with configuration - The processor is executed in the submit handler for the ConfigureAction form so when batch_process is called by the plugin the current route is views_bulk_operations.execute_configurable which has _admin_route: TRUE so the batch uses the admin theme if you have permissions to use it.

    When using action with no configuration or confirmation - ViewsBulkOperationsBulkForm does not execute the plugin, but redirects to views_bulk_operations.execute_batch so when batch_process is called by the plugin the current route is views_bulk_operations.execute_batch which does not have _admin_route: TRUE so the batch uses the default theme.

    Based on that - I would say the patch from #4 does the minimum to keep it consistent - but could introduce edge case regressions where a user with access to the admin theme may expect the batch to run in the front end. In this case, they would already be seeing the admin theme if the action had a configuration or confirmation form.

    Alternatively, in ViewsBulkOperationsBulkForm - could this be refactored so that it keeps the existing redirect behavior for configuration and confirm options - but calls execute directly on the plugin and redirects to the batch here rather than delegating this behavior to the views_bulk_operations.execute_batch route? I haven't really taken a close look at this route / controller to see if there is anything prohibiting this. That also might not be relevant as while it could solve an edge case, it would still be inconsistent since those 2 routes current using admin wouldn't take the current view into account anyway.

    That all said - I think #4 keeps things consistent and works for my use case so would be RTBC for me - but setting to needs review to clarify if its still needs work based on #7. Thanks @n.ghunaim !

  • 🇭🇺Hungary balazswmann

    Thanks for the patch in #4, it works.

  • Status changed to RTBC 4 months ago
  • 🇳🇿New Zealand ericgsmith

    Setting to RTBC - note I have previously tried to answer the comment #7 in comment #9.

    • graber committed 46214f57 on 4.2.x
      Issue #3221195 by n.ghunaim, dimplel, ericgsmith, qusai taha, rajab...
  • Status changed to Fixed 2 months ago
  • 🇵🇱Poland Graber

    Ok, let's have it. We'll see if we don't have other issues reported.

    • graber committed 46214f57 on 4.3.x
      Issue #3221195 by n.ghunaim, dimplel, ericgsmith, qusai taha, rajab...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024