Skip to content

Commit

Permalink
[BUGFIX] Store record after truncating flexform
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Mar 4, 2015
1 parent 53356c8 commit 57fd59f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Classes/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ public function preProcessRecord(array &$row, $id, DataHandler $reference) {
public function postProcessRecord($operation, $id, array &$row, DataHandler $reference, array $removals = array()) {
if ('update' === $operation) {
$record = $reference->datamap[$this->tableName][$id];
$stored = $this->recordService->getSingle($this->tableName, '*', $id);
$fieldName = $this->getFieldName((array) $record);
$dontProcess = (
NULL === $fieldName
Expand All @@ -536,8 +537,9 @@ public function postProcessRecord($operation, $id, array &$row, DataHandler $ref
}
}
}
$row[$fieldName] = MiscellaneousUtility::cleanFlexFormXml($row[$fieldName], $removals);
$row[$fieldName] = $stored[$fieldName] = MiscellaneousUtility::cleanFlexFormXml($row[$fieldName], $removals);
$reference->datamap[$this->tableName][$id][$fieldName] = $row[$fieldName];
$this->recordService->update($this->tableName, $stored);
}
}

Expand Down Expand Up @@ -803,7 +805,7 @@ protected function loadRecordFromDatabase($uid) {
* @return void
*/
public function trackMethodCall($methodName, $id) {
self::trackMethodCallWithClassName(get_class($this), $methodName, $id);
self::trackMethodCallWithClassName(get_called_class(), $methodName, $id);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions Tests/Unit/Provider/AbstractProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ protected function getBasicRecord() {
public function prunesEmptyFieldNodesOnRecordSave() {
$row = Records::$contentRecordWithoutParentAndWithoutChildren;
$row['pi_flexform'] = Xml::EXPECTING_FLUX_PRUNING;
$recordService = $this->getMock('FluidTYPO3\\Flux\\Service\\WorkspacesAwareRecordService', array('getSingle', 'update'));
$recordService->expects($this->once())->method('getSingle')->willReturn($row);
$recordService->expects($this->once())->method('update');
$provider = $this->getConfigurationProviderInstance();
$provider->setFieldName('pi_flexform');
$provider->setTableName('tt_content');
$provider->injectRecordService($recordService);
$tceMain = GeneralUtility::makeInstance('TYPO3\CMS\Core\DataHandling\DataHandler');
$tceMain->datamap['tt_content'][$row['uid']]['pi_flexform']['data'] = array();
$provider->postProcessRecord('update', $row['uid'], $row, $tceMain);
Expand Down Expand Up @@ -349,6 +353,10 @@ public function canPostProcessDataStructureWithManualFormInstance() {
*/
public function canPostProcessRecord() {
$provider = $this->getConfigurationProviderInstance();
$recordService = $this->getMock('FluidTYPO3\\Flux\\Service\\WorkspacesAwareRecordService', array('getSingle', 'update'));
$recordService->expects($this->once())->method('getSingle')->willReturn($row);
$recordService->expects($this->once())->method('update');
$provider->injectRecordService($recordService);
$record = $this->getBasicRecord();
$parentInstance = GeneralUtility::makeInstance('TYPO3\CMS\Core\DataHandling\DataHandler');
$record['test'] = 'test';
Expand Down Expand Up @@ -389,6 +397,9 @@ public function canPostProcessRecord() {
*/
public function canPostProcessRecordWithNullFieldName() {
$provider = $this->getConfigurationProviderInstance();
$recordService = $this->getMock('FluidTYPO3\\Flux\\Service\\WorkspacesAwareRecordService', array('getSingle'));
$recordService->expects($this->any())->method('getSingle')->willReturn($row);
$provider->injectRecordService($recordService);
$record = $this->getBasicRecord();
$parentInstance = GeneralUtility::makeInstance('TYPO3\CMS\Core\DataHandling\DataHandler');
$record['test'] = 'test';
Expand Down

0 comments on commit 57fd59f

Please sign in to comment.