[wp-trac] [WordPress Trac] #23208: Incorrect variable name for comment meta queries
WordPress Trac
noreply at wordpress.org
Tue Jan 15 20:27:43 UTC 2013
#23208: Incorrect variable name for comment meta queries
-----------------------------+--------------------------
Reporter: danielbachhuber | Type: defect (bug)
Status: new | Priority: normal
Milestone: Awaiting Review | Component: Comments
Version: 3.5 | Severity: normal
Keywords: needs-patch |
-----------------------------+--------------------------
An error notice I saw using the Liveblog plugin:
{{{
Undefined variable: q in /Users/danielbachhuber/wp/wp-includes/comment.php
on line 299
}}}
traces back to r22074 where the following is added:
{{{
// Parse meta query
$this->meta_query = new WP_Meta_Query();
$this->meta_query->parse_query_vars( $this->query_vars );
}}}
but then is used later as:
{{{
if ( ! empty( $this->query_vars['meta_key'] ) ) {
$allowed_keys[] = $q['meta_key'];
$allowed_keys[] = 'meta_value';
$allowed_keys[] = 'meta_value_num';
}
$ordersby = array_intersect( $ordersby, $allowed_keys );
foreach ( $ordersby as $key => $value ) {
if ( $value == $q['meta_key'] || $value == 'meta_value' )
{
$ordersby[ $key ] =
"$wpdb->commentmeta.meta_value";
} elseif ( $value == 'meta_value_num' ) {
$ordersby[ $key ] =
"$wpdb->commentmeta.meta_value+0";
}
}
}
}}}
Something like the patch attached resolves the error, but this would
probably benefit from unit tests too.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/23208>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list