From b040d4b600e400edcfd3273c701df73b116d123e Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 4 May 2018 16:38:22 +1200 Subject: [PATCH] Fix (unreleased) regression on report pager We recently added a patch to disable full group by before some queries that were not compliant with that standard. That patch broke the report pager because later code relied on the last issued query ALWAYS being the one that determined how many rows are retrived by the main query, however, we were doing a query to check sql mode after the main query. I could make a case for storing sql mode data somewhere sensible at the start of the session. However, I think this fix is the right fix for the bug as it calculates the rows retrieved / retrievable immediately after the retrieval query, rather than 'at some later date when we hope no other queries have run'. If is in the same function as the enableFullGroupBy so only reports that ALSO run that will hit the line (ie. not reports that override buildRows) --- CRM/Report/Form.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index b66fc3599c..672593d8e4 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -2962,6 +2962,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND CRM_Core_DAO::disableFullGroupByMode(); } $dao = CRM_Core_DAO::executeQuery($sql); + if (stristr($this->_select, 'SQL_CALC_FOUND_ROWS')) { + $this->_rowsFound = CRM_Core_DAO::singleValueQuery('SELECT FOUND_ROWS()'); + } CRM_Core_DAO::reenableFullGroupByMode(); if (!is_array($rows)) { $rows = array(); -- 2.25.1