Skip to content

Commit

Permalink
[BUGFIX] Respect query constraints in suggest receiver count
Browse files Browse the repository at this point in the history
The query builder that fetches the results in the suggest
receiver is re-used to get the correct count of available
results.

Resolves: #85228
Relates: #78129
Releases: master
Change-Id: I2df36d4668cdde616242912e7f0d53bcded18021
Reviewed-on: https://review.typo3.org/57192
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
astehlik authored and lolli42 committed Jun 15, 2018
1 parent fbed396 commit 4c0f3aa
Showing 1 changed file with 6 additions and 5 deletions.
Expand Up @@ -147,19 +147,20 @@ public function __construct($table, $config)
*/
public function queryTable(&$params, $recursionCounter = 0)
{
$maxQueryResults = 50;
$rows = [];
$this->params = &$params;
$start = $recursionCounter * 50;
$start = $recursionCounter * $maxQueryResults;
$this->prepareSelectStatement();
$this->prepareOrderByStatement();
$result = $this->queryBuilder->select('*')
->from($this->table)
->setFirstResult($start)
->setMaxResults(50)
->setMaxResults($maxQueryResults)
->execute();
$allRowsCount = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($this->table)
$allRowsCount = $this->queryBuilder
->count('uid')
->resetQueryPart('orderBy')
->execute()
->fetchColumn(0);
if ($allRowsCount) {
Expand Down Expand Up @@ -204,7 +205,7 @@ public function queryTable(&$params, $recursionCounter = 0)
}

// if there are less records than we need, call this function again to get more records
if (count($rows) < $this->maxItems && $allRowsCount >= 50 && $recursionCounter < $this->maxItems) {
if (count($rows) < $this->maxItems && $allRowsCount >= $maxQueryResults && $recursionCounter < $this->maxItems) {
$tmp = self::queryTable($params, ++$recursionCounter);
$rows = array_merge($tmp, $rows);
}
Expand Down

0 comments on commit 4c0f3aa

Please sign in to comment.