Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks ago

#62777 new defect (bug)

Force a 404 when no sitemap provider is found

Reported by: romainmrhenry's profile romainmrhenry Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: General Keywords: has-patch has-unit-tests needs-testing
Focuses: Cc:

Description

Currently WordPress does not force a 404 when no sitemap provider is found and instead continues down the regular template hierarchy.

This can be tested with:

  • /wp-sitemap-foo-1.xml
  • ?sitemap=foo

Where foo is not a registered provider.

I would expect a 404 when the url matches the sitemap url patterns but no provider is gound.

Attachments (1)

Screenshot 2025-01-08 at 11.54.41.png (125.7 KB) - added by thabotswana 5 weeks ago.

Download all attachments as: .zip

Change History (9)

This ticket was mentioned in PR #8085 on WordPress/wordpress-develop by romainmenke.


6 weeks ago
#1

  • Keywords has-patch has-unit-tests added

#2 @samiamnot
6 weeks ago

See the related #61293.

#3 @thabotswana
5 weeks ago

Reproduction Report

I'm currently unable to reproduce the problem.

Environment

  • OS: macOS 15.2
  • Web Server: PHP.wasm
  • PHP: 7.4.31-dev
  • WordPress: 6.8-alpha-20250103.134745
  • Browser: Firefox 133.0.3
  • Theme: Twenty Twenty-Five
  • Active Plugins: None activated

Actual Results

  • ❌ Error condition does not occur (unexpected).
Last edited 5 weeks ago by thabotswana (previous) (diff)

#4 follow-up: @romainmrhenry
5 weeks ago

@thabotswana That is unexpected :)

Did you see this test? https://github.com/WordPress/wordpress-develop/pull/8085/files#diff-6a57f412101368a64c09359f72a1007cc7b027db986f454a4666648b801b9f14

It fails when removing the patch.

How are permalinks configured during your manual test?

#5 in reply to: ↑ 4 @thabotswana
5 weeks ago

Replying to romainmrhenry:

@thabotswana That is unexpected :)

Did you see this test? https://github.com/WordPress/wordpress-develop/pull/8085/files#diff-6a57f412101368a64c09359f72a1007cc7b027db986f454a4666648b801b9f14

It fails when removing the patch.

How are permalinks configured during your manual test?

The permalink structure is set to Day and name

https://playground.wordpress.net/scope:calm-chic-park/2025/01/08/sample-post/

Maybe the difference is I'm using a WordPress Playground instance? 🤷🏾‍♂️

This ticket was mentioned in Slack in #core-test by oglekler. View the logs.


5 weeks ago

#7 follow-up: @tremidkhar
5 weeks ago

  • Keywords needs-testing added

Reproduction Report

Description

During the Test Team triage, we observed that the current behavior involves navigating through the template hierarchy when no sitemap provider matches the expected behavior, forcing a 404 error prematurely could lead to unexpected results. Further investigation may be required to fully understand the issue and determine if any adjustments are needed.

Environment

  • WordPress: 6.7.1
  • PHP: 8.3.6
  • Server: Apache/2.4.62 (Win64) OpenSSL/3.1.6 PHP/8.3.6 mod_fcgid/2.3.10-dev
  • Database: mysqli (Server: 11.1.2-MariaDB / Client: mysqlnd 8.3.6)
  • Browser: Chrome 131.0.0.0
  • OS: Windows 10/11

Actual Results

  1. A 404 page is displayed when no sitemap provider is found.

#8 in reply to: ↑ 7 @romainmrhenry
5 weeks ago

Replying to tremidkhar:

Reproduction Report

Description

During the Test Team triage, we observed that the current behavior involves navigating through the template hierarchy when no sitemap provider matches the expected behavior, forcing a 404 error prematurely could lead to unexpected results. Further investigation may be required to fully understand the issue and determine if any adjustments are needed.

Environment

  • WordPress: 6.7.1
  • PHP: 8.3.6
  • Server: Apache/2.4.62 (Win64) OpenSSL/3.1.6 PHP/8.3.6 mod_fcgid/2.3.10-dev
  • Database: mysqli (Server: 11.1.2-MariaDB / Client: mysqlnd 8.3.6)
  • Browser: Chrome 131.0.0.0
  • OS: Windows 10/11

Actual Results

  1. A 404 page is displayed when no sitemap provider is found.

The same could be said for the other conditions where a 404 is already being forced in the render_sitemaps function.
Only in this very specific scenario is the template hierarchy used.
This behavior has no test coverage, no explaining comment and no discussion as far as I can tell.

There also are better escape hatches to disable or manipulate the rendering of sitemaps.

Note: See TracTickets for help on using tickets.