Skip to content

Commit

Permalink
add warning about queries that don't specify 'connected_type'. fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
scribu committed Mar 21, 2012
1 parent c744fe8 commit 9708732
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/query-post.php
Expand Up @@ -38,7 +38,7 @@ function posts_clauses( $clauses, $wp_query ) {

$qv = P2P_Query::get_qv( $wp_query->query_vars );

if ( empty( $qv['items'] ) )
if ( !$qv )
return $clauses;

$wp_query->_p2p_cache = true;
Expand Down
2 changes: 1 addition & 1 deletion core/query-user.php
Expand Up @@ -25,7 +25,7 @@ function pre_user_query( $query ) {

$qv = P2P_Query::get_qv( $q );

if ( empty( $qv['items'] ) )
if ( !$qv )
return;

$map = array(
Expand Down
11 changes: 8 additions & 3 deletions core/query.php
Expand Up @@ -16,8 +16,12 @@ function expand_shortcut_qv( &$q ) {
}
}

if ( !isset( $q['connected_type'] ) )
if ( !isset( $q['connected_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';
Expand All @@ -26,6 +30,9 @@ function expand_shortcut_qv( &$q ) {
}

function get_qv( $q ) {
if ( !isset( $q['p2p_type'] ) )
return false;

$qv_list = array(
'items', 'direction', 'meta',
'orderby', 'order_num', 'order'
Expand All @@ -35,8 +42,6 @@ function get_qv( $q ) {
$qv[$key] = isset( $q["connected_$key"] ) ? $q["connected_$key"] : false;
}

$qv['p2p_type'] = isset( $q['p2p_type'] ) ? $q['p2p_type'] : false;

return $qv;
}

Expand Down

0 comments on commit 9708732

Please sign in to comment.