Skip to content

Prevent filtered links from showing up in the sitemap#17983

Merged
diedexx merged 1 commit intofeature/indexable-sitemapsfrom
FIX-52-hide-filtered-posts
Jan 27, 2022
Merged

Prevent filtered links from showing up in the sitemap#17983
diedexx merged 1 commit intofeature/indexable-sitemapsfrom
FIX-52-hide-filtered-posts

Conversation

@diedexx
Copy link
Copy Markdown
Member

@diedexx diedexx commented Jan 24, 2022

Context

  • Yoast SEO Premium, returns false in the wpseo_sitemap_entry filter to filter out sitemap entries for posts that are redirected. Other plugins can return similar values to prevent sitemap output.

Summary

This PR can be summarized in the following changelog entry:

  • Fixes an unreleased bug where empty sitemap entries would show when they are filtered out by other plugins.

Relevant technical choices:

  • I check if the loc key exists, as that's the only required key for the sitemap.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • add the following code block to your functions.php or wp-config.php: it randomly removes around half of your posts from the sitemap.
     add_filter( 'wpseo_sitemap_entry', function ( $url ) {
     	if ( (bool) random_int( 0, 1 ) ) {
     		return false;
     	}
     
     	return $url;
     } );
  • Visit your sitemap and see that around half of your content is not in the sitemap. (which posts are gone is randomized and changes with each page load).

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [Shopify] and I have added test instructions for Shopify.

Documentation

  • I have written documentation for this change.

Quality assurance

  • I have tested this code to the best of my abilities
  • I have added unittests to verify the code works as intended
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.

Comment thread src/helpers/xml-sitemap-helper.php Outdated
@diedexx diedexx force-pushed the FIX-52-hide-filtered-posts branch from b798b10 to 196893e Compare January 25, 2022 14:00
@diedexx
Copy link
Copy Markdown
Member Author

diedexx commented Jan 27, 2022

Merging this now so we can test the feature branch on staging. A CR can come later and feedback can be processed in a new branch.

@diedexx diedexx merged commit d3a67f7 into feature/indexable-sitemaps Jan 27, 2022
@diedexx diedexx deleted the FIX-52-hide-filtered-posts branch January 27, 2022 10:55
@karlijnbok karlijnbok added this to the Indexable Sitemap milestone Feb 8, 2022
@diedexx diedexx added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants