[wp-trac] [WordPress Trac] #41196: add _doing_it_wrong to get_query_var and prevent fatal errors

WordPress Trac noreply at wordpress.org
Wed Jun 28 20:32:22 UTC 2017


#41196: add _doing_it_wrong to get_query_var and prevent fatal errors
--------------------------+-----------------------------
 Reporter:  netweblogic   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 The following scenario will throw a fatal error:

 {{{#!php
 <?php
 function parse_query_fail_test(){
         get_query_var('some_var_name', false);
 }
 add_action('parse_query', 'parse_query_fail_test');

 function parse_query_fail_trigger(){
         get_posts();
 }
 add_action('plugins_loaded', 'parse_query_fail_trigger');
 }}}

 this could easily be avoided with a check and _doing_it_wrong function,
 similar to functions further down such as is_tax();

 I would argue that the same could be done for get_queried_object(),
 get_queried_object_id() and set_query_var()

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


More information about the wp-trac mailing list