[Plugin: Events Manager] Pagination of search results has SQL bug
-
G’day, using EM 5.0.50 and have found a problem with the SQL used to count search results, and pagination in the events-list.php template.
Firstly, the events-list.php template does not pass the search arguments onto em_paginate() so the search form is cleared when you click through to a page from pagination. When $args is supplied, the page number isn’t passed through properly, due to simply adding the search arguments array to another array. An array merge will ensure the second array’s values override the first array:
@28:
$search_args = array_merge(EM_Events::get_post_search($args), array('page'=>'%PAGE%','action'=>'search_events'));
Secondly, class EM_Events will never count rows correctly when there is an offset specified, because the result set has only one row (the count) and an offset scrolls that out of bounds. Thus, when ::get is called with $count=true you need to set $limit and $offset to empty strings:
@58:
$limit = $offset = ''; if (!$count) { $limit = ( $args['limit'] && is_numeric($args['limit'])) ? "LIMIT {$args['limit']}" : ''; $offset = ( $limit != "" && is_numeric($args['offset']) ) ? "OFFSET {$args['offset']}" : ''; }
- The topic ‘[Plugin: Events Manager] Pagination of search results has SQL bug’ is closed to new replies.