[BUGFIX] EXT:indexed_search: Dont add stat record for empty search 96/53396/3
authorDaniel Goerz <dlg@lightwerk.com>
Tue, 4 Jul 2017 12:07:24 +0000 (14:07 +0200)
committerSusanne Moog <susanne.moog@typo3.org>
Tue, 17 Oct 2017 23:15:31 +0000 (01:15 +0200)
Resolves: #81786
Releases: master, 8.7
Change-Id: I1bc5e93fdfb3a1068a09ae37c47e51b1811d58b5
Reviewed-on: https://review.typo3.org/53396
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Sascha Rademacher <s.rademacher@neusta.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/indexed_search/Classes/Controller/SearchController.php

index 1a07d46..04952bd 100644 (file)
@@ -793,7 +793,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
     }
 
     /**
-     * Write statistics information to database for the search operation
+     * Write statistics information to database for the search operation if there was at least one search word.
      *
      * @param array $searchParams search params
      * @param array $searchWords Search Word array
@@ -802,8 +802,13 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
      */
     protected function writeSearchStat($searchParams, $searchWords, $count, $pt)
     {
+        $searchWord = $this->getSword();
+        if (empty($searchWord) && empty($searchWords)) {
+            return;
+        }
+
         $insertFields = [
-            'searchstring' => $this->getSword(),
+            'searchstring' => $searchWord,
             'searchoptions' => serialize([$searchParams, $searchWords, $pt]),
             'feuser_id' => (int)$GLOBALS['TSFE']->fe_user->user['uid'],
             // cookie as set or retrieved. If people has cookies disabled this will vary all the time