Make WordPress Core

Opened 8 weeks ago

Closed 8 weeks ago

Last modified 8 weeks ago

#64135 closed defect (bug) (fixed)

Query: undefined variable $q in WP_Query::generate_cache_key()

Reported by: ramonopoly's profile ramonopoly Owned by: westonruter's profile westonruter
Milestone: 6.9 Priority: normal
Severity: normal Version: 6.9
Component: Query Keywords: has-patch
Focuses: Cc:

Description

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
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
if ( ! isset( $args['orderby'] ) ) {
    $args['orderby'] = 'date';
}

Change History (6)

#1 @westonruter
8 weeks ago

  • Milestone changed from Awaiting Review to 6.9
  • Owner set to westonruter
  • Status changed from new to reviewing

This ticket was mentioned in PR #10393 on WordPress/wordpress-develop by @ramonopoly.


8 weeks ago
#2

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:

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.

Introduced in https://core.trac.wordpress.org/changeset/58122 / https://github.com/10up/wordpress-develop/commit/3a6cca9ff772c77c86a3cf7c5a69398acc4c2272

This patch replaces the undefined $q variable with the correct $args parameter:

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

@ramonopoly commented on PR #10393:


8 weeks ago
#3

Thanks @westonruter 🙇🏻

#4 @ramonopoly
8 weeks ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 61043:

Query: fix undefined variable $q in WP_Query::generate_cache_key()

The generate_cache_key() method in WP_Query referenced an undefined variable $q. The method only has two parameters: $args and $sql. The variable $q is not defined anywhere in this method scope. This patch replaces the undefined $q variable with the correct $args parameter.

Follow-up to [59442]

Props ramonopoly, westonruter

Fixes #64135.

@ramonopoly commented on PR #10393:


8 weeks ago
#5

Committed to r61043

#6 @westonruter
8 weeks ago

This bug had the effect of always overriding the orderby query arg to be date when generating a cache key, potentially colliding with another cached query with a different orderby.

Note: See TracTickets for help on using tickets.