From 73637a4d216e7cb9a6882f79d87621d87780dc32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20M=C3=BCller?= <typo3@krue.ml> Date: Fri, 10 Jun 2022 14:08:03 +0200 Subject: [PATCH] [BUGFIX] Throw 404 error when XML sitemap is not available Resolves: #97612 Releases: main, 11.5 Change-Id: Ia23a15f0beb864a8b53c568ed27642ec7ac8c7b2 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74868 Tested-by: core-ci <typo3@b13.com> Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> --- .../seo/Classes/XmlSitemap/XmlSitemapRenderer.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapRenderer.php b/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapRenderer.php index 50780232f1bb..064e1e47391e 100644 --- a/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapRenderer.php +++ b/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapRenderer.php @@ -18,10 +18,12 @@ declare(strict_types=1); namespace TYPO3\CMS\Seo\XmlSitemap; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Http\PropagateResponseException; use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\PathUtility; use TYPO3\CMS\Fluid\View\StandaloneView; +use TYPO3\CMS\Frontend\Controller\ErrorController; use TYPO3\CMS\Seo\XmlSitemap\Exception\InvalidConfigurationException; /** @@ -122,7 +124,7 @@ class XmlSitemapRenderer */ protected function renderSitemap(ServerRequestInterface $request, string $sitemap, string $sitemapType): string { - if (!empty($sitemapConfig = $this->configuration['config'][$sitemapType]['sitemaps'][$sitemap])) { + if (!empty($sitemapConfig = $this->configuration['config'][$sitemapType]['sitemaps'][$sitemap] ?? null)) { if (class_exists($sitemapConfig['provider']) && is_subclass_of($sitemapConfig['provider'], XmlSitemapDataProviderInterface::class)) { /** @var XmlSitemapDataProviderInterface $provider */ @@ -146,7 +148,13 @@ class XmlSitemapRenderer throw new InvalidConfigurationException('No valid provider set for ' . $sitemap, 1535578522); } - throw new InvalidConfigurationException('No valid configuration found for sitemap ' . $sitemap, 1535578569); + throw new PropagateResponseException( + GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( + $request, + 'No valid configuration found for sitemap ' . $sitemap + ), + 1535578569 + ); } protected function getStandaloneView(): StandaloneView -- GitLab