Skip to content

Conversation

@pfefferle
Copy link
Member

Proposed changes:

  • 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()

Problem

When migration calls add_to_outbox() (e.g., for Move activities in #2766), the post_activitypub_add_to_outbox action fires but the scheduler hooks (schedule_outbox_activity_for_federation, schedule_announce_activity) aren't registered yet because:

  • Migration::init() runs at init priority 1
  • Scheduler::init() runs at init priority 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:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Fix migration activities not being scheduled for federation due to hook registration timing.

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.
Copilot AI review requested due to automatic review settings January 15, 2026 10:45
@pfefferle pfefferle self-assigned this Jan 15, 2026
@pfefferle pfefferle requested a review from a team January 15, 2026 10:45
Copy link

Copilot AI left a 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.
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 ) {
Copy link
Member

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?

Copy link
Member Author

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!

@pfefferle pfefferle merged commit 8e598b7 into trunk Jan 16, 2026
10 checks passed
@pfefferle pfefferle deleted the fix/scheduler-init-priority branch January 16, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants