Issue Bug Closed

#88784Record language is incorrectly changed to default language in overlayLanguageAndWorkspace

Jonas Schwabe 07/16/19, 15:48 updated 12/18/23, 12:08

Description

When a record with language uid !=0 is processed while the current language uid is 0 overlayLanguageAndWorkspace incorrectly “transforms” the record into the default language.

The relevant code is as far as I can tell this one:

if (isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']) && $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] > 0) {
  //force overlay by faking default language record, as getRecordOverlay can only handle default language records
  $row['uid'] = $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']];
  $row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']] = 0;
}

A foreign language record is handled by overlayLanguageAndWorkspace so the condition passes. The language uid is set to 0 for this record, the record is then considered as main language. When it is next passed into getRecordOverlay it’s not being dropped (as it should be in this case).

The above “fake” should only happen if $languageUid is not 0:

if (isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']) && $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] > 0 && $languageUid > 0) {
  //force overlay by faking default language record, as getRecordOverlay can only handle default language records
  $row['uid'] = $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']];
  $row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']] = 0;
}

This issue becomes visible e.g. when relations are resolved as in tx_news: https://github.com/georgringer/news/issues/843#issuecomment-511815126

Reviews 1