Skip to content

Commit

Permalink
keep expand_shortcut_qv() focused and prevent false positives. see sc…
Browse files Browse the repository at this point in the history
  • Loading branch information
scribu committed Mar 21, 2012
1 parent 12b74c4 commit e0f3417
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
9 changes: 4 additions & 5 deletions query-post.php
Expand Up @@ -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' );
Expand Down
11 changes: 8 additions & 3 deletions query-user.php
Expand Up @@ -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";
Expand Down
14 changes: 3 additions & 11 deletions query.php
Expand Up @@ -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(
Expand Down

0 comments on commit e0f3417

Please sign in to comment.