flux icon indicating copy to clipboard operation
flux copied to clipboard

BUG: FluidTYPO3\Flux\Service\RecordService::isBackendOrPreviewContext() fails when used in command line context

Open gardiner opened this issue 7 months ago • 1 comments

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 cloning pages from a command line command some flux hook eventually calls RecordService::isBackendOrPreviewContext(), which fails. The method itself calls ApplicationType::fromRequest() with the contents from $GLOBALS['TYPO3_REQUEST'], which is null when called from a command line command, causing it to fail with the message: TypeError: TYPO3\CMS\Core\Http\ApplicationType::fromRequest(): Argument #1 ($request) must be of type Psr\Http\Message\ServerRequestInterface, null given.

Relevant stack trace:

Stack trace:
#0 /var/www/html/vendor/fluidtypo3/flux/Classes/Service/RecordService.php(150): TYPO3\CMS\Core\Http\ApplicationType::fromRequest(NULL)
#1 /var/www/html/vendor/fluidtypo3/flux/Classes/Service/RecordService.php(63): FluidTYPO3\Flux\Service\RecordService->isBackendOrPreviewContext()
#2 /var/www/html/vendor/fluidtypo3/flux/Classes/Service/WorkspacesAwareRecordService.php(37): FluidTYPO3\Flux\Service\RecordService->getSingle('pages', '*', 29485)
#3 /var/www/html/vendor/fluidtypo3/flux/Classes/Provider/PageProvider.php(216): FluidTYPO3\Flux\Service\WorkspacesAwareRecordService->getSingle('pages', '*', 29485)
#4 /var/www/html/vendor/fluidtypo3/flux/Classes/Integration/HookSubscribers/DataHandlerSubscriber.php(79): FluidTYPO3\Flux\Provider\PageProvider->postProcessRecord('update', 29485, Array, Object(TYPO3\CMS\Core\DataHandling\DataHandler), Array)
#5 /var/www/html/vendor/typo3/cms-core/Classes/DataHandling/DataHandler.php(777): FluidTYPO3\Flux\Integration\HookSubscribers\DataHandlerSubscriber->processDatamap_afterDatabaseOperations('update', 'pages', 29485, Array, Object(TYPO3\CMS\Core\DataHandling\DataHandler))
#6 /var/www/html/vendor/typo3/cms-core/Classes/DataHandling/DataHandler.php(1169): TYPO3\CMS\Core\DataHandling\DataHandler->hook_processDatamap_afterDatabaseOperations(Array, 'update', 'pages', 29485, Array)
#7 /var/www/html/vendor/typo3/cms-core/Classes/DataHandling/DataHandler.php(3585): TYPO3\CMS\Core\DataHandling\DataHandler->process_datamap()
#8 /var/www/html/packages/tz_site_generator/Classes/Service/Records/DataHandlerService.php(160): TYPO3\CMS\Core\DataHandling\DataHandler->process_cmdmap()

To Reproduce Steps to reproduce the behavior:

  1. Call a typo3/symfony command line command which attempts to clone a page tree
  2. See error

Expected behavior In previous versions (9.x) of Flux the cloning worked without a problem.

Thanks for your help, it is greatly appreciated!

Cheers, Ole.

gardiner avatar Jul 24 '24 11:07 gardiner