Skip to content

Fix: Invalidate retries with the invalidation of an Outbox Item #1519

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

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/changelog/1519-from-description
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Properly remove retries schedules, with the invalidation of an Outbox-Item.
18 changes: 18 additions & 0 deletions includes/collection/class-outbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,24 @@ private static function invalidate_existing_items( $object_id, $activity_type, $
$timestamp = \wp_next_scheduled( 'activitypub_process_outbox', array( $existing_item_id ) );
\wp_unschedule_event( $timestamp, 'activitypub_process_outbox', array( $existing_item_id ) );

// Invalidate any retries for this outbox item.
$crons = _get_cron_array();
foreach ( $crons as $timestamp => $cron ) {
if ( ! isset( $cron['activitypub_async_batch'] ) ) {
continue;
}
foreach ( $cron['activitypub_async_batch'] as $event ) {
if (
isset( $event['args'][0][1] ) &&
'retry_send_to_followers' === $event['args'][0][1] &&
isset( $event['args'][2] ) &&
$existing_item_id === $event['args'][2]
) {
\wp_unschedule_event( $timestamp, 'activitypub_async_batch', $event['args'] );
}
}
}

\wp_publish_post( $existing_item_id );
\delete_post_meta( $existing_item_id, '_activitypub_outbox_offset' );
}
Expand Down
Loading