Loading
feat: #3636922 Create archive jobs from active schedules
Closes https://www.drupal.org/project/earkiv/issues/3636922
What it does
ScheduleRunner(serviceearkiv.schedule_runner):createDueJobs()loads the active schedules and, when an occurrence of the rule has passed since the schedule was last checked, creates a job with the default archiver and storage settings, owned by the owner of the schedule, and links it to the schedule. At most one job is created per check, also if several occurrences have passed, and none while a job of the schedule is new, running or waiting to be resumed. The time of the last check is kept in the State API; inactive and deleted schedules are forgotten, so a schedule that is activated again starts from that time.earkiv:processcallscreateDueJobs()while it holds the processing lock, before it processes the next job, so two processes cannot create the same job.Schedule::getRule()uses the creation time of the schedule asDTSTART, in the time zone of the site, when the rule has none.getNextOccurrence()andisActive()are added.- Schedule list: new columns "Next job" and "Latest job" (ID and status); the rule is described from the creation time.
- Links: deleting a schedule or an archive removes their links in
earkiv_schedules_archives; the archives are kept. - README: a "Schedules" section, including that parts left out of the rule are taken from the start time (so
BYMINUTEandBYSECONDshould be set) and that cron decides how close to the scheduled time a job starts.
Testing
createDueJobs() was called directly, since earkiv:process would have run the jobs against the default URL:
- A schedule created three days ago with
FREQ=DAILY;BYHOUR=10;BYMINUTE=0;BYSECOND=0created a job. A new schedule, an inactive one and one with an invalid rule did not; the invalid one logged a warning. - A second call right after created no job.
- With the last check set back three days and the job still New, the schedule was skipped.
- With that job Done, the next call created a new job.
The schedule list showed e.g. "weekly on Sunday at 2h …, starting from …" | 2026-11-15 02:00 | "67: Done". Deleting a schedule removed its link and kept the archive; deleting an archive removed its link.
phpcs (Drupal, DrupalPractice) reports one new warning, "Unused use statement" for ArchiveStatusEnum in ScheduleListBuilder, which is used in getLatestJob().
AI-Generated: Yes (Used Claude Code to write the feature, test it and write this merge request.)