Skip to content

Commit

Permalink
[TASK] Don't use QueryBuilder->add() anymore because it has been removed
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbltr committed Jul 19, 2024
1 parent 251766d commit f958e00
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Upcoming version for TYPO3 13
[TASK] Update requirements for TYPO3 13
[TASK] Migrate plugin registration
[TASK] Remove obsolete ext_tables.php
[TASK] Migrate registration of status dashboard widget
[TASK] Migrate registration of status dashboard widget, https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-96812-NoFrontendTypoScriptBasedTemplateOverridesInTheBackend.html#widget-registration-using-services-yaml
[TASK] Don't use QueryBuilder->add() anymore because it has been removed, https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/13.0/Breaking-102875-QueryBuilderChanges.html

Upcoming version
[BUGFIX] Use correct table names for query builder or connection. Thanks to Andreas Kießling. https://github.com/tpwd/ke_search/issues/228
Expand Down
29 changes: 12 additions & 17 deletions Classes/Domain/Repository/SearchPhraseStatisticsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,21 @@ public function update(int $uid, array $updateFields)
*/
public function findAllByNumberOfDays($days = 7): array
{
/** @var ConnectionPool $connectionPool */
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$connection = $connectionPool->getConnectionForTable($this->tableName);

$startTime = time() - $days * 24 * 60 * 60;
$col = 'searchphrase';
/** @var QueryBuilder $queryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($this->tableName);

$queryBuilder->getRestrictions()->removeAll();

$statisticData = $queryBuilder
->add('select', 'count(' . $col . ') as num, language, ' . $col)
->from($this->tableName)
->add(
'where',
'tstamp > ' . $queryBuilder->quote($startTime, PDO::PARAM_INT)
)
->add('groupBy', $col . ',language HAVING count(' . $col . ')>0')
->add('orderBy', 'num desc')
->executeQuery()
->fetchAllAssociative();
$sql = 'SELECT count(' . $col . ') as num, language, ' . $col
. ' FROM ' . $this->tableName
. ' WHERE tstamp > ' . $startTime
. ' GROUP BY ' . $col . ',language HAVING count(' . $col . ')>0'
. ' ORDER BY num desc';

$statement = $connection->prepare($sql);
$result = $statement->executeQuery();
$statisticData = $result->fetchAllAssociative();
return $statisticData;
}
}

0 comments on commit f958e00

Please sign in to comment.