From a46a7e8a1c670e65ed11ecd4726dc73093b1c1ba 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 6f8d36c8946b..7d323eba387e 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -2750,6 +2750,9 @@ public function unselectedSectionColumns() { */ public function buildRows($sql, &$rows) { $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();