Initialize Scheduler before Migration to ensure hooks are registered#2771
Merged
Initialize Scheduler before Migration to ensure hooks are registered#2771
Conversation
Changed Scheduler::init() priority from 10 (default) to 0, so it runs before Migration::init() (priority 1). This ensures that the post_activitypub_add_to_outbox hooks are registered before any migration code calls add_to_outbox(), allowing activities to be properly scheduled for federation.
There was a problem hiding this comment.
Pull request overview
This PR fixes a timing issue where activities added to the outbox during database migrations were not being scheduled for federation. The solution adjusts the initialization priority of the Scheduler to ensure its hooks are registered before Migration runs.
Changes:
- Modified
Scheduler::init()priority from default (10) to 0 - Ensures scheduler hooks are registered before
Migration::init()(priority 1) executes
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| activitypub.php | Changed Scheduler initialization priority to 0 to run before migrations |
| .github/changelog/2771-from-description | Added changelog entry documenting the bug fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updated the schedule_outbox_activity_for_federation method to use a default offset of 5 seconds instead of 0. This change ensures outbox items are scheduled with a slight delay by default.
Updated the default offset parameter in schedule_outbox_activity_for_federation from 5 seconds to 3 seconds to adjust the scheduling timing for outbox items.
jeherve
reviewed
Jan 15, 2026
Comment on lines
+277
to
+279
| * @param int $offset The offset to add to the scheduled time. Default 3 seconds. | ||
| */ | ||
| public static function schedule_outbox_activity_for_federation( $id, $offset = 0 ) { | ||
| public static function schedule_outbox_activity_for_federation( $id, $offset = 3 ) { |
Member
There was a problem hiding this comment.
Is the delay necessary even after the priority switch?
Member
Author
There was a problem hiding this comment.
I have no idea tbh! This is so hard to debug!
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.
Proposed changes:
Scheduler::init()priority from 10 (default) to 0, so it runs beforeMigration::init()(priority 1)post_activitypub_add_to_outboxhooks are registered before any migration code callsadd_to_outbox()Problem
When migration calls
add_to_outbox()(e.g., for Move activities in #2766), thepost_activitypub_add_to_outboxaction fires but the scheduler hooks (schedule_outbox_activity_for_federation,schedule_announce_activity) aren't registered yet because:Migration::init()runs atinitpriority 1Scheduler::init()runs atinitpriority 10 (default)This causes activities added during migration to go to the outbox but never get scheduled for federation.
Solution
Move
Scheduler::init()to priority 0 so all scheduler hooks are registered before migration runs.Other information:
Testing instructions:
add_to_outbox())activitypub_db_versionoptionactivitypub_process_outboxcron events)Changelog entry
Changelog Entry Details
Significance
Type
Message
Fix migration activities not being scheduled for federation due to hook registration timing.