alleyinteractive / alleyinteractive/wp-bulk-task

Provide a safe way to halt the bulk task

Open
#42 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
PHP
Stars
21
Forks
1
PR merge metrics
No merged PRs in 30d

Description

### Description

Currently, once a bulk task is started, it runs through the entire database, invoking the callable for each item. I would like to be able to halt the bulk task in such a way that I can resume it later at the same location in the database.

While it's technically possible today to halt the task by throwing an exception or exiting the script entirely, these methods will leave the cursor at whatever position it was last saved at, and they won't cause after-script logic to run, which isn't optimal.

### Use Case

We wrote a bulk task for a client recently that deleted items from the database. The client wanted to asked us to structure the script so that rather than deleting all eligible items at once, it would stop after deleting a given number of items, and they would review the effects of the deletions on their SEO and other concerns before moving on to delete the next batch. We accomplished this by having the callable return early once the number of deletions had occurred, but we had to let the rest of the bulk task run unnecessarily and then start the bulk task from the beginning next time.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.