[BUGFIX] Compatibility for finishers which set content into the response 31/56831/2
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Mon, 30 Apr 2018 16:58:48 +0000 (18:58 +0200)
committerSusanne Moog <susanne.moog@typo3.org>
Fri, 11 May 2018 14:01:14 +0000 (16:01 +0200)
Since #83822 EXT:form makes usage of the controller context
response object which has impacts to the finisher logic which was not
treated by #83822.
Since #84495, finishers with output can return this as string instead
of setting this directly into the response
(which results in a double output).
This patch ensures that existing custom finishers which set the content
into the response, get respected.

Resolves: #84901
Releases: master, 8.7
Change-Id: If98de92e6121283572b9146072ab8f9b7bcace8a
Reviewed-on: https://review.typo3.org/56831
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Riny van Tiggelen <info@online-gamer.nl>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Alessandro <alessandro.filira@pallino.it>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/form/Classes/Domain/Runtime/FormRuntime.php

index 32cad29..740e6d5 100644 (file)
@@ -549,15 +549,22 @@ class FormRuntime implements RootRenderableInterface, \ArrayAccess
         );
 
         $output = '';
+        $originalContent = $this->response->getContent();
+        $this->response->setContent(null);
         foreach ($this->formDefinition->getFinishers() as $finisher) {
             $finisherOutput = $finisher->execute($finisherContext);
             if (is_string($finisherOutput) && !empty($finisherOutput)) {
                 $output .= $finisherOutput;
+            } else {
+                $output .= $this->response->getContent();
+                $this->response->setContent(null);
             }
+
             if ($finisherContext->isCancelled()) {
                 break;
             }
         }
+        $this->response->setContent($originalContent);
 
         return $output;
     }