Skip to content

Commit

Permalink
[BUGFIX] Avoid SQL error in indexed_search statistics
Browse files Browse the repository at this point in the history
When an entered search word longer than 50 characters
was used in indexed_search previously, a TYPO3 Exception
was thrown due to a SQL error when having search statistics
enabled.

This change modifies the added statistic and cuts down
the search stats to a maximum length of 50 characters
as the DB field has only 50 characters.

Resolves: #93385
Related: #92993
Releases: master, 10.4
Change-Id: Iea691446571c31378c79c7ac27a7fe98b0fa458a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67573
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
  • Loading branch information
bmack authored and maddy2101 committed Feb 15, 2021
1 parent 2f5bd9b commit d478466
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,21 @@ protected function writeSearchStat(array $searchWords): void
$entries = [];
foreach ($searchWords as $val) {
$entries[] = [
'word' => $val['sword'],
mb_substr($val['sword'], 0, 50),
// Time stamp
'tstamp' => $GLOBALS['EXEC_TIME'],
$GLOBALS['EXEC_TIME'],
// search page id for indexed search stats
'pageid' => $GLOBALS['TSFE']->id
$GLOBALS['TSFE']->id
];
}
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('index_stat_word');
$connection->bulkInsert('index_stat_word', $entries);
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('index_stat_word')
->bulkInsert(
'index_stat_word',
$entries,
[ 'word', 'tstamp', 'pageid' ],
[ \PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_INT ]
);
}

/**
Expand Down

0 comments on commit d478466

Please sign in to comment.