Skip to content

Conversation

LiamSarsfield
Copy link
Contributor

@LiamSarsfield LiamSarsfield commented Sep 3, 2025

Fixes HOG-332: Add Blog Sticker filters

Proposed changes:

  • Creates 2 new filters that leverages the blog stickers for Atomic added here 191833-ghe-Automattic/wpcom
  • If either blog sticker is added, the respective filter will return true.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Test sitemap improvements

Does this pull request change what data or activity we track or use?

N/A

Testing instructions:

  • Verify your WoA site has an appropriate sticker (e.g. XMLWriter, as it is easy to test) by following the instructions in this PR: 191833-ghe-Automattic/wpcom
  • Ensure your site has at least one post
  • Run the following cronjob again on your site: jp_sitemap_cron_hook (e.g. through WP Crontrol)
  • Once the cronjob has ran, you can verify the sitemap has the XMLWriter by going to your site's sitemap URL, e.g.
    view-source:https://yourwebsite.wpcomstaging.com/sitemap.xml
  • Verify that Jetpack_Sitemap_Buffer_Master_XMLWriter appears as the 3rd line comment. This confirms the blog sticker has been successfully applied

… stickers

This update introduces two new filters in the Jetpack_Sitemap_Manager class:
- `jetpack_sitemap_suspend_cache_addition` to control cache addition during sitemap generation.
- `jetpack_sitemap_use_xmlwriter` to leverage XMLWriter when available, based on blog sticker status.

Both filters enhance sitemap generation flexibility by allowing site-specific configurations.
Copy link
Contributor

github-actions bot commented Sep 3, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (WordPress.com Site Helper), and enable the add/sitemap/blog-stickers-HOG-332 branch.

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Feature] Sitemaps [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress labels Sep 3, 2025
Copy link
Contributor

github-actions bot commented Sep 3, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Sep 3, 2025
Copy link

jp-launch-control bot commented Sep 3, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/wpcomsh/wpcomsh.php 112/326 (34.36%) -0.11% 1 ❤️‍🩹

Full summary · PHP report

…Sitemap_Manager

This commit introduces multiple test cases for the callback_filter_use_xmlwriter method, covering various scenarios including:
- When has_blog_sticker returns true or false.
- When wpcomsh_is_site_sticker_active returns true or false.
- Cases where neither function exists.

These tests ensure robust handling of XMLWriter usage based on blog sticker status, enhancing the reliability of sitemap generation.
This commit introduces a new file, class-sitemaps-sticker-handlers.php, which adds filters to control the suspension of cache addition and the use of XMLWriter for sitemaps based on active blog stickers. Additionally, tests for these new functionalities have been implemented to ensure proper behavior under various conditions, enhancing the flexibility and reliability of sitemap generation.
This commit updates the SitemapsStickerHandlersTest class to utilize mock functions for testing sticker functionality, replacing the previous Patchwork-based approach. A new mock file, sticker-functions.php, is introduced to define the mock functions `has_blog_sticker` and `wpcomsh_is_site_sticker_active`, allowing for better isolation and control during tests. The test cases are adjusted accordingly to ensure they validate the expected behavior of the sitemap generation based on sticker status.
@LiamSarsfield LiamSarsfield added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Sep 4, 2025
…nager

This commit introduces two new test cases to validate the behavior of the 'jetpack_sitemap_location' filter. The first test checks the default value of the filter, ensuring it is set to an empty string when no value is provided. The second test verifies that a custom filter can modify the sitemap location correctly. These additions enhance the test coverage for the sitemap functionality, ensuring expected behavior in various scenarios.
…-handlers.php with class-wpcomsh-sitemap-sticker-handlers.php. The new class centralizes sticker functionality for managing cache suspension and XMLWriter usage. Updated tests to reflect the new class structure and improved mock function handling for better test isolation.
@LiamSarsfield LiamSarsfield requested review from dilirity, kraftbj and a team September 4, 2025 18:12
@LiamSarsfield LiamSarsfield marked this pull request as ready for review September 4, 2025 18:12
@dilirity dilirity added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Sep 5, 2025
Copy link
Member

@dilirity dilirity left a comment

Choose a reason for hiding this comment

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

Nice work!

Tests work as per instructions, code looks good.

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Sitemaps [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Wpcomsh [Status] Needs Review This PR is ready for review. [Tests] Includes Tests [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants