Repository navigation
Conversation
…s and admin assets. When requests for missing sourcemaps (.map files) or assets within the admin or includes directories are routed to WordPress, the template loader previously rendered the full 404 theme template (including block templates, template parts, and database queries). This adds wp_short_circuit_404_assets() on template_redirect to terminate such requests with an immediate HTTP 404 status. Props therssoftware, brumack. Fixes #66354.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Description
Trac Ticket: https://core.trac.wordpress.org/ticket/66354
When a browser extension (such as React Developer Tools or Vue DevTools) or missing asset requests a
.mapsourcemap file (e.g./wp-admin/installHook.js.map) or a missing asset within the administration or includes directory, server rewrite rules pass the request toindex.php.Because no post or page matches the path, WordPress flags
is_404() = trueand invokes the full 404 template loader. In block themes, this renders the theme canvas and executesrender_block_core_template_part()for header and footer template parts, executing database queries, running transient caches, and returning invalid HTML for what should be a lightweight JSON sourcemap or asset 404.Changes
wp_short_circuit_404_assets(): boolinwp-includes/canonical.php.wp_short_circuit_404_assetstotemplate_redirectat priority 1010 inwp-includes/default-filters.php(running immediately afterwp_redirect_admin_locations)..mapfiles or paths insideadmin_url()/includes_url()with a 404 status header and nocache headers.wp_short_circuit_404_assetsfilter to allow plugins to customize or override the short-circuit behavior.tests/phpunit/tests/canonical/shortCircuit404Assets.php.Props @therssoftware, brumack