The batch API should be a pluggable service so it could be swapped out or mocked for testing.

The following will need to be completed:

#1797526: Make batch a wrapper around the queue system

Done:

Issue fork drupal-2875151

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

John Cook created an issue. See original summary.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

John Cook’s picture

The patch listed here builds on the work done in #2401797: Introduce a batch builder class to make the batch API easier to use, and as such will need the code from that issue's patch to be applied first until it is committed.

I've added an interface for the BatchQueueController to implement and added it to the core.services.yml file as batch.processor.

Also, I've changed the function calls in batch.inc and form.inc to use the new service. We would still need to deprecate the existing functions in favour of the service, but I think we should do that in a different issue.

I'm leaving the issue as "active" until #2401797 is committed.

John Cook’s picture

Dear Committer,

Please ensure that the following people are credited:

  • dawehner
  • kim.pepper
  • pguillard
  • Nitesh Sethia

They worked on #2320469: Move batch processing to a service, which is a duplicate of this issue and #2401797: Introduce a batch builder class to make the batch API easier to use. I used code from their work to provide the initial patch for this issue.

For reference the commit message is:

Issue #2320469 by dawehner, kim.pepper, pguillard, Nitesh Sethia: Move batch processing to a service

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

John Cook’s picture

John Cook’s picture

I've updated the summary and turned this issue into a plan as implementing batch processing as a service will be split into many tasks.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

colan’s picture

Status: Active » Needs review

I'm leaving the issue as "active" until #2401797: Introduce a batch builder class to make the batch API easier to use is committed.

Looks like that's in now.

Status: Needs review » Needs work

The last submitted patch, 3: Implement_batch_service-2875151-3.patch, failed testing. View results

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

nickolaj’s picture

Issue tags: +#dckyiv2019
alex_optim’s picture

Issue tags: -#dckyiv2019 +dckyiv2019
nickolaj’s picture

Assigned: Unassigned » nickolaj
sarathkm’s picture

This module in sandbox works fine. May be implementing this module fundamentals as base in core will be great starting point.

https://www.drupal.org/sandbox/acrosman/3025562

daffie’s picture

Assigned: nickolaj » Unassigned
Issue tags: +Needs reroll
jibran’s picture

Issue tags: +Kill includes
geek-merlin’s picture

voleger’s picture

Title: Implement batch api as a service » [META] Implement Batch API as a service
Issue summary: View changes

This looks more like a meta issue. And also great plan how to deprecate a bunch oh functions from includes files (#2999721: [META] Deprecate the legacy include files before Drupal 9). Updated IS.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

sokru’s picture

Issue tags: -Needs reroll

Removed "Needs reroll" tag, because most of the code is changes to non-existing file core/lib/Drupal/Core/Batch/BatchQueueController.php.

daffie’s picture

Issue tags: +Needs reroll

@sokru: The patch does not apply any more, therefore the patch needs to be rerolled.

eelkeblok’s picture

Since this is a Plan, does it even make sense to have a patch? I think it is a great idea, although how to implement this would need some careful consideration.

@geek-merlin, as you imply, there is a considerable amount of overlap with #1797526: Make batch a wrapper around the queue system, although the core aspect of that ticket (make batches a wrapper around the queue system) has since actually been implemented, leaving #1797526: Make batch a wrapper around the queue system a rebel without a cause, basically. I do believe there are some good ideas in there to improve the batch system in general. Probably those ideas (without going through the issue again, I can only come up with the one Chx implemented, although there may be more) should be outlined here to get a complete overview.

One aspect of redesigning the batch system I have been struggling with is this. Various core systems make use of the batch system. When a new batch system is introduced, the old batch API would be deprecated and at some point those mechanisms (the one that has been central to my thoughts about this is user cancellation) would have to be converted to the new system. However, at least the user cancellation API relies on how the current batch system works; it is possible to add to the batch built by the user cancellation system when hook_user_cancel is called by making use of the current Batch API. So, when user cancellation would start making use of an entirely new Batch API, that would be a BC-breaking change. That would mean that the new system can't really be that radically different from what it is now; it would need to essentially be a different wrapper around the same mechanics to allow the old Batch API to still work with any batches created with the new API. Is there any prior art for this sort of situation? Do we need to first abstract away such dependencies before we can make work of the batch API?

firewaller’s picture

+1

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Bhanu951 made their first commit to this issue’s fork.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.