Cleanup of batches is never performed, add batch cleanup after execution of batch

Created on 20 September 2016, almost 9 years ago
Updated 16 January 2023, over 2 years ago

Problem/Motivation

For now, creating batches, using storage service, looks like \Drupal::service('batch.storage')->create($batch);. For instance, if batch defined as progressive, then it'll be created via the same construction inside of batch_process() function. Afterwards, when batch is finished and _batch_finished() executed, an entry will be deleted from storage by \Drupal::service('batch.storage')->delete($batch['id']);. Everything fine at the moment. My proposal is: take care about the storage and trigger the cleanup() method of the service inside of system_cron().

In addition to above, there could be a case when _batch_queue() function will try to construct wrong class. To resolve this, I propose to add an interface which will identify batch-related queues.

Proposed resolution

Add execution of \Drupal::service('batch.storage')->cleanup() to system_cron().

Remaining tasks

None.

User interface changes

None.

API changes

Add \Drupal\Core\Queue\BatchQueueInterface which must be implemented by every custom batch queue.

Data model changes

None.

✨ Feature request
Status

Needs review

Version

10.1 ✨

Component
Batch  →

Last updated 9 days ago

  • Maintained by
  • 🇬🇧United Kingdom @John Cook
Created by

🇺🇦Ukraine BR0kEN Dnipro

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024