-
Notifications
You must be signed in to change notification settings - Fork 215
Description
I have checked that the bug exists in the dev-development branch
Yes
I have checked that there are no already open issues or recently closed issues about this bug
Yes
Describe the bug
When running referenceindex:update from the console in TYPO3 v13, an error occurs: NoServerRequestGivenException.
However, if you trigger the rebuild via the TYPO3 Backend, it works without any issues.
I have debugged the code and found that the problem is caused by a FluidTYPO3\Flux\Form being instantiated, which in turn tries to access TypoScript. This is not possible in this context – and also not necessary for updating the reference index.
To Reproduce
Steps to reproduce the behavior:
- Run the command:
typo3 referenceindex:update
Expected behavior
The command should run without errors in the terminal.
Especially during CI/CD pipelines, this error causes the process to fail – although it works fine via the backend.
Possible Workaround
As a quick fix, I added a check in the BeforeFlexFormDataStructureParsedEventListener that verifies whether the command is being run via CLI and specifically for referenceindex:update. In that case, the logic for building the Flux form is skipped.
The workaround was only meant as a quick solution – maybe there's a better or more sustainable approach?
<?php
namespace FluidTYPO3\Flux\Integration\Event;
use FluidTYPO3\Flux\Builder\FlexFormBuilder;
use Symfony\Component\Console\Input\ArgvInput;
use TYPO3\CMS\Core\Configuration\Event\BeforeFlexFormDataStructureParsedEvent;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class BeforeFlexFormDataStructureParsedEventListener
{
public function applyFluxFlexFormDataStructure(BeforeFlexFormDataStructureParsedEvent $event): void
{
static $shouldSkip = null;
if ($shouldSkip === null) {
$shouldSkip = false;
if (PHP_SAPI === 'cli') {
$input = new ArgvInput();
$command = $input->getFirstArgument();
if ($command === 'referenceindex:update') {
$shouldSkip = true;
}
}
}
if ($shouldSkip) {
return;
}
/** @var FlexFormBuilder $flexFormBuilder */
$flexFormBuilder = GeneralUtility::makeInstance(FlexFormBuilder::class);
$structure = $flexFormBuilder->parseDataStructureByIdentifier($event->getIdentifier());
if (!empty($structure)) {
$event->setDataStructure($structure);
}
}
}