Skip to content

Commit 681aa0c

Browse files
committed
Register Dispatcher callbacks
Moves async batch callback registration for activity sending and retrying from Scheduler's static property to Dispatcher initialization. Updates _doing_it_wrong message version to 'unreleased' for clarity.
1 parent 69bcfb7 commit 681aa0c

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

includes/class-dispatcher.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public static function init() {
4545
\add_filter( 'activitypub_additional_inboxes', array( self::class, 'add_inboxes_by_mentioned_actors' ), 10, 3 );
4646
\add_filter( 'activitypub_additional_inboxes', array( self::class, 'add_inboxes_of_replied_urls' ), 10, 3 );
4747
\add_filter( 'activitypub_additional_inboxes', array( self::class, 'add_inboxes_of_relays' ), 10, 3 );
48+
49+
Scheduler::register_async_batch_callback( 'activitypub_send_activity', array( self::class, 'send_to_followers' ) );
50+
Scheduler::register_async_batch_callback( 'activitypub_retry_activity', array( self::class, 'retry_send_to_followers' ) );
4851
}
4952

5053
/**

includes/class-scheduler.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ class Scheduler {
2727
*
2828
* @var array
2929
*/
30-
private static $batch_callbacks = array(
31-
'activitypub_send_activity' => array( Dispatcher::class, 'send_to_followers' ),
32-
'activitypub_retry_activity' => array( Dispatcher::class, 'retry_send_to_followers' ),
33-
);
30+
private static $batch_callbacks = array();
3431

3532
/**
3633
* Initialize the class, registering WordPress hooks.
@@ -44,8 +41,6 @@ public static function init() {
4441

4542
// Event callbacks.
4643
\add_action( 'activitypub_async_batch', array( self::class, 'async_batch' ), 10, 99 );
47-
\add_action( 'activitypub_send_activity', array( self::class, 'async_batch' ), 10, 3 );
48-
\add_action( 'activitypub_retry_activity', array( self::class, 'async_batch' ), 10, 3 );
4944
\add_action( 'activitypub_reprocess_outbox', array( self::class, 'reprocess_outbox' ) );
5045
\add_action( 'activitypub_outbox_purge', array( self::class, 'purge_outbox' ) );
5146

@@ -79,7 +74,7 @@ public static function register_schedulers() {
7974
*/
8075
public static function register_async_batch_callback( $hook, $callback ) {
8176
if ( \did_action( 'init' ) && ! \doing_action( 'init' ) ) {
82-
\_doing_it_wrong( __METHOD__, 'Async batch callbacks should be registered before or during the init action.', '5.2.0' );
77+
\_doing_it_wrong( __METHOD__, 'Async batch callbacks should be registered before or during the init action.', 'unreleased' );
8378
return;
8479
}
8580

0 commit comments

Comments
 (0)