From: Steve Sutton Date: Thu, 27 Jul 2017 17:33:30 +0000 (-0400) Subject: Update the test for empty categories if an array. X-Git-Tag: v1.6.57^2~6 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=bb1e510198e726594d82b3b1a1b8078b04999c10;p=WP-Plugins%2Fglm-member-db-events.git Update the test for empty categories if an array. This is where it is checking for an array and at same time if array is not empty. Moving the filter_var part before this fixes the issue where it wouldn't pass. --- diff --git a/models/front/events/baseAction.php b/models/front/events/baseAction.php index 9e094dc..69d45f3 100644 --- a/models/front/events/baseAction.php +++ b/models/front/events/baseAction.php @@ -237,8 +237,11 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents "; } + // Get cats if categoryId is an array + $cats = filter_var( $categoryId, FILTER_VALIDATE_INT, array( 'flags' => FILTER_FORCE_ARRAY ) ); + $catId = filter_var( $categoryId, FILTER_VALIDATE_INT ); // If a category ID is supplied - if ( $catId = filter_var( $categoryId, FILTER_VALIDATE_INT ) ) { + if ( $catId ) { //$events = $this->getEventsByCategory( $catId, $limit ); $whereParts[] = " T.id IN ( @@ -258,7 +261,7 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents $order .= " LIMIT {$limit} OFFSET 0"; } // Else if the $categoryId is an array - } else if ( $cats = filter_var( $categoryId, FILTER_VALIDATE_INT, array( 'flags' => FILTER_FORCE_ARRAY ) ) && !empty( $cats ) ) { + } else if ( $cats && !empty( $cats ) ) { $whereParts[] = " T.id IN ( SELECT event diff --git a/models/front/events/list.php b/models/front/events/list.php index 1f3a248..63cbf01 100644 --- a/models/front/events/list.php +++ b/models/front/events/list.php @@ -836,13 +836,13 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction } else { if($current_year == $year){ - + $sql = 'SELECT MONTH(start_time) as month FROM '. GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX .'times '; $sql .= "WHERE YEAR(start_time) = $year "; $sql .= "AND MONTH(start_time) >= MONTH(CURDATE()) "; $sql .= "AND event IN (select id from ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10) "; $sql .= "GROUP BY month"; - + $results[$year] = $wpdb->get_results($sql, ARRAY_A); } else { $sql = 'SELECT MONTH(start_time) as month FROM '. GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX .'times ';