Batch API should use the current theme to run the batches

Created on 3 August 2009, over 15 years ago
Updated 16 August 2023, about 1 year ago

Problem/Motivation

This is when Garland is the site default, Seven is the admin theme, and I run a simpletest.

The Simpletest selection page is in Seven, the batch API page for progress bar is Garland, and the results page is Seven again. Just guessing, but I bet that's the case with all batch API, it uses the default or maintenance theme, not something to be blamed on simpletest.

Steps to reproduce

Proposed resolution

Remaining tasks

Determine if there is a problem with the theme and running cron manually. See #38 🐛 Batch API should use the current theme to run the batches Fixed .

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Fixed

Version

8.9 ⚰️

Component
Batch 

Last updated 9 days ago

Created by

🇺🇸United States deekayen Earth

Live updates comments and jobs are added and updated live.
  • API clean-up

    Refactors an existing API or subsystem for consistency, performance, modularization, flexibility, third-party integration, etc. May imply an API change. Frequently used during the Code Slush phase of the release cycle.

  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

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.

  • 🇭🇺Hungary mibfire

    There is an issue with "applies" method of BatchNegotiator class. This doesn't take the "system.batch_page.json" route into account. So for example while the default theme is used on the "system.batch_page.html" route the admin theme is used on "system.batch_page.json" route. Question is why "system.batch_page.json" route is not taken into account in the "applies" method? In my opinion this should be consistent through the whole batch process regardless of this is the batch page("system.batch_page.html") or the batch ajax calls("system.batch_page.json").

    Also the following is how the theme is set for the batch at the beginning.

    function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = NULL) {
      $batch =& batch_get();
    
      $activeThemeName = \Drupal::service('theme.manager')->getActiveTheme();
      $request = \Drupal::request();
    
      if (isset($batch)) {
        // Add process information
        $process_info = [
          'current_set' => 0,
          'progressive' => TRUE,
          'url' => $url ?? Url::fromRoute('system.batch_page.html'),
          'source_url' => Url::fromRouteMatch(\Drupal::routeMatch())->mergeOptions(['query' => \Drupal::request()->query->all()]),
          'batch_redirect' => $redirect,
          'theme' => \Drupal::theme()->getActiveTheme()->getName(),
          'redirect_callback' => $redirect_callback,
        ];
    

    =>

    " 'theme' => \Drupal::theme()->getActiveTheme()->getName(),"
    

    So this should apply to the ajax calls too.

    I created a patch for this issue.

  • 🇭🇺Hungary mibfire

    Pls repoen the issue.

  • 🇮🇹Italy trickfun

    In my case, batch page uses right theme but no menu is displayed.
    why no block is loaded?

    thank you

Production build 0.71.5 2024