Skip to content

Do not store activitypub_max_image_attachments if it uses the default value #1821

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

Merged
merged 6 commits into from
Jun 16, 2025

Conversation

pfefferle
Copy link
Member

@pfefferle pfefferle commented Jun 16, 2025

Do not store the activitypub_max_image_attachments Post-Meta, if it is the same as the default, to not spam the DB.

Proposed changes:

  • Checks if the activitypub_max_image_attachments setting from the block editor has the same value as the default, and remove it if so.

Other information:

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

Testing instructions:

  • See unittest

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

The image attachment setting is no longer saved to the database if it matches the default value.

@pfefferle pfefferle self-assigned this Jun 16, 2025
@pfefferle pfefferle requested review from obenland and Copilot June 16, 2025 09:14
@pfefferle pfefferle changed the title Do not store activitypub_max_image_attachments if it is the default Do not store activitypub_max_image_attachments if it uses the default value Jun 16, 2025
Copy link

@Copilot 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 prevents storing the activitypub_max_image_attachments post meta when it matches the default setting, reducing unnecessary database entries.
Key changes:

  • Updated updated_postmeta to delete meta when it equals the default option
  • Added unit tests for this behavior
  • Created a changelog entry for the change

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/includes/class-test-activitypub.php Adds test_updated_postmeta to verify default-value meta is not persisted and custom values are
includes/class-activitypub.php Extends updated_postmeta to delete the max-image-attachments meta if it equals the default
.github/changelog/1821-from-description Adds a patch-level changelog entry detailing the behavior change
Comments suppressed due to low confidence (1)

includes/class-activitypub.php:692

  • [nitpick] Update the docblock above updated_postmeta to mention that this method also removes the activitypub_max_image_attachments meta when it matches the default.
public static function updated_postmeta( $meta_id, $object_id, $meta_key, $meta_value ) {

pfefferle and others added 4 commits June 16, 2025 11:16
Copy link
Member

@obenland obenland left a comment

Choose a reason for hiding this comment

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

This should be good to go as-is.

The function doc is currently specific to activitypub_content_visibility, so that could be generalized, but I'm not sure I'd consider it a blocker.

Potential follow-ups:

  • We could consider giving activitypub_content_warning a similar treatment.
  • I don't know if it's possible to move this to the update_post_metadata hook and avoid the step of updating the value?
  • Should all of this also happen when a meta value gets added?

@pfefferle pfefferle merged commit e3f0a3e into trunk Jun 16, 2025
11 checks passed
@pfefferle pfefferle deleted the improve/default-image-attachments branch June 16, 2025 14:44
@pfefferle
Copy link
Member Author

I will work on a follow up! I think it should work for both!

pfefferle added a commit that referenced this pull request Jun 18, 2025
this is a follow up of #1821
@pfefferle pfefferle mentioned this pull request Jun 18, 2025
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants