-
Notifications
You must be signed in to change notification settings - Fork 83
Fix old posts being federated when edited #2703
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
base: trunk
Are you sure you want to change the base?
Conversation
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.
There was a problem hiding this 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; |
Copilot
AI
Dec 27, 2025
There was a problem hiding this comment.
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.
| $_visibility = ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL; | |
| $_visibility = ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL; | |
| } else { | |
| // Newer post, default to public. | |
| $_visibility = ACTIVITYPUB_CONTENT_VISIBILITY_PUBLIC; |
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
Fixes #
Proposed changes:
metadata_exists()to distinguish between "never set" (calculate age-based default) and "explicitly set to public" (respect user choice)Other information:
Testing instructions:
Scenario 1: Old post without explicit visibility
post_datein database)Scenario 2: Old post with explicit public visibility
Scenario 3: New post keeps default
activitypub_content_visibilitymeta should NOT exist (no DB flooding)Scenario 4: Any post set to local
Changelog entry
Changelog Entry Details
Significance
Type
Message
Fix old posts being federated when edited despite "Do not federate" default.