Skip to main content

benecaster_feed_request_log_hard_cap_enforced

Action Free

Fires whenever the emergency-purge guardrail deletes the oldest feed-request records. The guardrail is the first step of the nightly purge at 02:30: if the raw log has grown past its hard row cap — five million by default — it deletes oldest-first until the log is back to 80% of the cap, then raises a warning-level admin notice.

This firing means retention is not keeping up. The guardrail is a backstop against a log that would otherwise fill the disk, not a routine tidy-up, so treat it as an alert rather than housekeeping. Route it to whatever you already watch — PagerDuty, Sentry, Slack — and when it arrives, revisit the retention window or the cap itself at Settings → Tools → Feed request log.

Note the data is already gone by the time your callback runs. If those records matter to you, the fix is a shorter retention window feeding an external store, not a listener here.

Parameters

Name Type Default Description
$event array — Guardrail event. Keys: `previous_count` (int — row count before trimming), `cap` (int — the configured hard cap), `target` (int — 80% of cap, the row count after trimming), `deleted` (int — number of rows removed)

Examples

Route the guardrail firing to PagerDuty

add_action( 'benecaster_feed_request_log_hard_cap_enforced', function ( array $event ): void {
    wp_remote_post( MY_PAGERDUTY_ENDPOINT, [
        'body' => wp_json_encode( [
            'routing_key'  => MY_PAGERDUTY_KEY,
            'event_action' => 'trigger',
            'payload'      => [
                'summary'  => sprintf(
                    'Benecaster feed log hit hard cap — deleted %d rows (was %d, target %d)',
                    $event['deleted'],
                    $event['previous_count'],
                    $event['target']
                ),
                'severity' => 'warning',
                'source'   => home_url(),
            ],
        ] ),
    ] );
} );

Notes

An admin notice is published automatically when the guardrail fires; this action is for external routing only. The notice re-surfaces every 7 days while the log remains above the cap (controlled by re_dismiss_after on the NoticeManager::publish() call).

Need this built rather than just documented? See our services →