[wp-trac] [WordPress Trac] #64135: Query: undefined variable $q in WP_Query::generate_cache_key()

WordPress Trac noreply at wordpress.org
Wed Oct 22 06:09:18 UTC 2025


#64135: Query: undefined variable $q in WP_Query::generate_cache_key()
--------------------------+-----------------------------
 Reporter:  ramonopoly    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  trunk
 Severity:  normal        |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------------
 Follow up to https://core.trac.wordpress.org/ticket/59442

 The `generate_cache_key()` method in `WP_Query` references an undefined
 variable `$q` on line 5046:

 {{{#!php
 <?php
 if ( ! isset( $q['orderby'] ) ) {
     $args['orderby'] = 'date';
 }
 }}}



 The method only has two parameters: `$args` and `$sql`. The variable `$q`
 is not defined anywhere in this method scope.


 This fix is to replace the undefined `$q` variable with the correct
 `$args` parameter:

 {{{#!php
 <?php
 if ( ! isset( $args['orderby'] ) ) {
     $args['orderby'] = 'date';
 }
 }}}

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


More information about the wp-trac mailing list