[wp-trac] [WordPress Trac] #54507: Site Editor does not load when using "almost pretty" permalinks
WordPress Trac
noreply at wordpress.org
Thu Nov 25 06:02:47 UTC 2021
#54507: Site Editor does not load when using "almost pretty" permalinks
--------------------------+-----------------------------
Reporter: noisysocks | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
The Site Editor does not load if the site's permalink structure is set to
[https://wordpress.org/support/article/using-permalinks/#pathinfo-almost-
pretty the "almost pretty" structure]. This is the default permalink
structure [https://github.com/WordPress/wordpress-
develop/blob/d6f3d408d8e8e61221de7d7832360f203c4b4d06/src/wp-
admin/includes/upgrade.php#L500 when WordPress is installed on a server
that does not support URL rewriting.]
Steps to reproduce:
1. Go to ''WP Admin → Settings → Permalinks''.
2. Select ''Custom Structure'' and enter
`/index.php/%year%/%monthnum%/%day%/%postname%/` into the text field.
3. Go to ''WP Admin → Appearance → Editor''.
4. You'll see a WSOD.
----
The WSOD occurs because the Site Editor tries to access a property on a
null template object.
The template object is null because the request made to
`/wp/v2/templates/twentytwentytwo//home` results in a 404 error.
You can confirm this locally:
{{{
$ http -a admin:password GET http://wp-git-build.test/index.php/wp-
json/wp/v2/templates/twentytwentytwo//home context==edit
HTTP/1.1 404 Not Found
{
"code": "rest_template_not_found",
"data": {
"status": 404
},
"message": "No templates exist with that id."
}
}}}
The request results in a 404 error because the REST API endpoint is
looking for a template named `twentytwentytwo/home`, not
`twentytwentytwo//home`. (Note the number of slashes.)
This is because, when the "almost pretty" permalink structure, WordPress
will use `$_SERVER['PATH_INFO']` as the route. `PATH_INFO` will collapse
double slashes.
You can confirm this by adding a `var_dump()` to `wp-settings.php`:
{{{
var_dump( $_SERVER['PATH_INFO'] ); // string(45) "/wp-
json/wp/v2/templates/twentytwentytwo/home"
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54507>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list