Commit ce89b4c7 authored by Paul Ilea's avatar Paul Ilea
Browse files

[TASK] Use the first root page uid if pid not set or set to zero

parent d332dc00
......@@ -46,6 +46,7 @@ use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Page\PageRepository;
/**
* MailTemplateService
......@@ -258,13 +259,22 @@ class MailTemplateService {
if (TYPO3_MODE === 'FE') {
/** @var TypoScriptFrontendController $tsfe */
$tsfe = $GLOBALS['TSFE'];
$pageUid = $tsfe->id;
$pageUid = (int) $tsfe->id;
} else {
$pageUid = (int) GeneralUtility::_GP('id');
}
if ($this->pid) {
$pageUid = $this->pid;
$pageUid = (int) $this->pid;
}
if ($pageUid === 0) {
$pageRepository = $this->objectManager->get(PageRepository::class);
$rootPageRows = $pageRepository->getRecordsByField(
'pages', 'is_siteroot', 1, 'hidden = 0', '', 'sorting', 1
);
if ($rootPageRows && \count($rootPageRows)) {
$pageUid = (int) $rootPageRows[0]['uid'];
}
}
$siteRootId = BackendService::getSiteRoot($pageUid);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment