Commit c21ccfa3 authored by Chris Müller's avatar Chris Müller Committed by Andreas Fernandez
Browse files

[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/+/74818


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent edada8a0
......@@ -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\Core\Rendering\RenderingContextFactory;
use TYPO3\CMS\Frontend\Controller\ErrorController;
use TYPO3\CMS\Seo\XmlSitemap\Exception\InvalidConfigurationException;
use TYPO3Fluid\Fluid\View\TemplateView;
......@@ -108,7 +110,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 */
......@@ -131,7 +133,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 getXslFilePath(string $sitemapType = null, string $sitemap = null): string
......
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