diff --git a/Classes/DirectMailUtility.php b/Classes/DirectMailUtility.php
index e15c90b35..41ce47d76 100644
--- a/Classes/DirectMailUtility.php
+++ b/Classes/DirectMailUtility.php
@@ -30,7 +30,10 @@
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
+use TYPO3\CMS\Core\Http\ServerRequestFactory;
+use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
/**
* Static class.
@@ -97,6 +100,22 @@ public static function getTypolinkURL(
$typolinkPageUrl = 't3://page?uid=';
$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
+ // Ensure a PSR-7 request is available for ContentObjectRenderer when running in CLI/Scheduler
+ if (!empty($GLOBALS['TYPO3_REQUEST'])) {
+ $cObj->setRequest($GLOBALS['TYPO3_REQUEST']);
+ } else {
+ try {
+ $requestFactory = GeneralUtility::makeInstance(ServerRequestFactory::class);
+ $request = $requestFactory->fromGlobals();
+ // Provide applicationType so ApplicationType::fromRequest() can detect BE/FE
+ $request = $request->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE);
+ $GLOBALS['TYPO3_REQUEST'] = $request;
+ $cObj->setRequest($request);
+ } catch (\Throwable $e) {
+ // ignore: if we cannot create a request, typolink may still fail later
+ }
+ }
+
return $cObj->typolink_URL([
'parameter' => $typolinkPageUrl . $parameter,
'forceAbsoluteUrl' => $forceAbsoluteUrl,
@@ -301,7 +320,8 @@ protected static function addUserPass(string $url, array $params): string
public static function getFullUrlsForDirectMailRecord(array $row): array
{
// Finding the domain to use
- if (!$_SERVER['HTTP_HOST']) {
+ // Use empty() to avoid "Undefined array key" when running in CLI/Scheduler
+ if (empty($_SERVER['HTTP_HOST'])) {
// In CLI / Scheduler context, $_SERVER['HTTP_HOST'] can be null
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
$site = $siteFinder->getSiteByPageId((int)$row['page']);
diff --git a/Classes/Dmailer.php b/Classes/Dmailer.php
index 9c1e83be1..1b532e14a 100644
--- a/Classes/Dmailer.php
+++ b/Classes/Dmailer.php
@@ -404,7 +404,7 @@ public function sendAdvanced(array $recipientRow, string $tableNameChar): int
// Plain
$this->theParts['plain']['content'] = '';
if ($this->flagPlain) {
- $tempContentPlain = $this->getBoundaryParts($this->dmailer['boundaryParts_plain'], $recipientRow['sys_dmail_categories_list']);
+ $tempContentPlain = $this->getBoundaryParts($this->dmailer['boundaryParts_plain'], $recipientRow['sys_dmail_categories_list'] ?? '');
if ($this->mailHasContent) {
$tempContentPlain = $this->replaceMailMarkers($tempContentPlain, $recipientRow, $additionalMarkers);
if (trim($this->dmailer['sys_dmail_rec']['use_rdct']) || trim($this->dmailer['sys_dmail_rec']['long_link_mode'])) {
@@ -844,7 +844,7 @@ protected function setContent(MailMessage $mailer): void
$this->extractMediaLinks();
foreach ($this->theParts['html']['media'] as $media) {
// TODO: why are there table related tags here?
- if (in_array($media['tag'], ['img', 'table', 'tr', 'td'], true) && !$media['use_jumpurl'] && !$media['do_not_embed']) {
+ if (isset($media['tag']) && in_array($media['tag'], ['img', 'table', 'tr', 'td'], true) && !$media['use_jumpurl'] && !$media['do_not_embed']) {
if (ini_get('allow_url_fopen')) {
$context = GeneralUtility::makeInstance(FetchUtility::class)->getStreamContext();
if (($fp = fopen($media['absRef'], 'r', false, $context)) !== false) {
diff --git a/Classes/Module/StatisticsController.php b/Classes/Module/StatisticsController.php
index 75c23fc6a..85edcc5e7 100644
--- a/Classes/Module/StatisticsController.php
+++ b/Classes/Module/StatisticsController.php
@@ -1574,7 +1574,7 @@ public function getUrlStr(array $urlParts): string
$urlstr .= ($urlParts['fragment'] ?? '') ? '#' . $urlParts['fragment'] : '';
}
} else {
- $urlstr = ((isset($urlParts['host']) && $urlParts['host']) ? $urlParts['scheme'] . '://' . $urlParts['host'] : $baseUrl) . $urlParts['path'];
+ $urlstr = ((isset($urlParts['host']) && $urlParts['host']) ? $urlParts['scheme'] . '://' . $urlParts['host'] : $baseUrl) . ($urlParts['path'] ?? '');
$urlstr .= ($urlParts['query'] ?? '') ? '?' . $urlParts['query'] : '';
$urlstr .= ($urlParts['fragment'] ?? '') ? '#' . $urlParts['fragment'] : '';
}
@@ -1653,11 +1653,11 @@ public function getLinkLabel(
}
- if ($this->implodedParams['showContentTitle'] == 1) {
+ if (isset($this->implodedParams['showContentTitle']) && $this->implodedParams['showContentTitle'] == 1) {
$label = $contentTitle;
}
- if ($this->implodedParams['prependContentTitle'] == 1) {
+ if (isset($this->implodedParams['prependContentTitle']) && $this->implodedParams['prependContentTitle'] == 1) {
$label = $contentTitle . ' (' . $linkedWord . ')';
}
diff --git a/Classes/SelectCategories.php b/Classes/SelectCategories.php
index c24af3f3c..5b298bea4 100644
--- a/Classes/SelectCategories.php
+++ b/Classes/SelectCategories.php
@@ -17,6 +17,7 @@
use DirectMailTeam\DirectMail\Repository\TempRepository;
use TYPO3\CMS\Core\Localization\LanguageService;
+use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
@@ -39,7 +40,7 @@ public function getLocalizedCategories(array &$params): void
$lang = $this->getLang();
$site = $params['site'];
- $languages = $site->getAllLanguages();
+ $languages = ($site instanceof Site) ? $site->getAllLanguages() : [];
foreach($languages as $language) {
if($language->getLocale()->getLanguageCode() == $lang) {
$sysLanguageUid = $language->getLanguageId();
diff --git a/Resources/Public/Images/module-directmail.svg b/Resources/Public/Images/module-directmail.svg
old mode 100755
new mode 100644
index 0f452e7bb..841bcff5a
--- a/Resources/Public/Images/module-directmail.svg
+++ b/Resources/Public/Images/module-directmail.svg
@@ -1,10 +1 @@
-
-
-
-
+