Skip to content

Commit

Permalink
[BUGFIX] Prevent warnings if DataHandler received record has no language
Browse files Browse the repository at this point in the history
Warnings may trigger if the current BE user does not have access
to the language column of a record being moved. When this happens,
Flux will now attempt to read the language UID from the record as
stored in DB, or will default to the default language UID of zero.
  • Loading branch information
NamelessCoder committed Nov 9, 2023
1 parent 6cd3b78 commit 5c10d64
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Classes/Integration/HookSubscribers/DataHandlerSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ public function processDatamap_afterDatabaseOperations($command, $table, $id, $f
// of parent, rather, parent was pasted somewhere else).
// If language of child record is different from resolved parent (copyToLanguage occurred), resolve the
// right parent for the language and update the column position accordingly.
$recordUid = (integer) ($record['uid'] ?? $id);
$originalParentUid = ColumnNumberUtility::calculateParentUid($fieldArray['colPos']);
$originalParent = $this->getSingleRecordWithoutRestrictions($table, $originalParentUid, 'sys_language_uid');
if ($originalParent !== null && $originalParent['sys_language_uid'] !== $fieldArray['sys_language_uid']) {
$currentRecordLanguageUid = $fieldArray['sys_language_uid']
?? $this->getSingleRecordWithoutRestrictions($table, $recordUid, 'sys_language_uid')['sys_language_uid']
?? 0;
if ($originalParent !== null && $originalParent['sys_language_uid'] !== $currentRecordLanguageUid) {
// copyToLanguage case. Resolve the most recent translated version of the parent record in language of
// child record, and calculate the new column position number based on it.
$newParentRecord = $this->getTranslatedVersionOfParentInLanguageOnPage(
(int) $fieldArray['sys_language_uid'],
(int) $currentRecordLanguageUid,
(int) $fieldArray['pid'],
$originalParentUid
);
Expand Down

0 comments on commit 5c10d64

Please sign in to comment.