Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion Classes/DirectMailUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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']);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Dmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions Classes/Module/StatisticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] : '';
}
Expand Down Expand Up @@ -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 . ')';
}

Expand Down
3 changes: 2 additions & 1 deletion Classes/SelectCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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();
Expand Down
11 changes: 1 addition & 10 deletions Resources/Public/Images/module-directmail.svg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.