[BUGFIX] Remove double encoding of dataStructureIdentifier 55/58855/5
authorStefan Froemken <froemken@gmail.com>
Tue, 6 Nov 2018 11:18:02 +0000 (12:18 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Thu, 8 Nov 2018 19:44:16 +0000 (20:44 +0100)
As dataStructureIdentifier of FlexForms will be transferred
as JSON-encoded string, there is no need to call "json_encode"
again on that string.

Resolves: #86864
Releases: master
Change-Id: I813c9297a8dae24ae584a3606831a8fda5642df9
Reviewed-on: https://review.typo3.org/58855
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/backend/Classes/Controller/Wizard/SuggestWizardController.php
typo3/sysext/backend/Tests/Unit/Controller/Wizard/SuggestWizardControllerTest.php

index 9b9e6f9..572dfe8 100644 (file)
@@ -48,7 +48,7 @@ class SuggestWizardController
         $pid = isset($parsedBody['pid']) ? (int)$parsedBody['pid'] : 0;
         $dataStructureIdentifier = '' ?? null;
         if (!empty($parsedBody['dataStructureIdentifier'])) {
-            $dataStructureIdentifier = json_encode($parsedBody['dataStructureIdentifier']);
+            $dataStructureIdentifier = $parsedBody['dataStructureIdentifier'];
         }
         $flexFormSheetName = $parsedBody['flexFormSheetName'] ?? null;
         $flexFormFieldName = $parsedBody['flexFormFieldName'] ?? null;
index 0d9ff4d..60a305e 100644 (file)
@@ -31,6 +31,7 @@ class SuggestWizardControllerTest extends UnitTestCase
      */
     public function getFlexFieldConfigurationThrowsExceptionIfSimpleFlexFieldIsNotFound(): void
     {
+        $dataStructureIdentifier = '{"type":"tca","tableName":"tt_content","fieldName":"pi_flexform","dataStructureKey":"blog_example,list"}';
         $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);
         $serverRequestProphecy->getParsedBody()->willReturn([
             'value' => 'theSearchValue',
@@ -38,7 +39,7 @@ class SuggestWizardControllerTest extends UnitTestCase
             'field' => 'aField',
             'uid' => 'aUid',
             'pid' => 'aPid',
-            'dataStructureIdentifier' => ['anIdentifier'],
+            'dataStructureIdentifier' => $dataStructureIdentifier,
             'flexFormSheetName' => 'sDb',
             'flexFormFieldName' => 'aField',
             'flexFormContainerName' => '',
@@ -64,7 +65,7 @@ class SuggestWizardControllerTest extends UnitTestCase
         ];
         $flexFormToolsProphecy = $this->prophesize(FlexFormTools::class);
         GeneralUtility::addInstance(FlexFormTools::class, $flexFormToolsProphecy->reveal());
-        $flexFormToolsProphecy->parseDataStructureByIdentifier(json_encode(['anIdentifier']))->willReturn($dataStructure);
+        $flexFormToolsProphecy->parseDataStructureByIdentifier($dataStructureIdentifier)->willReturn($dataStructure);
 
         $this->expectException(\RuntimeException::class);
         $this->expectExceptionCode(1480609491);
@@ -76,6 +77,7 @@ class SuggestWizardControllerTest extends UnitTestCase
      */
     public function getFlexFieldConfigurationThrowsExceptionIfSectionContainerFlexFieldIsNotFound(): void
     {
+        $dataStructureIdentifier = '{"type":"tca","tableName":"tt_content","fieldName":"pi_flexform","dataStructureKey":"blog_example,list"}';
         $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);
         $serverRequestProphecy->getParsedBody()->willReturn([
             'value' => 'theSearchValue',
@@ -83,7 +85,7 @@ class SuggestWizardControllerTest extends UnitTestCase
             'field' => 'aField',
             'uid' => 'aUid',
             'pid' => 'aPid',
-            'dataStructureIdentifier' => ['anIdentifier'],
+            'dataStructureIdentifier' => $dataStructureIdentifier,
             'flexFormSheetName' => 'sDb',
             'flexFormFieldName' => 'aField',
             'flexFormContainerName' => 'aContainer',
@@ -109,7 +111,7 @@ class SuggestWizardControllerTest extends UnitTestCase
         ];
         $flexFormToolsProphecy = $this->prophesize(FlexFormTools::class);
         GeneralUtility::addInstance(FlexFormTools::class, $flexFormToolsProphecy->reveal());
-        $flexFormToolsProphecy->parseDataStructureByIdentifier(json_encode(['anIdentifier']))->willReturn($dataStructure);
+        $flexFormToolsProphecy->parseDataStructureByIdentifier($dataStructureIdentifier)->willReturn($dataStructure);
 
         $this->expectException(\RuntimeException::class);
         $this->expectExceptionCode(1480611208);