From 320d96828fb7478c3800060bc85240332f95712b Mon Sep 17 00:00:00 2001 From: Igor Neyman Date: Thu, 4 May 2023 14:57:15 +0000 Subject: [PATCH 1/4] fix: warnings in Importer --- Classes/Importer.php | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/Classes/Importer.php b/Classes/Importer.php index 7b5d171ca..409ede503 100644 --- a/Classes/Importer.php +++ b/Classes/Importer.php @@ -211,9 +211,9 @@ public function displayImport(): array } // check if "email" is mapped + $error = []; if (isset($stepCurrent) && $stepCurrent === 'startImport') { $map = $this->indata['map']; - $error = []; // check noMap $newMap = ArrayUtility::removeArrayEntryByValue(array_unique($map), 'noMap'); if (empty($newMap)) { @@ -227,6 +227,9 @@ public function displayImport(): array } $out = ''; + if(!isset($stepCurrent)) { + $stepCurrent = ''; + } switch ($stepCurrent) { case 'conf': $output['conf']['show'] = true; @@ -269,7 +272,7 @@ public function displayImport(): array ['val' =>'name', 'text' => 'name'], ]; - $output['conf']['disableInput'] = $this->params['inputDisable'] == 1 ? true : false; + $output['conf']['disableInput'] = ($this->params['inputDisable'] ?? 0) == 1 ? true : false; // show configuration $output['subtitle'] = $this->getLanguageService()->getLL('mailgroup_import_header_conf'); @@ -279,10 +282,10 @@ public function displayImport(): array $output['conf']['storageSelected'] = $this->indata['storage'] ?? ''; // remove existing option - $output['conf']['remove_existing'] = !$this->indata['remove_existing'] ? false : true; + $output['conf']['remove_existing'] = !($this->indata['remove_existing'] ?? false) ? false : true; // first line in csv is to be ignored - $output['conf']['first_fieldname'] = !$this->indata['first_fieldname'] ? false : true; + $output['conf']['first_fieldname'] = !($this->indata['first_fieldname'] ?? false) ? false : true; // csv separator $output['conf']['delimiter'] = $optDelimiter; @@ -293,13 +296,13 @@ public function displayImport(): array $output['conf']['encapsulationSelected'] = $this->indata['encapsulation'] ?? ''; // import only valid email - $output['conf']['valid_email'] = !$this->indata['valid_email'] ? false : true; + $output['conf']['valid_email'] = !($this->indata['valid_email'] ?? false) ? false : true; // only import distinct records - $output['conf']['remove_dublette'] = !$this->indata['remove_dublette'] ? false : true; + $output['conf']['remove_dublette'] = !($this->indata['remove_dublette'] ?? false) ? false : true; // update the record instead renaming the new one - $output['conf']['update_unique'] = !$this->indata['update_unique'] ? false : true; + $output['conf']['update_unique'] = !($this->indata['update_unique'] ?? false) ? false : true; // which field should be use to show uniqueness of the records $output['conf']['record_unique'] = $optUnique; @@ -320,7 +323,7 @@ public function displayImport(): array $output['mapping']['remove_dublette'] = $this->indata['remove_dublette']; $output['mapping']['update_unique'] = $this->indata['update_unique']; $output['mapping']['record_unique'] = $this->indata['record_unique']; - $output['mapping']['all_html'] = !$this->indata['all_html'] ? false : true; + $output['mapping']['all_html'] = !($this->indata['all_html'] ?? false) ? false : true; $output['mapping']['error'] = $error; // show charset selector @@ -386,7 +389,7 @@ public function displayImport(): array $output['mapping']['table'][] = [ 'mapping_description' => $csv_firstRow[$i], 'mapping_i' => $i, - 'mapping_mappingSelected' => $this->indata['map'][$i], + 'mapping_mappingSelected' => $this->indata['map'][$i] ?? '', 'mapping_value' => $exampleLines, ]; } @@ -427,8 +430,8 @@ public function displayImport(): array $output['startImport']['remove_dublette'] = $this->indata['remove_dublette']; $output['startImport']['update_unique'] = $this->indata['update_unique']; $output['startImport']['record_unique'] = $this->indata['record_unique']; - $output['startImport']['all_html'] = !$this->indata['all_html'] ? false : true; - $output['startImport']['add_cat'] = $this->indata['add_cat'] ? true : false; + $output['startImport']['all_html'] = !($this->indata['all_html'] ?? false) ? false : true; + $output['startImport']['add_cat'] = ($this->indata['add_cat'] ?? false) ? true : false; $output['startImport']['error'] = $error; @@ -454,7 +457,7 @@ public function displayImport(): array foreach ($endOrder as $order) { $rowsTable = []; - if (is_array($result[$order])) { + if (is_array($result[$order] ?? false)) { foreach ($result[$order] as $v) { $mapKeys = array_keys($v); $rowsTable[] = [ @@ -471,12 +474,12 @@ public function displayImport(): array } // back button - if (is_array($this->indata['map'])) { + if (is_array($this->indata['map'] ?? false)) { foreach ($this->indata['map'] as $fieldNr => $fieldMapped) { $output['startImport']['hiddenMap'][] = ['name' => htmlspecialchars('CSV_IMPORT[map][' . $fieldNr . ']'), 'value' => htmlspecialchars($fieldMapped)]; } } - if (is_array($this->indata['cat'])) { + if (is_array($this->indata['cat'] ?? false)) { foreach ($this->indata['cat'] as $k => $catUid) { $output['startImport']['hiddenCat'][] = ['name' => htmlspecialchars('CSV_IMPORT[cat][' . $k . ']'), 'value' => htmlspecialchars($catUid)]; } @@ -487,8 +490,7 @@ public function displayImport(): array default: // show upload file form $output['subtitle'] = $this->getLanguageService()->getLL('mailgroup_import_header_upload'); - - if (($this->indata['mode'] === 'file') && !(((strpos($currentFileInfo['file'], 'import') === false) ? 0 : 1) && ($currentFileInfo['realFileext'] === 'txt'))) { + if ((($this->indata['mode'] ?? '') === 'file') && !(((strpos($currentFileInfo['file'], 'import') === false) ? 0 : 1) && ($currentFileInfo['realFileext'] === 'txt'))) { $output['upload']['current'] = true; $file = $this->getFileById((int)$this->indata['newFileUid']); if (is_object($file)) { @@ -510,8 +512,8 @@ public function displayImport(): array $output['upload']['csv'] = htmlspecialchars($this->indata['csv'] ?? ''); $output['upload']['target'] = htmlspecialchars($this->userTempFolder()); $output['upload']['target_disabled'] = GeneralUtility::_POST('importNow') ? 'disabled' : ''; - $output['upload']['newFile'] = $this->indata['newFile']; - $output['upload']['newFileUid'] = $this->indata['newFileUid']; + $output['upload']['newFile'] = $this->indata['newFile'] ?? ''; + $output['upload']['newFileUid'] = $this->indata['newFileUid'] ?? 0; } $output['title'] = $this->getLanguageService()->getLL('mailgroup_import') . BackendUtility::cshItem($this->cshTable ?? '', 'mailgroup_import'); @@ -726,7 +728,7 @@ public function doImport(array $csvData): array * Hook for doImport Mail * will be called every time a record is inserted */ - if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['doImport'])) { + if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['doImport'] ?? false)) { $hookObjectsArr = []; foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['doImport'] as $classRef) { $hookObjectsArr[] = GeneralUtility::makeInstance($classRef); @@ -756,7 +758,7 @@ public function addDataArray(array &$data, $id, array $dataArray): void if ($this->indata['all_html']) { $data['tt_address'][$id]['module_sys_dmail_html'] = $this->indata['all_html']; } - if (is_array($this->indata['cat']) && !in_array('cats', $this->indata['map'])) { + if (is_array($this->indata['cat'] ?? false) && !in_array('cats', $this->indata['map'])) { foreach ($this->indata['cat'] as $k => $v) { $data['tt_address'][$id]['module_sys_dmail_category'][$k] = $v; } From a4922dd802c2b9c434fafafa71c8b62d0b0a89dc Mon Sep 17 00:00:00 2001 From: Igor Neyman Date: Thu, 8 Jun 2023 12:37:44 +0000 Subject: [PATCH 2/4] fix: warning for base64_decode --- Classes/Middleware/JumpurlController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Middleware/JumpurlController.php b/Classes/Middleware/JumpurlController.php index 64fb82d70..ec041dabe 100644 --- a/Classes/Middleware/JumpurlController.php +++ b/Classes/Middleware/JumpurlController.php @@ -187,7 +187,7 @@ protected function getTargetUrl(int $targetIndex): ?string if (!empty($this->directMailRecord)) { $mailContent = unserialize( - base64_decode($this->directMailRecord['mailContent']), + base64_decode((string)$this->directMailRecord['mailContent']), ['allowed_classes' => false] ); if ($targetIndex >= 0) { From 6a06b250cdc282c5851dfc4b403882d66f8eabfa Mon Sep 17 00:00:00 2001 From: Igor Neyman Date: Thu, 8 Jun 2023 12:50:15 +0000 Subject: [PATCH 3/4] fix: php warnings in JumpurlController --- Classes/Middleware/JumpurlController.php | 29 +++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Classes/Middleware/JumpurlController.php b/Classes/Middleware/JumpurlController.php index ec041dabe..088e8e4cc 100644 --- a/Classes/Middleware/JumpurlController.php +++ b/Classes/Middleware/JumpurlController.php @@ -86,8 +86,8 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface if ($this->shouldProcess()) { $mailId = (int)$this->request->getQueryParams()['mid']; $submittedRecipient = isset($this->request->getQueryParams()['rid']) ? (string)$this->request->getQueryParams()['rid'] : ''; - $submittedAuthCode = $this->request->getQueryParams()['aC']; - $jumpurl = $this->request->getQueryParams()['jumpurl']; + $submittedAuthCode = $this->request->getQueryParams()['aC'] ?? ''; + $jumpurl = $this->request->getQueryParams()['jumpurl'] ?? ''; $urlId = 0; if (MathUtility::canBeInterpretedAsInteger($jumpurl)) { @@ -179,25 +179,28 @@ protected function initDirectMailRecord(int $mailId): void * Fetches the target url from the direct mail record * * @param int $targetIndex - * @return string|null + * @return string */ - protected function getTargetUrl(int $targetIndex): ?string + protected function getTargetUrl(int $targetIndex): string { - $targetUrl = null; + $targetUrl = ''; if (!empty($this->directMailRecord)) { $mailContent = unserialize( base64_decode((string)$this->directMailRecord['mailContent']), ['allowed_classes' => false] ); - if ($targetIndex >= 0) { - // Link (number) - $this->responseType = self::RESPONSE_TYPE_HREF; - $targetUrl = $mailContent['html']['hrefs'][$targetIndex]['absRef']; - } else { - // Link (number, plaintext) - $this->responseType = self::RESPONSE_TYPE_PLAIN; - $targetUrl = $mailContent['plain']['link_ids'][abs($targetIndex)]; + + if(is_array($mailContent)) { + if ($targetIndex >= 0) { + // Link (number) + $this->responseType = self::RESPONSE_TYPE_HREF; + $targetUrl = $mailContent['html']['hrefs'][$targetIndex]['absRef']; + } else { + // Link (number, plaintext) + $this->responseType = self::RESPONSE_TYPE_PLAIN; + $targetUrl = $mailContent['plain']['link_ids'][abs($targetIndex)]; + } } $targetUrl = htmlspecialchars_decode(urldecode($targetUrl)); } From 69fdbcd1919ddf668c47d67fd45054f05d4d23fe Mon Sep 17 00:00:00 2001 From: Igor Neyman Date: Thu, 8 Jun 2023 12:52:46 +0000 Subject: [PATCH 4/4] docs: raise version --- ext_emconf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext_emconf.php b/ext_emconf.php index 7b764e121..fc34f3a44 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -9,7 +9,7 @@ 'author_company' => 'd.k.d Internet Service GmbH', 'state' => 'stable', 'clearcacheonload' => 0, - 'version' => '9.3.0', + 'version' => '9.4.0', 'constraints' => [ 'depends' => [ 'typo3' => '11.5.0-11.99.99',