#110436Uncaught InvalidArgumentException in PageRouter when an MP parameter points to a page without a site
Description
We are seeing HTTP 500s on our site whenever an old URL containing an MP parameter is requested and the mount point page it refers to has since been deleted. I have tried to track down where it comes from — I am not a core developer, so I may well have misread something, but here is what I found in case it helps.
In PageRouter::generateUri() the site of the mount point page is looked up so cross-domain mount point links can be built against the right base:
try {
[, $mountPointPage] = explode('-', (string)reset($mountPointPairs));
$site = GeneralUtility::makeInstance(SiteMatcher::class)
->matchByPageId((int)$mountPointPage);
$language = $site->getLanguageById($language->getLanguageId());
} catch (SiteNotFoundException $e) {
// No alternative site found, use the existing one
}
As far as I can tell, that catch is never reached, because SiteMatcher::matchByPageId() already handles SiteNotFoundException itself and returns a NullSite instead:
public function matchByPageId(int $pageId, ?array $rootLine = null): SiteInterface
{
try {
return $this->finder->getSiteByPageId($pageId, $rootLine);
} catch (SiteNotFoundException) {
return new NullSite();
}
}
NullSite only knows language 0, so the getLanguageById() call on the next line throws \InvalidArgumentException (#1522965188) rather than SiteNotFoundException, and it ends up uncaught.
Steps to reproduce
- A site with at least two configured languages.
- An MP value whose mount point page cannot be resolved to a site. In our case the mount point page had simply been deleted.
- Request any page with that parameter, e.g. /some/page?MP=4290-5974.
- Have something on the page build a link for a language other than 0 — for us it was the language menu, which does this once per configured language.
One thing that surprised me: the requested page does not have to be inside the mounted tree. If the MP value does not apply to it, the root line seems to ignore the parameter and the site resolves fine, so PageLinkBuilder gets a valid site and calls generateUri(), which then parses the MP pair anyway.
Actual result
InvalidArgumentException: Language 1 does not exist on site #NULL.
in typo3/sysext/core/Classes/Site/Entity/NullSite.php:115
#0 typo3/sysext/core/Classes/Routing/PageRouter.php(291): NullSite->getLanguageById()
#1 typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php(573): PageRouter->generateUri()
#2 typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php(198): PageLinkBuilder->generateUrlForPageWithSiteConfiguration()
#3 typo3/sysext/frontend/Classes/Typolink/LinkFactory.php(149): PageLinkBuilder->build()
...
#10 typo3/sysext/frontend/Classes/DataProcessing/LanguageMenuProcessor.php(364): HierarchicalMenuContentObject->render()
The whole request returns a 500.
Expected result
No fatal error. Going by the comment already in the code (“No alternative site found, use the existing one”), I would have expected it to fall back to the current language when the mount point cannot be resolved.
Language 0 is not affected, presumably because that is the one language NullSite provides.
Since old URLs like this can sit in search results or be re-crawled, the 500 keeps coming back on its own, which is what made us look into it.
Possible fix
Locally we are running with the catch widened, which resolved it for us:
- } catch (SiteNotFoundException $e) {
- // No alternative site found, use the existing one
+ } catch (SiteNotFoundException|\InvalidArgumentException $e) {
+ // No alternative site or language found, use the existing one
}
On our installation (13.4.31, six languages) the 500 became a normal 200, and pages using mount points that do resolve correctly rendered identically before and after. That is only our own site though, so I have no idea whether this is the right shape of fix for core.
I did wonder whether checking $site instanceof Site before calling getLanguageById() would be better, but that on its own would not cover a real Site that simply lacks the requested language. Someone who knows this code will have a better view.
Possibly related
- PageLinkBuilder creates broken “translated” Slugs for MountPoints
- Language menu on mount point page does not generate a valid link
Both are about mount point link generation, but I could not find one covering this particular exception. Apologies if I have missed an existing report.
Reviews 2
History 36
-
Maike Kiebele changed assigned to Maike Kiebele <span data-processor="relativetime" data-value="2026-08-12T12:57:37+00:00" > 08/12/26, 12:57 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 95362 status
NewUnder Review <span data-processor="relativetime" data-value="2026-08-18T07:35:42+00:00" > 08/18/26, 07:35 </span> -
Gerrit Code Review pushed patch set 2 for main to change 95362 <span data-processor="relativetime" data-value="2026-09-03T06:49:03+00:00" > 09/03/26, 06:49 </span>
-
Gerrit Code Review pushed patch set 1 for 14.3 to change 95590 <span data-processor="relativetime" data-value="2026-09-03T07:10:34+00:00" > 09/03/26, 07:10 </span>
-
Maike Kiebele commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-09-03T07:40:09+00:00" > 09/03/26, 07:40 </span>Applied in changeset commit:a7dbfc086b60df398aa1ef70f9cb6361647ff1bb.
Did a check for TYPO3 versions 12-main
Using an additional GET param like `?MP=123456789-987654321` returns with HTTP Status 500 as far the site has multiple languages configured.
If no multiple languages are configured, these TYPO3 versions returns with HTTP Status 200, as expected.