Permalink
Browse files

keep expand_shortcut_qv() focused and prevent false positives. see #131

  • Loading branch information...
scribu committed Mar 21, 2012
1 parent 1b17f15 commit 48f0391400c69676229a16b9e62bbfaab7deea29
Showing with 15 additions and 19 deletions.
  1. +4 −5 core/query-post.php
  2. +8 −3 core/query-user.php
  3. +3 −11 core/query.php
View
@@ -14,13 +14,12 @@ function init() {
function parse_query( $wp_query ) {
$q =& $wp_query->query_vars;
- if ( !P2P_Query::expand_shortcut_qv( $q ) )
- return;
+ P2P_Query::expand_shortcut_qv( $q );
- if ( 'any' == $q['connected_items'] ) {
- $item = isset( $q['post_type'] ) ? $q['post_type'] : 'post';
- } else {
+ if ( isset( $q['connected_items'] ) ) {
$item = $q['connected_items'];
+ } else {
+ $item = isset( $q['post_type'] ) ? $q['post_type'] : 'post';
}
$r = P2P_Query::expand_connected_type( $q, $item, 'post' );
View
@@ -11,10 +11,15 @@ function pre_user_query( $query ) {
$q =& $query->query_vars;
- if ( !P2P_Query::expand_shortcut_qv( $q ) )
- return;
+ P2P_Query::expand_shortcut_qv( $q );
+
+ if ( isset( $q['connected_items'] ) ) {
+ $item = $q['connected_items'];
+ } else {
+ $item = 'any';
+ }
- $r = P2P_Query::expand_connected_type( $q, $q['connected_items'], 'user' );
+ $r = P2P_Query::expand_connected_type( $q, $item, 'user' );
if ( false === $r ) {
$query->query_where = " AND 1=0";
View
@@ -15,24 +15,16 @@ function expand_shortcut_qv( &$q ) {
$q['connected_direction'] = $direction;
}
}
+ }
- if ( !isset( $q['connected_type'] ) ) {
+ function get_qv( $q ) {
+ if ( !isset( $q['p2p_type'] ) ) {
if ( isset( $q['connected_items'] ) ) {
trigger_error( "P2P queries without 'connected_type' are no longer supported." );
}
return false;
}
- if ( !isset( $q['connected_items'] ) )
- $q['connected_items'] = 'any';
-
- return true;
- }
-
- function get_qv( $q ) {
- if ( !isset( $q['p2p_type'] ) )
- return false;
-
$qv['p2p_type'] = $q['p2p_type'];
$qv_list = array(

0 comments on commit 48f0391

Please sign in to comment.