[BUGFIX] Fix Exception caused by empty staticPageArguments 14/63414/2
authorManuel Munz <munz@comuno.net>
Tue, 25 Feb 2020 17:20:13 +0000 (18:20 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Thu, 27 Feb 2020 12:51:49 +0000 (13:51 +0100)
When 'Index Records immediately when saved?' is enabled in indexing
configurations for records, then on saving the record the
string 'null' is used for this indexingconfiguration and passed to
SearchController::preparePageLink(), which expects an array and
therefore throws an exception.

This commit fixes this by checking if
$this->conf['staticPageArguments'] is an array and only then json_decode
that, else it sets the value to null.

Resolves: #89816
Related: #86994
Releases: master, 9.5
Change-Id: I96d3fb963ecb508bc536967afece064ad12bb989
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63414
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/indexed_search/Classes/Indexer.php

index d771bb9..c5bd055 100644 (file)
@@ -1393,7 +1393,7 @@ class Indexer
         $fields = [
             'phash' => $this->hash['phash'],
             'phash_grouping' => $this->hash['phash_grouping'],
-            'static_page_arguments' => json_encode($this->conf['staticPageArguments']),
+            'static_page_arguments' => is_array($this->conf['staticPageArguments']) ? json_encode($this->conf['staticPageArguments']) : null,
             'contentHash' => $this->content_md5h,
             'data_page_id' => $this->conf['id'],
             'data_page_type' => $this->conf['type'],
@@ -2171,7 +2171,7 @@ class Indexer
             'type' => (int)$this->conf['type'],
             'sys_lang' => (int)$this->conf['sys_language_uid'],
             'MP' => (string)$this->conf['MP'],
-            'staticPageArguments' => $this->conf['staticPageArguments'],
+            'staticPageArguments' => is_array($this->conf['staticPageArguments']) ? json_encode($this->conf['staticPageArguments']) : null,
         ];
         // Set grouping hash (Identifies a "page" combined of id, type, language, mountpoint and cHash parameters):
         $this->hash['phash_grouping'] = IndexedSearchUtility::md5inthash(serialize($hArray));