Skip to content

Commit

Permalink
Check the 'fields' argument of the query $query. Do not include event…
Browse files Browse the repository at this point in the history
… columns when we're only after one ID/parent ID columns. Append, rather than prepend event columns. Thanks to @simonwheatley. Ref #98, Ref #99
  • Loading branch information
stephenharris committed Jun 21, 2013
1 parent 3640bef commit b84bb83
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions includes/event-organiser-archives.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,17 @@ function wp17853_eventorganiser_workaround( $limit ){
function eventorganiser_event_fields( $select, $query ){
global $wpdb;

if( eventorganiser_is_event_query( $query, true ) ){
$q_fields = $query->get( 'fields' );

if( eventorganiser_is_event_query( $query, true ) && 'ids' != $q_fields && 'id=>parent' != $q_fields ){
$et =$wpdb->eo_events;
/* Include 'event_occurrence' for backwards compatibility. Will eventually be removed. */
/* Renaming event_id as occurrence id. Keep event_id for backwards compatibility */
if( 'series'== $query->get('group_events_by') ) {
//Work-around for group_events_by series.
$select = "{$et}.event_id, {$et}.event_id AS occurrence_id, {$et}.StartTime, min({$et}.StartDate) as StartDate, min({$et}.EndDate) as EndDate, {$et}.FinishTime, {$et}.event_occurrence, ".$select;
$select .= ", {$et}.event_id, {$et}.event_id AS occurrence_id, {$et}.StartTime, min({$et}.StartDate) as StartDate, min({$et}.EndDate) as EndDate, {$et}.FinishTime, {$et}.event_occurrence ";
}else{
$select = "{$et}.event_id, {$et}.event_id AS occurrence_id, {$et}.StartDate, {$et}.StartTime, {$et}.EndDate, {$et}.FinishTime, {$et}.event_occurrence, ".$select;
$select .= ", {$et}.event_id, {$et}.event_id AS occurrence_id, {$et}.StartDate, {$et}.StartTime, {$et}.EndDate, {$et}.FinishTime, {$et}.event_occurrence ";
}
}
return $select;
Expand Down

0 comments on commit b84bb83

Please sign in to comment.