Skip to content
Corex

SubmissionRetention

Corex\Config\Retention\SubmissionRetention · class · Config layer

Real submission retention (spec 065): stores the retention window, finds the submissions that are due under it, previews how many there are (a real dry-run), and applies the chosen action to them — only when asked, and, for the same marked-test choice, never to a record the preview did not count. It never acts without a caller-supplied confirmation (enforced at {@see RetentionController}) and never bypasses the trash (trashed records are recoverable). The loop is separated from the WordPress query so it stays unit-testable. “Move to trash” is the inbox’s trash, asked for through {@see SubmissionRetentionTrash}: the same access rules, the same history on each submission and one entry in the activity stream for the run (spec 105, US4). Nothing here trashes a submission itself. A submission is due while it is older than the window and still holds its personal data. Trashing takes it out of the stored set and anonymizing finishes it; archiving does neither, so an archived record stays due and can still be anonymized or trashed (DECISIONS #232).

__construct(RetentionSettings $settings, SubmissionRetentionStore $reader, SubmissionRetentionTrash $trash)

Section titled “__construct(RetentionSettings $settings, SubmissionRetentionStore $reader, SubmissionRetentionTrash $trash)”

The dry-run preview for the current window: how many stored submissions are due right now, before an action is chosen. With the same $includeTest, every action acts on these or on a subset of them. Real count, never fabricated, and bounded by one run’s size.

prune(SubmissionAccessScope $scope, string $action, bool $includeTest): int

Section titled “prune(SubmissionAccessScope $scope, string $action, bool $includeTest): int”

Apply the action to the due submissions it still has something to do for, oldest first. Returns the number handled. The caller MUST have verified capability + nonce + confirmation before calling this.

applyIds(SubmissionAccessScope $scope, string $action, array $ids): int

Section titled “applyIds(SubmissionAccessScope $scope, string $action, array $ids): int”

Apply the action to the given submission ids; returns how many it was applied to. Separated from the query so the loop is unit-testable with a stub reader. The trash is asked once for the whole run, as the person running it: it records a run, and a call for each submission would record one each.