diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index 6914a61081ef539d8ac7c143a598024b6eb9c826..da685056c68470b4a6fee606e6135a790ae56acc 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -180,6 +180,39 @@ class BackendUtility return $row; } + /** + * Purges computed properties starting with underscore character ('_'). + * + * @param array $record + * @return array + */ + public static function purgeComputedPropertiesFromRecord(array $record): array + { + return array_filter( + $record, + function (string $propertyName): bool { + return $propertyName[0] !== '_'; + }, + ARRAY_FILTER_USE_KEY + ); + } + + /** + * Purges computed property names starting with underscore character ('_'). + * + * @param array $propertyNames + * @return array + */ + public static function purgeComputedPropertyNames(array $propertyNames): array + { + return array_filter( + $propertyNames, + function (string $propertyName): bool { + return $propertyName[0] !== '_'; + } + ); + } + /** * Makes an backwards explode on the $str and returns an array with ($table, $uid). * Example: tt_content_45 => array('tt_content', 45) @@ -3910,7 +3943,12 @@ class BackendUtility $orig_pid = $row['pid']; $movePldSwap = self::movePlhOL($table, $row); } - $wsAlt = self::getWorkspaceVersionOfRecord($wsid, $table, $row['uid'], implode(',', array_keys($row))); + $wsAlt = self::getWorkspaceVersionOfRecord( + $wsid, + $table, + $row['uid'], + implode(',', static::purgeComputedPropertyNames(array_keys($row))) + ); // If version was found, swap the default record with that one. if (is_array($wsAlt)) { // Check if this is in move-state: @@ -3978,7 +4016,11 @@ class BackendUtility } // Find pointed-to record. if ($versionState->equals(VersionState::MOVE_PLACEHOLDER) && $moveID) { - if ($origRow = self::getRecord($table, $moveID, implode(',', array_keys($row)))) { + if ($origRow = self::getRecord( + $table, + $moveID, + implode(',', static::purgeComputedPropertyNames(array_keys($row))) + )) { $row = $origRow; return true; } diff --git a/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php b/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php index 9a6de40e2cd185435de6cb014b3d79991ec51e6d..12a700f851600204cca5cfb778fb965e3cc94ca0 100644 --- a/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php +++ b/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php @@ -1176,4 +1176,36 @@ class BackendUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase $return = BackendUtility::getTCAtypes($table, $rec, $useFieldNameAsKey); $this->assertSame($expected, $return); } + + /** + * @test + */ + public function purgeComputedPropertyNamesRemovesPropertiesStartingWithUnderscore() + { + $propertyNames = [ + 'uid', + 'pid', + '_ORIG_PID' + ]; + $computedPropertyNames = BackendUtility::purgeComputedPropertyNames($propertyNames); + self::assertSame(['uid', 'pid'], $computedPropertyNames); + } + + /** + * @test + */ + public function purgeComputedPropertiesFromRecordRemovesPropertiesStartingWithUnderscore() + { + $record = [ + 'uid' => 1, + 'pid' => 2, + '_ORIG_PID' => 1 + ]; + $expected = [ + 'uid' => 1, + 'pid' => 2 + ]; + $computedProperties = BackendUtility::purgeComputedPropertiesFromRecord($record); + self::assertSame($expected, $computedProperties); + } } diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index 1254355e748e230efc2b3121c8f914f570091bf1..99f052587239f2d13ebddadbc1706dee5cee4faa 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -3395,6 +3395,7 @@ class DataHandler $data = []; $nonFields = array_unique(GeneralUtility::trimExplode(',', 'uid,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,t3ver_oid,t3ver_wsid,t3ver_id,t3ver_label,t3ver_state,t3ver_count,t3ver_stage,t3ver_tstamp,' . $excludeFields, true)); BackendUtility::workspaceOL($table, $row, -99, false); + $row = BackendUtility::purgeComputedPropertiesFromRecord($row); // Initializing: $theNewID = StringUtility::getUniqueId('NEW');