Make WordPress Core

Opened 6 years ago

Last modified 3 years ago

#51280 assigned defect (bug)

wp_register_sitemap_provider() breaks sitemap functionality if provider name contains a dash (-)

Reported by: MadtownLems Owned by: pbiron
Priority: normal Milestone: Future Release
Component: Sitemaps Version: 5.5
Severity: minor Keywords: needs-patch
Cc: Focuses:

Description

The announcement post for the functionality (​https://make.wordpress.org/core/2020/07/22/new-xml-sitemaps-functionality-in-wordpress-5-5/) includes the following snippet:

wp_register_sitemap_provider( 'awesome-plugin', $provider );

However, I believe that the name doesn't work in practice. From my experiences, using a dash in the sitemap provider name causes the following:

The map is listed on the index, but when trying to view it, you just view your site's home page (not a 404, and not anything sitemappy).

If you register the provider with the name 'awesome-plugin', render_sitemaps() sees the following data:

$sitemap => 'awesome' (Expected: 'awesome-plugin' )
$object_subtype => 'plugin' (Expected: null )

and then it returns early due to if ( ! $provider )

As another test, I tried simply changing the name of Core's User Sitemap from 'users' to 'foo-users' and got the same result. The map was listed on the index, but when trying to browse it, you just see your site's home page (not a 404).

Doing some debugging, render_sitemaps sees the following data:

$sitemap => 'foo'
$object_subtype => 'users'

and then it returns early due to if ( ! $provider )

Change History (5)

This ticket was mentioned in ​Slack in #core-sitemaps by madtownlems. ​View the logs.


6 years ago

#2 @johnbillion
6 years ago

  • Version → 5.5

#3 @pbiron
6 years ago

  • Owner set to pbiron
  • Status new → assigned

Thank you for the report.

I can confirm the described behavior. It's not just dash (-): any character not in the range [a-z] causes the same results.

Additionally, the $name parameter of wp_register_sitemap_provider() must be the same as the $name property of the WP_Sitemaps_Provider subclass instance passed in the $provider param...and that is not currently documented anywhere.

#5 @swissspidy
3 years ago

  • Keywords needs-patch added
  • Milestone Awaiting Review → Future Release
  • Severity normal → minor
Note: See TracTickets for help on using tickets.