Skip to content

Commit

Permalink
[BUGFIX] Fix unintentional overwrite of FlexForm DS
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed May 2, 2022
1 parent 79a03f8 commit 31a4c16
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
10 changes: 4 additions & 6 deletions Classes/Integration/HookSubscribers/DynamicFlexForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
*/
class DynamicFlexForm extends FlexFormTools
{
private const DUMMY_SOURCE = ['sheets' => ['lDEF' => ['ROOT' => ['type' => 'array', 'el' => []]]]];

/**
* @var ObjectManagerInterface
*/
Expand Down Expand Up @@ -125,7 +123,7 @@ public function getDataStructureIdentifierPreProcess(array $tca, $tableName, $fi
}
$provider = $this->configurationService->resolvePrimaryConfigurationProvider($tableName, $fieldName, $record);
if (!$provider) {
return static::DUMMY_SOURCE;
return [];
}
static::$recursed = true;
$identifier = [
Expand All @@ -151,11 +149,11 @@ public function getDataStructureIdentifierPreProcess(array $tca, $tableName, $fi
public function parseDataStructureByIdentifierPreProcess(array $identifier)
{
if ($identifier['type'] !== 'flux') {
return static::DUMMY_SOURCE;
return [];
}
$record = $identifier['record'];
if (!$record) {
return static::DUMMY_SOURCE;
return [];
}

$fromCache = $this->configurationService->getFromCaches($identifier);
Expand All @@ -167,7 +165,7 @@ public function parseDataStructureByIdentifierPreProcess(array $identifier)
$record = BackendUtility::getRecord($identifier['tableName'], $record['uid'], '*', '', false);
}
$fieldName = $identifier['fieldName'];
$dataStructArray = $this->parseDataStructureByIdentifier($identifier['originalIdentifier']);
$dataStructArray = [];
$provider = $this->configurationService->resolvePrimaryConfigurationProvider(
$identifier['tableName'],
$fieldName,
Expand Down
12 changes: 1 addition & 11 deletions Classes/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -773,19 +773,9 @@ public function postProcessCommand($command, $id, array &$row, &$relativeTo, Dat
*/
public function postProcessDataStructure(array &$row, &$dataStructure, array $conf)
{
$defaultDataStructure = ['sheets' => ['lDEF' => ['ROOT' => ['type' => 'array', 'el' => ['xmlTitle' => ['TCEforms' => ['label' => 'The Title:', 'config' => ['type' => 'input', 'size' => '48']]]]]]]];
$form = $this->getForm($row);
if (null !== $form) {
$newDataStructure = $form->build();
if ($dataStructure === $defaultDataStructure) {
$dataStructure = $newDataStructure;
} elseif (count($form->getFields()) > 0) {
if ($newDataStructure !== ['meta' => ['langDisable' => 1, 'langChildren' => 0], 'ROOT' => ['type' => 'array', 'el' => []]]) {
$dataStructure = array_replace_recursive($dataStructure, $newDataStructure);
} else {
$dataStructure = $newDataStructure;
}
}
$dataStructure = array_replace_recursive($dataStructure, $form->build());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testReturnsEmptyDataStructureIdentifierForNonMatchingTableAndFie
{
$subject = $this->objectManager->get(DynamicFlexForm::class);
$result = $subject->getDataStructureIdentifierPreProcess(['foo' => 'bar'], 'sometable', 'somefield', ['uid' => 123]);
$this->assertSame(['sheets' => ['lDEF' => ['ROOT' => ['type' => 'array', 'el' => []]]]], $result);
$this->assertSame([], $result);
}

/**
Expand All @@ -34,7 +34,7 @@ public function testReturnsEmptyDataStructureForIdentifier(array $identifier)
{
$subject = $this->objectManager->get(DynamicFlexForm::class);
$result = $subject->parseDataStructureByIdentifierPreProcess($identifier);
$this->assertSame(['sheets' => ['lDEF' => ['ROOT' => ['type' => 'array', 'el' => []]]]], $result);
$this->assertSame([], $result);
}

/**
Expand Down

0 comments on commit 31a4c16

Please sign in to comment.