Recurring Tasks¶
RecurringTasksMigrator runs a set of idempotent tasks on every deployment, unlike versioned migrations which run only once. It uses the same Migration interface but ignores version comparison — every task's install() is called unconditionally.
Built-in task: WCStatusCheckerTask¶
Barberklingen\BasePlugin\Migrations\RecurringTasks\WCStatusCheckerTask
Runs two checks on each deployment:
1. VARCHAR column size¶
Reads all registered WooCommerce order and subscription statuses, finds the longest value, and ensures both the wc_statuses.status column and the native wp_posts.post_status / wc_orders.status column are wide enough. If not, it runs an ALTER TABLE … MODIFY automatically.
This prevents silent truncation when custom statuses with long names are introduced.
2. Missing status rows¶
Compares registered statuses against the rows in wc_statuses and inserts any that are missing. This keeps the lookup table in sync when new statuses are added to WooCommerce or WooCommerce Subscriptions.
Registering your own recurring task¶
Use the base-plugin/recurring-tasks filter to append a Migration instance:
add_filter('base-plugin/recurring-tasks', function (array $tasks): array {
$tasks[] = new MyDeploymentTask();
return $tasks;
});
Your task class:
class MyDeploymentTask implements Migration {
public function install(): void {
// Idempotent work — runs on every deployment.
// Safe to run multiple times.
}
public function get_version(): string {
return ''; // Ignored by RecurringTasksMigrator
}
}
Tip
Because recurring tasks run on every deployment they must be idempotent — running them twice should produce the same result as running them once. Use INSERT IGNORE, existence checks, or similar guards.