[wp-trac] [WordPress Trac] #40166: query_vars bug sets is_home to false.

WordPress Trac noreply at wordpress.org
Tue Mar 28 16:43:03 UTC 2017


#40166: query_vars bug sets is_home to false.
--------------------------+------------------------------
 Reporter:  avengers      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:  4.7.3
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by indextwo):

 I'm getting exactly the same behaviour; ended up on ticket #25143 before
 finding this. Problem described in previous ticket for `3.6` still exists
 in `4.7.3` and as above: adding a query var via `query_vars` whilst having
 a static page set as the homepage results in `is_home()` incorrectly
 returning `true` and `is_front_page()` returning `false` when appending a
 `$_GET` var to the URL. Remove the `query_vars` filter, and they behave as
 expected.

 To double-check, I added `die('<h1>I AM TEH INDEX</h1>');` to my
 `index.php` template (where my page template was normal) and I got the
 `die()` rather than the regular page content when
 `add_filter('query_vars', 'my_qv_func')` was enabled.

 It may be worth noting that this only happens ''if'' you add a custom
 query var:

 {{{#!php
 <?php
 function my_qv_func($queryVars) {
         $queryVars[] = 'myqv';
         return $queryVars;
 }
 add_filter('query_vars', 'my_qv_func'); // Static homepage breaks
 }}}


 Remove the addition (but leave the filter in place) and it behaves as
 expected:

 {{{#!php
 <?php
 function my_qv_func($queryVars) {
         //$queryVars[] = 'myqv';
         return $queryVars;
 }
 add_filter('query_vars', 'my_qv_func'); // Static homepage behaves as
 expected
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40166#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list