Skip to content

Stop loading Action Scheduler and turn off Stream's auto-purge - #489

Merged
mikelittle merged 3 commits into
masterfrom
disable-stream-purge-action-scheduler
Oct 9, 2026
Merged

mikelittle merged 3 commits into
masterfrom
disable-stream-purge-action-scheduler

Conversation

@mikelittle

@mikelittle mikelittle commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Since 4.2.0, Stream purges old records through Action Scheduler, which we avoid because it interferes with Cavalcade. We keep records indefinitely in a write-only log, so the purge can never delete anything and only adds a recurring job.

Stream 4.3.0 added wp_stream_enable_auto_purge and wp_stream_use_action_scheduler for this case. Both are now set to false before Stream loads. Stream clears any purge job that earlier versions scheduled, and no longer loads Action Scheduler, so the manual setup, the queue-runner cron removal and the Scheduled Actions menu removal are deleted.

Effect on sites: the extra.altis.modules.security.disable-action-scheduler-cron setting no longer does anything and is documented as safe to remove. Plugins that bundle their own Action Scheduler, such as WooCommerce, now run normally, where the old workaround suppressed their queue runner.

Part of humanmade/product-dev#2078.

🤖 Generated with Claude Code

Audit log records are kept indefinitely in a write-only log, so Stream's purge job can never delete anything. Disable it and tell Stream to use WP-Cron (Cavalcade) rather than Action Scheduler, which makes our manual Action Scheduler setup and the disable-action-scheduler-cron option unnecessary.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@wisyhambolu wisyhambolu left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine mostly but It would be good to deal with the leftover action_scheduler_run_queue event before merging. The rest are nits.

Comment thread inc/stream/namespace.php
// delete. Stop it being scheduled and use WP-Cron (Cavalcade) rather than Action Scheduler.
// Stream reads these filters when its plugin file loads, so they must be added first.
add_filter( 'wp_stream_enable_auto_purge', '__return_false' );
add_filter( 'wp_stream_use_action_scheduler', '__return_false' );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sites that set disable-action-scheduler-cron: false will have Action Scheduler’s action_scheduler_run_queue event scheduled every minute. Action Scheduler is no longer loaded, so nothing will ever remove that event, and Cavalcade will keep running a job with no handler every minute.

Could we clear it once, only when no other plugin provides Action Scheduler? The class_exists check means a site running WooCommerce keeps its own queue runner.

add_action( 'init', function () {
	if ( class_exists( 'ActionScheduler', false ) || get_option( 'altis_stream_as_cleanup' ) ) {
		return;
	}
	wp_unschedule_hook( 'action_scheduler_run_queue' );
	update_option( 'altis_stream_as_cleanup', 1 );
} );

If we’d rather not ship cleanup code, an upgrade note with wp cron event delete action_scheduler_run_queue would also work.

Related, and lower impact: the description says Stream clears purge jobs that earlier versions scheduled. That’s true for WP-Cron. For jobs stored in Action Scheduler’s tables, Stream only clears them when Action Scheduler’s functions are loaded (class-admin.php#L1104). Since we no longer load it, those rows stay in the actionscheduler_* tables. That’s harmless, because nothing runs them and the purge is blocked when it runs anyway. It might just be worth softening that line in the description.

@mikelittle mikelittle Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason someone might set disable-action-scheduler-cron: false is that they do want Actions Scheduler to run for another plugin. For example, WooCommerce. We only care to turn it off for Stream. If another plugin needs it, it will install its own copy and use that. That setting was to stop Altis from breaking that other plugin. Now we no longer interfere with other plugins' use of AS.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the comment above to make it clearer we are disabling the loading of Action scheduler only. The fact we disable auto purge means WP Cron won't get used either, but we don't need to say that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. Any site that set that flag has its own Action Scheduler handling the event, so it won’t be orphaned. Happy to drop this.

Comment thread inc/stream/namespace.php
}
// Records are kept indefinitely in a write-only log, so Stream's purge job has nothing to
// delete. Stop it being scheduled and use WP-Cron (Cavalcade) rather than Action Scheduler.
// Stream reads these filters when its plugin file loads, so they must be added first.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this is only true of wp_stream_use_action_scheduler. wp_stream_enable_auto_purge is read later, on wp_loaded (class-admin.php#L273) and when the purge runs. Maybe:

	// `wp_stream_use_action_scheduler` is read when Stream's plugin file loads, so these must be added before the require.

Comment thread docs/audit-log.md Outdated
```
The Audit Log plugin (Stream) can use [Action Scheduler](https://actionscheduler.org/) for deferred work, but Altis does not load it. Audit Log records are kept indefinitely, so Altis turns off Stream's automatic purge, and Stream uses WP-Cron for any deferred work instead.

Other plugins can continue to use Action Scheduler if they need it, such as WooCommerce, which loads its own copy. Altis does not interfere with them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this changes behaviour for sites running WooCommerce or another plugin that bundles Action Scheduler. Their queue runner and the Tools → Scheduled Actions menu now work, where we used to suppress them. That’s the right outcome, it would be good if we could add it to the release notes or changelog, so it doesn’t surprise anyone?

@mikelittle mikelittle Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what the disable-action-scheduler-cron: false was for. If our previous default behaviour broke things for another site's plugins, they will have needed to set that setting to stop us breaking things. Now we don't turn it off. So they no longer need the setting.

@mikelittle
mikelittle requested a review from wisyhambolu October 9, 2026 16:38

@wisyhambolu wisyhambolu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@mikelittle
mikelittle merged commit 7231351 into master Oct 9, 2026
2 of 3 checks passed
@mikelittle
mikelittle deleted the disable-stream-purge-action-scheduler branch October 9, 2026 17:23
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Successfully created backport PR for v25-branch:

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Successfully created backport PR for v26-branch:

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Successfully created backport PR for v27-branch:

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Successfully created backport PR for v28-branch:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants