[wp-trac] [WordPress Trac] #34634: Empty PHP_SELF causes 404 pages to load front page with 200 status code
WordPress Trac
noreply at wordpress.org
Wed Mar 16 14:03:02 UTC 2016
#34634: Empty PHP_SELF causes 404 pages to load front page with 200 status code
----------------------------+------------------------------
Reporter: l3rady | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Bootstrap/Load | Version: 2.0
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
----------------------------+------------------------------
Changes (by Chouby):
* keywords: => has-patch
* version: 4.3.1 => 2.0
* component: Query => Bootstrap/Load
Comment:
I had a different issue which however has the same cause, i.e the fact
that `$_SERVER['PHP_SELF']` does not contain a reliable value depending on
the server configuration.
In most cases, it contains the relative path of the file to boot
WordPress. When the server does not set it, `wp_fix_server_vars()` fixes
it with `$_SERVER['REQUEST_URI']` without the query string.
This works well for admin, login, etc... but not when WordPress boots from
`index.php`. In that case, it is expected that the server fills the
variable with `'/index.php'`. But if the server does not fill it, then
`wp_fix_server_vars()` fixes it incorrectly to something like `'/'` when
using default permalinks or something like `'/postname'` when using pretty
permalinks.
This inconsistency can lead to various potential bugs including the one
reported here.
In [attachment:34634.diff], I propose to explicitely set
`$_SERVER['PHP_SELF']` to `'/index.php'` when it is empty and
`$_SERVER['REQUEST_URI']` does not contain a php file. This is a first
rough patch which may need a smarter test to avoid some edged cases.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34634#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list