Skip to content

Conversation

@pfefferle
Copy link
Member

@pfefferle pfefferle commented Dec 27, 2025

Fixes #

Proposed changes:

  • Fix old posts (>30 days) being federated when edited, even when "Do not federate" is shown as default in the editor
  • Use metadata_exists() to distinguish between "never set" (calculate age-based default) and "explicitly set to public" (respect user choice)
  • Update Classic Editor to only save visibility when it differs from the natural default, avoiding DB flooding with default values
  • Normalize 'public' to empty string in Classic Editor to match REST API behavior

Other information:

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

Testing instructions:

Scenario 1: Old post without explicit visibility

  1. Create a post dated >30 days ago (or manually set post_date in database)
  2. Edit the post without touching the visibility setting
  3. Save → post should NOT be federated (default is now "local" for old posts)

Scenario 2: Old post with explicit public visibility

  1. Create a post dated >30 days ago
  2. Edit the post and explicitly select "Public" visibility
  3. Save → post SHOULD be federated (user choice is respected)
  4. Edit again → visibility should still show "Public" (not reset to "local")

Scenario 3: New post keeps default

  1. Create a new post, keep visibility as default "Public"
  2. Save → post is federated
  3. Check database → activitypub_content_visibility meta should NOT exist (no DB flooding)

Scenario 4: Any post set to local

  1. Create/edit any post and set visibility to "Do not federate"
  2. Save → post is NOT federated
  3. Edit again → visibility is still "Do not federate"

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 old posts being federated when edited despite "Do not federate" default.

The visibility default logic in get_default_visibility() was only used
for displaying the meta box UI but not enforced during federation.
This caused old posts (>30 days) to be federated when edited, even
though "Do not federate" was shown as the default in the editor.

This fix consolidates the default visibility logic into
get_content_visibility() and uses it in is_post_disabled() to ensure
consistent behavior between the UI and actual federation logic.
Copilot AI review requested due to automatic review settings December 27, 2025 16:02
@pfefferle pfefferle self-assigned this Dec 27, 2025
@pfefferle pfefferle requested a review from a team December 27, 2025 16:02
@github-actions github-actions bot added the [Focus] Compatibility Ensuring the plugin plays well with other plugins label Dec 27, 2025
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 bug where posts older than 30 days were being federated when edited, despite the UI showing "Do not federate" as the default option. The fix consolidates default visibility logic into a single function to ensure consistent behavior between the UI and federation logic.

  • Centralizes default visibility logic in get_content_visibility() function
  • Updates is_post_disabled() to use the centralized logic instead of reading raw meta values
  • Removes duplicate visibility logic from Classic_Editor::get_default_visibility()

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
integration/class-classic-editor.php Simplifies get_default_visibility() to delegate to centralized get_content_visibility() function
includes/functions.php Adds default visibility calculation logic to get_content_visibility() and updates is_post_disabled() to use it
.github/changelog/2703-from-description Adds changelog entry for the bug fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


if ( $post_timestamp < $one_month_ago ) {
// Old post, default to local (do not federate).
$_visibility = ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL;
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a post is not federated and is not older than 30 days, $_visibility remains set to ACTIVITYPUB_CONTENT_VISIBILITY_PUBLIC from line 1448, but this case is not explicitly handled in the else block. This could lead to unexpected behavior. Add an explicit else clause to set $_visibility = ACTIVITYPUB_CONTENT_VISIBILITY_PUBLIC; for clarity and to ensure the intended default for new posts.

Suggested change
$_visibility = ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL;
$_visibility = ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL;
} else {
// Newer post, default to public.
$_visibility = ACTIVITYPUB_CONTENT_VISIBILITY_PUBLIC;

Copilot uses AI. Check for mistakes.
The visibility default logic in get_default_visibility() was only used
for displaying the meta box UI but not enforced during federation.
This caused old posts (>30 days) to be federated when edited, even
though "Do not federate" was shown as the default in the editor.

This fix:
- Uses metadata_exists() in get_content_visibility() to distinguish
  between "never set" (calculate age-based default) and "explicitly
  set to public" (respect user choice)
- Updates Classic Editor to only save visibility when it differs from
  the natural default, avoiding DB flooding with default values
- Normalizes 'public' to empty string in Classic Editor to match
  REST API behavior

Scenarios now handled correctly:
- Old post, never touched → local (not federated)
- Old post, explicitly set to public → public (federated)
- New post, default public → no meta saved, public (federated)
- Any post set to local/quiet_public → saved, respected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Focus] Compatibility Ensuring the plugin plays well with other plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants