Add configurable distribution modes for federation delivery#3044
Open
Add configurable distribution modes for federation delivery#3044
Conversation
Adds a "Distribution Mode" setting to the Advanced Settings page with four presets (Default, Balanced, Eco, Custom) that control batch size and pause between batches for federation delivery. Includes a constant override via ACTIVITYPUB_DISTRIBUTION_MODE in wp-config.php. Fixes #2672
There was a problem hiding this comment.
Pull request overview
Adds an admin-configurable “Distribution Mode” that controls federation delivery pacing via existing dispatcher/scheduler filters, with an optional wp-config.php constant override to enforce a mode and hide the UI.
Changes:
- Adds an Advanced Settings “Distribution Mode” radio field with presets and custom batch/pause inputs.
- Registers new options and wires delivery pacing into
activitypub_dispatcher_batch_sizeandactivitypub_scheduler_async_batch_pause. - Adds
ACTIVITYPUB_DISTRIBUTION_MODEconstant override and a changelog entry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| includes/wp-admin/class-advanced-settings-fields.php | Adds the Distribution Mode settings UI, including custom input toggling. |
| includes/constants.php | Defines ACTIVITYPUB_DISTRIBUTION_MODE for wp-config.php overrides. |
| includes/class-options.php | Registers new settings and applies distribution mode to existing delivery pacing filters. |
| .github/changelog/3044-from-description | Records the feature in the changelog. |
You can also share your feedback on Copilot code review. Take the survey.
- Fix inconsistent constant check: use `false ===` in both the UI visibility check and the option override - Validate ACTIVITYPUB_DISTRIBUTION_MODE constant against allowed modes, falling back to 'default' for invalid values - Centralize preset definitions in Options::get_distribution_modes() and reuse in both admin UI and parameter resolution - Add static cache in get_distribution_params() to avoid rebuilding presets on every filter call during delivery - Null-guard the custom fields DOM element in inline script
Use `use` statements at the top of files instead of inline fully-qualified class names like \Activitypub\Options::method().
- Prevent batch size of 0 with max(1, absint()) sanitization. - Default mode now passes through the incoming filter value so other plugins and constants are not silently overridden. - Remove static cache from get_distribution_params() since get_option() is already cached by WordPress and the static var caused stale values. - Add tests for presets, custom mode, sanitization, and filter behavior.
…stant - Cap custom batch size at 500 and pause at 3600s to prevent accidental server overload via misconfiguration. - Reject 'custom' as a valid ACTIVITYPUB_DISTRIBUTION_MODE constant value since its parameters are still DB-settable. - Add tests for upper bound enforcement.
Default 15s, Balanced 30s, Eco 30s — the differentiation between modes is now purely batch size (100/50/20). The previous 5min Eco pause caused unreasonably long delivery times.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2672
Proposed changes:
activitypub_dispatcher_batch_sizeandactivitypub_scheduler_async_batch_pausefilters so admins can tune federation delivery speed without code.ACTIVITYPUB_DISTRIBUTION_MODEconstant for wp-config.php override (hides the UI when set).Other information:
Testing instructions:
ACTIVITYPUB_DISTRIBUTION_MODEas'eco'in wp-config.php — verify the UI field is hidden and Eco mode values are used.Changelog entry
Changelog Entry Details
Significance
Type
Message
Add a Distribution Mode setting to control how quickly posts are delivered to followers.