FluidTYPO3 / flux

TYPO3 extension Flux: Dynamic Fluid FlexForms
https://fluidtypo3.org
146 stars 212 forks source link

[BUGFIX] prevent exception on command line caused by undefined HTTP Host #2136

Open bahammes opened 1 year ago

bahammes commented 1 year ago

Setting TYPO3_PATH_ROOT does not resolve the problem for me, it is also already set correctly by TYPO3.

The cause of the problem is missing HTTP_HOST in $_SERVER on the command line. If you look at \TYPO3\CMS\Core\Http\NormalizedParams::determineSiteUrl, the parameter $requestDir is not a server directory, but the request host with the script path appended.

On the command line (and also in the backend context) the server params are not passed to the newly created ServerRequest instance in \FluidTYPO3\Flux\Builder\RequestBuilder::getServerRequest, so the HTTP host is always empty.

In TYPO3 >= 11.x a cast to string was added in \TYPO3\CMS\Core\Http\NormalizedParams::determineSiteUrl so the exception cannot occur there any more.

My suggested solution for this would be to add fallback handling in case the HTTP host is empty: first check if any site contains a full host name as the base if no host name is found, set a dummy host as a last resort for TYPO3 10.4 only. Since this is only used for the temporary Request object in \FluidTYPO3\Flux\Integration\Configuration\SpooledConfigurationApplicator::spoolQueuedContentTypeRegistrations, this should have no effect on anything outside of EXT:flux.