Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
- Create a content listing view and integrate a view bulk operation.
- Set the view bulk operation configuration as shown in screenshot [Screenshot from 2021-06-29 11-04-14].
- Select any bulk operation.
- Save the View.
Comment | File | Size | Author |
---|---|---|---|
#4 | 3221195_4.patch | 512 bytes | n.ghunaim |
Screenshot from 2021 06 29 11 01 42.png | 12.17 KB | DimpleL | |
Screenshot from 2021 06 29 11 04 14.png | 51.04 KB | DimpleL |
Comments
Comment #2
Graber CreditAttribution: Graber as a volunteer commentedIt's not dependant on VBO, it's the Drupal core batch processing page that has its own URL.
See this core issue: #539022: Batch API should use the current theme to run the batches
Comment #3
n.ghunaim CreditAttribution: n.ghunaim at Vardot for Vardot commentedI'm still facing this issue even when upgrading the core module to 9.5.9
Comment #4
n.ghunaim CreditAttribution: n.ghunaim at Vardot for Vardot commentedI have applied a change to make views_bulk_operations.execute_batch routing use the _admin_route, this fixes the theming issue for the bulk operations module.
Comment #5
n.ghunaim CreditAttribution: n.ghunaim at Vardot for Vardot commentedComment #6
Qusai Taha CreditAttribution: Qusai Taha at Vardot commentedPatch #4 working with me
Thank you!
Comment #7
Graber CreditAttribution: Graber as a volunteer commentedAnd what if the view having a VBO field is not on admin pages and uses the default theme instead of the admin theme?
Also, what about other controllers like the confirmation and configuration form for actions that require those?
Comment #8
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedI 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. ( big work and hard coded fix - I'm not with that )
Solution #2: 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
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.
Comment #9
ericgsmith CreditAttribution: ericgsmith at Catalyst IT commentedAdding related issue.
Reading the issue #2911751
_admin_route: TRUE
was added toviews_bulk_operations.confirm
andviews_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 expressed in #7 - but at this point its a fairly established assumption. 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:
#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.
When using confirmation option - The processor is executed in the submit handler for the
ConfirmAction
form so whenbatch_process
is called the current route isviews_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 whenbatch_process
is called by the plugin the current route isviews_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 whenbatch_process
is called by the plugin the current route isviews_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, doesn't over complicate things 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 !
Comment #10
balazswmann CreditAttribution: balazswmann commentedThanks for the patch in #4, it works.