Bug #94537
closedPage could not be resolved if page slug ending in index and using PageSuffix RouteEnhancer to add .php suffix to all pages of a site.
100%
Description
There is a weired behaviour (bug?) in resolving a page, if a PageSuffix RouteEnhancer is used to add .php to all
pages for typeNum 0.
I could reproduce this on a new Install with v9 and v10 (see below), 11.2 failed because of error in installer, and master not tried yet.
But i have checked the code in the Master, the code-block which generates this behaviour/bug is still (nearly) the same, and so should behave
the same way. (Eventually someone with master running can confirm this).
I debugged the TYPO3\CMS\Frontend\MiddlewarePageResolver
$pageArguments = $site->getRouter()->matchRequest($request, $previousResult);
or better to say the matchRequest() method from the TYPO3\CMS\Core\Routing\PageRouter
if (!empty($urlPath)) {
$normalizedParams = $request->getAttribute('normalizedParams');
if ($normalizedParams instanceof NormalizedParams) {
$scriptName = ltrim($normalizedParams->getScriptName(), '/');
if ($scriptName !== '' && strpos($urlPath, $scriptName) !== false) {
$urlPath = str_replace($scriptName, '', $urlPath);
}
}
}
Here, the scriptName ( /index.php ) would be replaced with '', which will convert the called uri
/features-index.php to /features-
which generates a uri/id/slug is not the wanted page (given is a page with a set slug to /features-index). And as long as no page with the slug (/features-) exists (which should not be because of the tailing -), it throughs and page not found error (404).
I would call this a bug - or was this done intentionally ??
Can someone reproduce this and can we talk if this need some fixing ? It only occurs in the combination with the ".php" PageSuffix.
Calling '/features-index' will resolve the page just fine.
So, doing the replace in this manner:
if (!empty($urlPath)) {
$normalizedParams = $request->getAttribute('normalizedParams');
if ($normalizedParams instanceof NormalizedParams) {
$scriptName = ltrim($normalizedParams->getScriptName(), '/');
if ($scriptName !== '' && strpos($urlPath, $scriptName) !== false) {
$urlPath = str_replace('/'.$scriptName, '', $urlPath);
}
}
}
It works in my case (real project) and the test installations done to verify this behaviour/issue.
So, can someone who is into this give his opinion ? How to fix it ?
If this is intentionally, then there should be some hints for editors and so on or something like this.
v9
--
- Created new project using composer and the introduction package
- Create new Siteconfig for Rootpage
- add PageSuffix RouteEnhancer to generated site-config:
routeEnhancers:
PageTypeSuffix:
type: PageType
default: .php
index: index
map: { }
- change in the page settings the slug for the feature page (PID: 81) to '/features-index' (save & close )
- click the "view" button on the page header
=> in a new tab http(s)://projectdomain/features-index.php is calles
error: Page Not Found (404)
v10
---
- Created new project using composer and the introduction package
- add PageSuffix RouteEnhancer to generated site-config:
routeEnhancers:
PageTypeSuffix:
type: PageType
default: .php
index: index
map: { }
- change in the page settings the slug for the feature page (PID: 80) to '/features-index' (save & close )
- click the "view" button on the page header
=> in a new tab http(s)://projectdomain/features-index.php is calles
> error: Page Not Found (404)
v11.2
-----
Could not get in running because of error in the install tool for createing admin user
- ajay request: Fatal error: Class TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream may not inherit from final class (GuzzleHttp\Psr7\LazyOpenStream) in /var/www/work/typo3-play/t3v11/public/typo3/sysext/core/Classes/Http/SelfEmittableLazyOpenStream.php on line 29,
v11 master
----------
not tried yet