From c263398baca88bbb16ad6150a38612493d1d0c2c Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 24 Feb 2026 18:11:59 +0100 Subject: [PATCH 1/2] Add backwards compatibility for ACTIVITYPUB_DISABLE_SIDELOADING The 7.9.1 release shipped `ACTIVITYPUB_DISABLE_SIDELOADING` constant and `activitypub_sideloading_enabled` filter. A subsequent refactor replaced these with a new caching system but dropped the old names. This restores backwards compatibility by mapping the old constant to the new `ACTIVITYPUB_DISABLE_REMOTE_CACHE` and deprecating the old filter via `apply_filters_deprecated()` pointing to `activitypub_remote_cache_enabled`. Also renames the unreleased `ACTIVITYPUB_DISABLE_MEDIA_CACHE` to `ACTIVITYPUB_DISABLE_REMOTE_CACHE` for unified naming with the filter. --- includes/class-cache.php | 17 ++++++++++++++++- includes/constants.php | 6 +++++- readme.txt | 1 + .../phpunit/tests/includes/class-test-cache.php | 11 +++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/includes/class-cache.php b/includes/class-cache.php index 4e81fac5e2..1bbaaeaadd 100644 --- a/includes/class-cache.php +++ b/includes/class-cache.php @@ -42,7 +42,22 @@ public static function init() { */ public static function is_enabled() { // Check constant first. - if ( ACTIVITYPUB_DISABLE_MEDIA_CACHE ) { + if ( ACTIVITYPUB_DISABLE_REMOTE_CACHE ) { + return false; + } + + /** + * Filters whether sideloading is enabled. + * + * This filter was introduced in 7.9.1 and replaced by + * {@see 'activitypub_remote_cache_enabled'} in a subsequent release. + * + * @since 7.9.1 + * @deprecated unreleased Use {@see 'activitypub_remote_cache_enabled'} instead. + * + * @param bool $enabled Whether sideloading is enabled. Default true. + */ + if ( ! \apply_filters_deprecated( 'activitypub_sideloading_enabled', array( true ), 'unreleased', 'activitypub_remote_cache_enabled' ) ) { return false; } diff --git a/includes/constants.php b/includes/constants.php index 5c251d3d99..7a40b895b6 100644 --- a/includes/constants.php +++ b/includes/constants.php @@ -20,7 +20,11 @@ defined( 'ACTIVITYPUB_DISABLE_OUTGOING_INTERACTIONS' ) || define( 'ACTIVITYPUB_DISABLE_OUTGOING_INTERACTIONS', false ); defined( 'ACTIVITYPUB_DEFAULT_OBJECT_TYPE' ) || define( 'ACTIVITYPUB_DEFAULT_OBJECT_TYPE', 'wordpress-post-format' ); defined( 'ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE' ) || define( 'ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE', 100 ); -defined( 'ACTIVITYPUB_DISABLE_MEDIA_CACHE' ) || define( 'ACTIVITYPUB_DISABLE_MEDIA_CACHE', false ); +// Backwards compatibility: map old ACTIVITYPUB_DISABLE_SIDELOADING to ACTIVITYPUB_DISABLE_REMOTE_CACHE. +if ( ! defined( 'ACTIVITYPUB_DISABLE_REMOTE_CACHE' ) && defined( 'ACTIVITYPUB_DISABLE_SIDELOADING' ) ) { + define( 'ACTIVITYPUB_DISABLE_REMOTE_CACHE', ACTIVITYPUB_DISABLE_SIDELOADING ); +} +defined( 'ACTIVITYPUB_DISABLE_REMOTE_CACHE' ) || define( 'ACTIVITYPUB_DISABLE_REMOTE_CACHE', false ); // The following constants are invariable and define values used throughout the plugin. diff --git a/readme.txt b/readme.txt index d814e222e8..eff8956945 100644 --- a/readme.txt +++ b/readme.txt @@ -89,6 +89,7 @@ The plugin uses PHP Constants to enable, disable or change its default behaviour * `ACTIVITYPUB_DISABLE_REWRITES` - Disable auto generation of `mod_rewrite` rules. Default: `false`. * `ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS` - Block incoming replies/comments/likes. Default: `false`. * `ACTIVITYPUB_DISABLE_OUTGOING_INTERACTIONS` - Disable outgoing replies/comments/likes. Default: `false`. +* `ACTIVITYPUB_DISABLE_REMOTE_CACHE` - Disable remote media caching (avatars, media, emoji). Default: `false`. Replaces `ACTIVITYPUB_DISABLE_SIDELOADING` from 7.9.1. * `ACTIVITYPUB_SHARED_INBOX_FEATURE` - Enable the shared inbox. Default: `false`. * `ACTIVITYPUB_SEND_VARY_HEADER` - Enable to send the `Vary: Accept` header. Default: `false`. diff --git a/tests/phpunit/tests/includes/class-test-cache.php b/tests/phpunit/tests/includes/class-test-cache.php index 77abd74cbc..c9fd278d14 100644 --- a/tests/phpunit/tests/includes/class-test-cache.php +++ b/tests/phpunit/tests/includes/class-test-cache.php @@ -36,6 +36,17 @@ public function test_is_enabled_filter() { $this->assertTrue( Cache::is_enabled() ); } + /** + * Test is_enabled respects deprecated sideloading filter. + */ + public function test_is_enabled_deprecated_sideloading_filter() { + $this->setExpectedDeprecated( 'activitypub_sideloading_enabled' ); + + add_filter( 'activitypub_sideloading_enabled', '__return_false' ); + $this->assertFalse( Cache::is_enabled() ); + remove_filter( 'activitypub_sideloading_enabled', '__return_false' ); + } + /** * Test init does not run when disabled. */ From ca29ed461981b0bfec2ba5b26107a7381a6f0414 Mon Sep 17 00:00:00 2001 From: Automattic Bot Date: Tue, 24 Feb 2026 19:12:50 +0200 Subject: [PATCH 2/2] Add changelog --- .github/changelog/2973-from-description | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/changelog/2973-from-description diff --git a/.github/changelog/2973-from-description b/.github/changelog/2973-from-description new file mode 100644 index 0000000000..d5f525f4e4 --- /dev/null +++ b/.github/changelog/2973-from-description @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Add backwards compatibility for the `ACTIVITYPUB_DISABLE_SIDELOADING` constant and `activitypub_sideloading_enabled` filter from version 7.9.1.