Bug #87695
closedTCA type slug fails on records with sys_language_uid == -1
0%
Description
I found after updating a TYPO3 project and introducing site configs and TCA type slug fields to custom TCA tables for url handling, that in the CMS backend trying to edit records containing a TCA type slug field and having sys_language_uid -1 (All languages) the backend throws an exception:
"(1/1) #1522965188 InvalidArgumentException Language -1 does not exist on site #PSEUDO_2."
So I guess the TCA type slug can't handle sys_language_uid -1 as this can't be a defined language in site config, which can only contain languages with uid > 0.
Stacktrace:
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Site/Entity/NullSite.php line 113
{
if (isset($this->languages[$languageId])) {
return $this->languages[$languageId];
}
throw new \InvalidArgumentException(
'Language ' . $languageId . ' does not exist on site ' . $this->getIdentifier() . '.',
1522965188
);
}
at TYPO3\CMS\Core\Site\Entity\NullSite->getLanguageById(-1)
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Form/Element/InputSlugElement.php line 218
- @return string
*/
protected function getPrefix(SiteInterface $site, int $requestLanguageId = 0): string {
$language = $site->getLanguageById($requestLanguageId);
$base = $language->getBase();
$baseUrl = (string)$base;
$baseUrl = rtrim($baseUrl, '/');
if (!empty($baseUrl) && empty($base->getScheme()) && $base->getHost() !== '') {
at TYPO3\CMS\Backend\Form\Element\InputSlugElement->getPrefix(object(TYPO3\CMS\Core\Site\Entity\PseudoSite), -1)
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Form/Element/InputSlugElement.php line 83
if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && !empty($GLOBALS['TCA'][$table]['ctrl']['languageField'])) {
$languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
$languageId = (int)((is_array($row[$languageField]) ? $row[$languageField][0] : $row[$languageField]) ?? 0);
}
$baseUrl = $this->getPrefix($this->data['site'], $languageId);
$itemValue = $parameterArray['itemFormElValue'];
$config = $parameterArray['fieldConf']['config'];
$evalList = GeneralUtility::trimExplode(',', $config['eval'], true);
at TYPO3\CMS\Backend\Form\Element\InputSlugElement->render()
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Form/Container/SingleFieldContainer.php line 180
} else {
// Fallback to type if no renderType is given
$options['renderType'] = $parameterArray['fieldConf']['config']['type'];
}
$resultArray = $this->nodeFactory->create($options)->render();
return $resultArray;
}
/**
at TYPO3\CMS\Backend\Form\Container\SingleFieldContainer->render()
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Form/Container/PaletteAndSingleContainer.php line 145
$options = $this->data;
$options['fieldName'] = $fieldName;
$options['renderType'] = 'singleFieldContainer';
$childResultArray = $this->nodeFactory->create($options)->render();
if (!empty($childResultArray['html'])) {
$mainStructureCounter++;
$fieldLabel = '';
at TYPO3\CMS\Backend\Form\Container\PaletteAndSingleContainer->render()
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Form/Container/TabsContainer.php line 86
foreach ($elements as $element) {
$options['fieldsArray'][] = implode(';', $element);
}
$options['renderType'] = 'paletteAndSingleContainer';
$childArray = $this->nodeFactory->create($options)->render();
$tabElements[] = [
'label' => $tabWithLabelAndElements['label'],
'content' => $childArray['html'],
at TYPO3\CMS\Backend\Form\Container\TabsContainer->render()
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Form/Container/FullRecordContainer.php line 83
} else {
$data['renderType'] = 'noTabsContainer';
}
return $this->nodeFactory->create($data)->render();
}
/**
* @return LanguageService
at TYPO3\CMS\Backend\Form\Container\FullRecordContainer->render()
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Form/Container/OuterWrapContainer.php line 55
$options['renderType'] = 'fullRecordContainer';
} else {
$options['renderType'] = 'listOfFieldsContainer';
}
$result = $this->nodeFactory->create($options)->render();
$childHtml = $result['html'];
$recordPath = '';
at TYPO3\CMS\Backend\Form\Container\OuterWrapContainer->render()
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Controller/EditDocumentController.php line 1346
}
}
$formData['renderType'] = 'outerWrapContainer';
$formResult = $nodeFactory->create($formData)->render();
$html = $formResult['html'];
$formResult['html'] = '';
at TYPO3\CMS\Backend\Controller\EditDocumentController->makeEditForm()
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Controller/EditDocumentController.php line 1175
if (is_array($this->editconf)) {
$this->formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
// Creating the editing form, wrap it with buttons, document selector etc.
$editForm = $this->makeEditForm();
if ($editForm) {
$this->firstEl = reset($this->elementsData);
// Checking if the currently open document is stored in the list of "open documents" - if not, add it:
if (($this->docDat[1] !== $this->storeUrlMd5 || !isset($this->docHandler[$this->storeUrlMd5]))
at TYPO3\CMS\Backend\Controller\EditDocumentController->main(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Controller/EditDocumentController.php line 537
}
}
$this->init($request);
$this->main($request);
return new HtmlResponse($this->moduleTemplate->renderContent());
}
at TYPO3\CMS\Backend\Controller\EditDocumentController->mainAction(object(TYPO3\CMS\Core\Http\ServerRequest))
at call_user_func_array(array(object(TYPO3\CMS\Backend\Controller\EditDocumentController), 'mainAction'), array(object(TYPO3\CMS\Core\Http\ServerRequest)))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Http/RouteDispatcher.php line 87
$arguments[] = $response;
}
}
return call_user_func_array($target, $arguments);
}
/**
* Wrapper method for static form protection utility
at TYPO3\CMS\Backend\Http\RouteDispatcher->dispatch(object(TYPO3\CMS\Core\Http\ServerRequest), object(TYPO3\CMS\Core\Http\Response))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Http/RequestHandler.php line 73
}
try {
// Check if the router has the available route and dispatch.
$dispatcher = GeneralUtility::makeInstance(RouteDispatcher::class);
return $dispatcher->dispatch($request, $response);
} catch (InvalidRequestTokenException $e) {
// When token was invalid redirect to login
$url = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir;
return new RedirectResponse($url);
at TYPO3\CMS\Backend\Http\RequestHandler->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Middleware/SiteResolver.php line 59
$site = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId($pageId, $rootLine);
$request = $request->withAttribute('site', $site);
$GLOBALS['TYPO3_REQUEST'] = $request;
}
return $handler->handle($request);
}
}
at TYPO3\CMS\Backend\Middleware\SiteResolver->process(object(TYPO3\CMS\Core\Http\ServerRequest), object(TYPO3\CMS\Backend\Http\RequestHandler))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php line 138
if (!$middleware instanceof MiddlewareInterface) {
throw new \InvalidArgumentException(get_class($middleware) . ' does not implement ' . MiddlewareInterface::class, 1516821342);
}
return $middleware->process($request, $this->next);
}
};
}
}
at class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Middleware/AdditionalResponseHeaders.php line 39
- @return ResponseInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
$response = $handler->handle($request);
foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['HTTP']['Response']['Headers'] ?? [] as $header) {
[$headerName, $value] = explode(':', $header, 2);
$response = $response->withAddedHeader($headerName, trim($value));
}
at TYPO3\CMS\Backend\Middleware\AdditionalResponseHeaders->process(object(TYPO3\CMS\Core\Http\ServerRequest), object(class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php line 138
if (!$middleware instanceof MiddlewareInterface) {
throw new \InvalidArgumentException(get_class($middleware) . ' does not implement ' . MiddlewareInterface::class, 1516821342);
}
return $middleware->process($request, $this->next);
}
};
}
}
at class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Middleware/OutputCompression.php line 45
ob_clean();
// Initialize output compression if configured
$this->initializeOutputCompression();
return $handler->handle($request);
}
/**
* Initialize output compression if configured
at TYPO3\CMS\Backend\Middleware\OutputCompression->process(object(TYPO3\CMS\Core\Http\ServerRequest), object(class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php line 138
if (!$middleware instanceof MiddlewareInterface) {
throw new \InvalidArgumentException(get_class($middleware) . ' does not implement ' . MiddlewareInterface::class, 1516821342);
}
return $middleware->process($request, $this->next);
}
};
}
}
at class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Middleware/LegacyBackendTemplateInitialization.php line 42
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$GLOBALS['TBE_TEMPLATE'] = GeneralUtility::makeInstance(DocumentTemplate::class);
return $handler->handle($request);
}
}
at TYPO3\CMS\Backend\Middleware\LegacyBackendTemplateInitialization->process(object(TYPO3\CMS\Core\Http\ServerRequest), object(class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php line 138
if (!$middleware instanceof MiddlewareInterface) {
throw new \InvalidArgumentException(get_class($middleware) . ' does not implement ' . MiddlewareInterface::class, 1516821342);
}
return $middleware->process($request, $this->next);
}
};
}
}
at class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Middleware/BackendUserAuthenticator.php line 70
Bootstrap::initializeLanguageObject();
// Register the backend user as aspect
$this->setBackendUserAspect(GeneralUtility::makeInstance(Context::class), $GLOBALS['BE_USER']);
return $handler->handle($request);
}
/**
* Check if the user is required for the request
at TYPO3\CMS\Backend\Middleware\BackendUserAuthenticator->process(object(TYPO3\CMS\Core\Http\ServerRequest), object(class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php line 138
if (!$middleware instanceof MiddlewareInterface) {
throw new \InvalidArgumentException(get_class($middleware) . ' does not implement ' . MiddlewareInterface::class, 1516821342);
}
return $middleware->process($request, $this->next);
}
};
}
}
at class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Middleware/BackendRouteInitialization.php line 72
// Add the route path to the request
$request = $request->withAttribute('routePath', $pathToRoute);
return $handler->handle($request);
}
}
at TYPO3\CMS\Backend\Middleware\BackendRouteInitialization->process(object(TYPO3\CMS\Core\Http\ServerRequest), object(class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php line 138
if (!$middleware instanceof MiddlewareInterface) {
throw new \InvalidArgumentException(get_class($middleware) . ' does not implement ' . MiddlewareInterface::class, 1516821342);
}
return $middleware->process($request, $this->next);
}
};
}
}
at class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Middleware/ForcedHttpsBackendRedirector.php line 53
list($server, $address) = explode('/', $url, 2);
return new RedirectResponse('https://' . $server . $sslPortSuffix . '/' . $address);
}
return $handler->handle($request);
}
}
at TYPO3\CMS\Backend\Middleware\ForcedHttpsBackendRedirector->process(object(TYPO3\CMS\Core\Http\ServerRequest), object(class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php line 138
if (!$middleware instanceof MiddlewareInterface) {
throw new \InvalidArgumentException(get_class($middleware) . ' does not implement ' . MiddlewareInterface::class, 1516821342);
}
return $middleware->process($request, $this->next);
}
};
}
}
at class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Middleware/LockedBackendGuard.php line 71
$request->getAttribute('normalizedParams')->getRemoteAddress(),
trim((string)$GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])
);
return $handler->handle($request);
}
/**
* Check adminOnly configuration variable and redirects to an URL in file typo3conf/LOCK_BACKEND
at TYPO3\CMS\Backend\Middleware\LockedBackendGuard->process(object(TYPO3\CMS\Core\Http\ServerRequest), object(class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php line 138
if (!$middleware instanceof MiddlewareInterface) {
throw new \InvalidArgumentException(get_class($middleware) . ' does not implement ' . MiddlewareInterface::class, 1516821342);
}
return $middleware->process($request, $this->next);
}
};
}
}
at class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Middleware/NormalizedParamsAttribute.php line 58
// refactored to have ServerRequest object available where it is needed. This global will be
// deprecated then and removed.
$GLOBALS['TYPO3_REQUEST'] = $request;
return $handler->handle($request);
}
}
at TYPO3\CMS\Core\Middleware\NormalizedParamsAttribute->process(object(TYPO3\CMS\Core\Http\ServerRequest), object(class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php line 138
if (!$middleware instanceof MiddlewareInterface) {
throw new \InvalidArgumentException(get_class($middleware) . ' does not implement ' . MiddlewareInterface::class, 1516821342);
}
return $middleware->process($request, $this->next);
}
};
}
}
at class@anonymous/usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php0x7f3ade886056->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php line 67
- @return ResponseInterface
*/
public function handle(ServerRequestInterface $request): ResponseInterface {
return $this->tip->handle($request);
}
/**
* Seed the middleware stack with the inner request handler
at TYPO3\CMS\Core\Http\MiddlewareDispatcher->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/AbstractApplication.php line 98
{
$requestHandler = GeneralUtility::makeInstance($this->requestHandler);
$dispatcher = $this->createMiddlewareDispatcher($requestHandler);
return $dispatcher->handle($request);
}
/**
* Set up the application and shut it down afterwards
at TYPO3\CMS\Core\Http\AbstractApplication->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/backend/Classes/Http/Application.php line 68
return $this->installToolRedirect();
}
// Set up the initial context
$this->initializeContext();
return parent::handle($request);
}
/**
* Check if LocalConfiguration.php and PackageStates.php exist
at TYPO3\CMS\Backend\Http\Application->handle(object(TYPO3\CMS\Core\Http\ServerRequest))
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/sysext/core/Classes/Http/AbstractApplication.php line 110
final public function run(callable $execute = null)
{
try {
$response = $this->handle(
\TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals()
);
if ($execute !== null) {
call_user_func($execute);
}
at TYPO3\CMS\Core\Http\AbstractApplication->run()
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/index.php line 24
// Set up the application for the backend
call_user_func(function () {
$classLoader = require dirname(DIR).'/vendor/autoload.php';
\TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::run(1, \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE);
\TYPO3\CMS\Core\Core\Bootstrap::init($classLoader)->get(\TYPO3\CMS\Backend\Http\Application::class)->run();
});
at {closure}()
in /usr/www/users/stagep/typo3_src-9.5.4/typo3/index.php line 25
call_user_func(function () {
$classLoader = require dirname(DIR).'/vendor/autoload.php';
\TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::run(1, \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE);
\TYPO3\CMS\Core\Core\Bootstrap::init($classLoader)->get(\TYPO3\CMS\Backend\Http\Application::class)->run();
});