From 847f62f3efb555a7f11d5d7896527fb2bd22f3d5 Mon Sep 17 00:00:00 2001 From: Georg Ringer <georg.ringer@gmail.com> Date: Wed, 11 Jan 2023 08:13:03 +0100 Subject: [PATCH] [BUGFIX] Fix notices in QueryGenerator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: #99511 Releases: main, 11.5 Change-Id: I9657a72e68ac0fea8ee8b0d75fcaa23a3cb4ce8b Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77323 Reviewed-by: Georg Ringer <georg.ringer@gmail.com> Tested-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Tested-by: Georg Ringer <georg.ringer@gmail.com> Reviewed-by: Benni Mack <benni@typo3.org> --- .../Classes/Database/QueryGenerator.php | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/typo3/sysext/lowlevel/Classes/Database/QueryGenerator.php b/typo3/sysext/lowlevel/Classes/Database/QueryGenerator.php index ad70ab7afaa8..4b25d55dfbdd 100644 --- a/typo3/sysext/lowlevel/Classes/Database/QueryGenerator.php +++ b/typo3/sysext/lowlevel/Classes/Database/QueryGenerator.php @@ -586,12 +586,8 @@ class QueryGenerator /** * Add to store query configs - * - * @param array $storeQueryConfigs - * @param int $index - * @return array */ - protected function addToStoreQueryConfigs($storeQueryConfigs, $index) + protected function addToStoreQueryConfigs(array $storeQueryConfigs, int $index): array { $keyArr = explode(',', $this->storeList); $storeQueryConfigs[$index] = []; @@ -630,7 +626,7 @@ class QueryGenerator $languageService = $this->getLanguageService(); $flashMessage = null; $storeArray = $this->initStoreArray(); - $storeQueryConfigs = unserialize($this->settings['storeQueryConfigs'] ?? '', ['allowed_classes' => false]); + $storeQueryConfigs = (array)(unserialize($this->settings['storeQueryConfigs'] ?? '', ['allowed_classes' => false])); $storeControl = GeneralUtility::_GP('storeControl'); $storeIndex = (int)($storeControl['STORE'] ?? 0); $saveStoreArray = 0; @@ -938,7 +934,7 @@ class QueryGenerator } break; case 'check': - if (!$fields['items']) { + if (!($fields['items'] ?? false)) { $fields['type'] = 'boolean'; } else { $fields['type'] = 'binary'; @@ -950,10 +946,10 @@ class QueryGenerator case 'select': case 'category': $fields['type'] = 'multiple'; - if ($fields['foreign_table']) { + if ($fields['foreign_table'] ?? false) { $fields['type'] = 'relation'; } - if ($fields['special']) { + if ($fields['special'] ?? false) { $fields['type'] = 'text'; } break; @@ -1090,7 +1086,7 @@ class QueryGenerator $fieldSetup = $conf; $out = ''; if ($fieldSetup['type'] === 'multiple') { - foreach ($fieldSetup['items'] as $val) { + foreach (($fieldSetup['items'] ?? []) as $val) { $value = $languageService->sL($val[0]); if (GeneralUtility::inList($fieldValue, $val[1]) || $fieldValue == $val[1]) { if ($out !== '') { @@ -1125,7 +1121,7 @@ class QueryGenerator $out .= htmlspecialchars($value); } } - if (str_contains($fieldSetup['allowed'], ',')) { + if (str_contains($fieldSetup['allowed'] ?? '', ',')) { $from_table_Arr = explode(',', $fieldSetup['allowed']); $useTablePrefix = 1; if (!$fieldSetup['prepend_tname']) { @@ -1149,7 +1145,7 @@ class QueryGenerator } } } else { - $from_table_Arr[0] = $fieldSetup['allowed']; + $from_table_Arr[0] = $fieldSetup['allowed'] ?? null; } if (!empty($fieldSetup['prepend_tname'])) { $useTablePrefix = 1; @@ -1754,7 +1750,7 @@ class QueryGenerator if (is_array($conf['inputValue'])) { $conf['inputValue'] = implode(',', $conf['inputValue']); } - $lineHTML[] = '<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $fieldPrefix . '[inputValue]">'; + $lineHTML[] = '<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf['inputValue'] ?? '') . '" name="' . $fieldPrefix . '[inputValue]">'; } elseif ($conf['comparison'] === 64) { if (is_array($conf['inputValue'])) { $conf['inputValue'] = $conf['inputValue'][0]; @@ -1782,10 +1778,10 @@ class QueryGenerator $lineHTML[] = '<div class="col mb-sm-2">'; if ($conf['comparison'] === 37 || $conf['comparison'] === 36) { // between: - $lineHTML[] = '<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $fieldPrefix . '[inputValue]">'; - $lineHTML[] = '<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf['inputValue1']) . '" name="' . $fieldPrefix . '[inputValue1]">'; + $lineHTML[] = '<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf['inputValue'] ?? '') . '" name="' . $fieldPrefix . '[inputValue]">'; + $lineHTML[] = '<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf['inputValue1'] ?? '') . '" name="' . $fieldPrefix . '[inputValue1]">'; } else { - $lineHTML[] = '<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $fieldPrefix . '[inputValue]">'; + $lineHTML[] = '<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf['inputValue'] ?? '') . '" name="' . $fieldPrefix . '[inputValue]">'; } $lineHTML[] = '</div>'; $lineHTML[] = '</div>'; -- GitLab