diff --git a/Classes/Controller/AdminModuleController.php b/Classes/Controller/AdminModuleController.php index 638b915..cda36e3 100644 --- a/Classes/Controller/AdminModuleController.php +++ b/Classes/Controller/AdminModuleController.php @@ -112,21 +112,24 @@ protected function debugAction( ServerRequestInterface $request, ModuleTemplate $view, ): ResponseInterface { - $cmd = $request->getParsedBody()['tx_examples_admin_examples']['cmd'] ?? 'cookies'; - switch ($cmd) { - case 'cookies': - $this->debugCookies(); - break; - default: - // do something else + $body = $request->getParsedBody(); + if (is_array($body)) { + $cmd = $body['tx_examples_admin_examples']['cmd'] ?? 'cookies'; + switch ($cmd) { + case 'cookies': + $this->debugCookies(); + break; + default: + // do something else + } + + $view->assignMultiple( + [ + 'cookies' => $request->getCookieParams(), + 'lastcommand' => $cmd, + ], + ); } - - $view->assignMultiple( - [ - 'cookies' => $request->getCookieParams(), - 'lastcommand' => $cmd, - ], - ); return $view->renderResponse('AdminModule/Debug'); } diff --git a/Classes/Controller/ModuleController.php b/Classes/Controller/ModuleController.php index 33918ff..bb7eba5 100644 --- a/Classes/Controller/ModuleController.php +++ b/Classes/Controller/ModuleController.php @@ -63,7 +63,6 @@ public function __construct( protected readonly ResourceFactory $resourceFactory, protected readonly FileRepository $fileRepository, protected readonly ConnectionPool $connectionPool, - protected readonly DataHandler $dataHandler, protected readonly TableInformationService $tableInformationService, private readonly LoggerInterface $logger, ) {} @@ -458,10 +457,15 @@ public function fileReferenceCreateAction( 'image' => $newId, // For multiple new references $newId is a comma-separated list ]; // process the data - $this->dataHandler->start($data, []); - $this->dataHandler->process_datamap(); + + /** @var DataHandler $dataHandler */ + // Do not inject or reuse the DataHander as it holds state! + // Do not use `new` as GeneralUtility::makeInstance handles dependencies + $dataHandler = GeneralUtility::makeInstance(DataHandler::class); + $dataHandler->start($data, []); + $dataHandler->process_datamap(); // Error or success reporting - if (count($this->dataHandler->errorLog) === 0) { + if (count($dataHandler->errorLog) === 0) { $this->addFlashMessage( LocalizationUtility::translate( 'create_relation_success', @@ -470,7 +474,7 @@ public function fileReferenceCreateAction( '', ); } else { - foreach ($this->dataHandler->errorLog as $log) { + foreach ($dataHandler->errorLog as $log) { $this->addFlashMessage( $log, LocalizationUtility::translate(