[wp-trac] [WordPress Trac] #41224: WP strips query vars if post contains "wp-admin"

WordPress Trac noreply at wordpress.org
Mon Jul 3 00:09:52 UTC 2017


#41224: WP strips query vars if post contains "wp-admin"
--------------------------+-----------------------------
 Reporter:  khromov       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I'm running up against this rather obscure issue in the WP Query parser.

 If a post name contains "wp-admin", the query vars are emptied which
 results in loading the front page instead of the post.

 Repro steps:
 - Use built-in PHP web server to start a WP site.
 - Create a post or CPT called "test-wp-admin"
 - View the post, you will be redirected to the frontpage.

 Here is the relevant code from class-wp.php

 {{{
 if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/')
 !== false )
     unset( $perma_query_vars );
 }}}


 https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-
 wp.php#L276

 If you inspect $_SERVER['PHP_SELF'], the resulting value is "/index.php
 /test-wp-admin/" which triggers the conditional.

 It is not immediately clear to me why this is being done at all.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41224>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list