-
Notifications
You must be signed in to change notification settings - Fork 83
Initialize Scheduler before Migration to ensure hooks are registered #2771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| * @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 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the delay necessary even after the priority switch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea tbh! This is so hard to debug!
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.