Make WordPress Core

Opened 7 weeks ago

Closed 17 hours ago

Last modified 17 hours ago

#61931 closed defect (bug) (fixed)

sitemap.xml redirect no longer works when using custom permalinks

Reported by: gmariani405's profile gmariani405 Owned by: swissspidy's profile swissspidy
Milestone: 6.7 Priority: normal
Severity: normal Version: 5.5
Component: Sitemaps Keywords: has-patch commit has-screenshots has-testing-info has-unit-tests
Focuses: Cc:

Description

The XML sitemap functionality from WordPress 5.5 fails to handle the /sitemap.xml -> /wp-sitemap.xml redirect if custom permalinks are used. If you use any of the built-in permlinks modes, the redirect functions fine, but if you set it to a custom permalink that is dis-similar to the built-in ones it breaks because it is only looking to pull values from the built-in regular expression matches. The /wp-sitemap.xml itself still continues to work.

In the sites where the redirect breaks, I have this as the Custom Structure:

/%category%/%postname%/
/%category%/%year%/%monthnum%/%postname%/

Change History (13)

#1 @swissspidy
7 weeks ago

  • Milestone changed from Awaiting Review to 6.7
  • Version changed from trunk to 5.5

This ticket was mentioned in PR #7249 on WordPress/wordpress-develop by @swissspidy.


7 weeks ago
#2

  • Keywords has-patch added

@swissspidy commented on PR #7249:


7 weeks ago
#3

cc @pbiron

@euthelup commented on PR #7249:


3 days ago
#4

After testing this case I can confirm the issue on wordpress:trunk branch. With a custom permalink set, if I try to visit http://localhost:8889/sitemap.xml I get a redirect to the "404 - not found" template.

After switching to swissspidy:fix/61931-sitemap-redirect when I visit http://localhost:8889/sitemap.xml I get a redirect to http://localhost:8889/wp-sitemap.xml and I can see the proper Sitemap template.

Good job! 👍

#5 @swissspidy
3 days ago

  • Keywords commit added
  • Owner set to swissspidy
  • Status changed from new to accepted

@peterwilsoncc commented on PR #7249:


25 hours ago
#6

Are you able to add a test case for the permalink structures noted in the ticket?

#7 @krupajnanda
20 hours ago

  • Keywords has-screenshots has-testing-info added

Hi @peterwilsoncc

Test Report

Description

This report validates whether the indicated patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/7249

Environment

  • WordPress: 6.7-alpha-58576-src
  • PHP: 8.2.15
  • Server: nginx/1.25.3
  • Database: mysqli (Server: 8.0.36 / Client: mysqlnd 8.2.15)
  • Browser: Chrome 129.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Four 1.2
  • MU Plugins:
    • Safe Autoloaded Options Limit Test (MU Plugin) 1.0
  • Plugins:
    • Test Reports 1.1.0

Actual Results

  1. ✅ Issue resolved with patch.

Additional Notes

  • Scenarios I checked :
    • Fresh WordPress Setup
    • Default Permalink, URL redirection ✅
    • Custom Permalink, URL redirection ✅

Supplemental Artifacts

Please check the visual here : https://drive.google.com/file/d/1gm_0T3o4doJi-fmmEysmyYuUR9De7Q5z/view?usp=drive_link

This ticket was mentioned in Slack in #core by chaion07. View the logs.


18 hours ago

#9 @chaion07
18 hours ago

Thanks @gmariani405 for reporting this. We reviewed this Ticket during a recent bug-scrub session. Kudos to Krupa for adding the Test Reports and acknowledging that the patch is working as expected. We also believe that this is ready for commit. Thanks.

Props to @krupajnanda for the Test Results and @pratiklondhe for the discussion.

Cheers!

#10 @swissspidy
18 hours ago

  • Keywords has-unit-tests added

#11 @swissspidy
17 hours ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 59228:

Sitemaps: Improve sitemap.xml redirects when using custom permalinks.

Changes the way redirects from sitemap.xml to wp-sitemap.xml happen, so that they also work when using a more complex custom rewrite structure.

Props gmariani405, swissspidy, euthelup, peterwilsoncc.
Fixes #61931.

#12 @swissspidy
17 hours ago

In 59229:

Sitemaps: Add missing _deprecated_function() call to newly deprecated method.

Follow-up to [59228].

See #61931.

Note: See TracTickets for help on using tickets.