diff --git a/src/Model/RecordLocale.php b/src/Model/RecordLocale.php index fd95695c..74f3a4f0 100644 --- a/src/Model/RecordLocale.php +++ b/src/Model/RecordLocale.php @@ -387,13 +387,8 @@ public function getSourceLocale(): ?Locale return null; } - $fallbackLocales = []; - foreach ($this->getLocaleObject()->Fallbacks() as $fallback) { - $fallbackLocale = $fallback->Locale; - $fallbackLocales[] = $fallbackLocale; - - if (!$record->existsInLocale($fallbackLocale)) { + if (!$record->existsInLocale($fallback->Locale)) { continue; } @@ -401,47 +396,13 @@ public function getSourceLocale(): ?Locale return $fallback; } - // This model allows fallback to any locale even bypassing the fallback rules, + // Noting here that we have another case here that isn't handled correctly + // In case this model allows fallback to any locale even bypassing the fallback rules, // so we just need to find the most recently updated locale // as that's the one which is going to be providing content - if ($inheritanceMode === FluentExtension::INHERITANCE_MODE_ANY) { - $lastEditedList = ArrayList::create(); - - /** @var RecordLocale $localeInformation */ - foreach ($record->Locales() as $localeInformation) { - $locale = $localeInformation->getLocale(); - - // Ignore any fallback locales as we've already confirmed that none of these locales - // are acting as the source locale - if (in_array($locale, $fallbackLocales)) { - continue; - } - - $localisedRecord = $localeInformation->getRecord(); - - // We don't have any localised data in this locale so this doesn't qualify as a potential source locale - if (!$localisedRecord) { - continue; - } - - $data = ArrayData::create([ - 'Locale' => $locale, - 'LastEdited' => $localisedRecord->LastEdited, - ]); - - $lastEditedList->push($data); - } - - // We found at leadt one candidate for the source locale, let's pick the most recently updated one - if ($lastEditedList->count() > 0) { - $sortedLocales = $lastEditedList - ->sort('LastEdited', 'DESC') - ->column('Locale'); - $mostRecentlyEditedLocale = array_shift($sortedLocales); - - return Locale::getByLocale($mostRecentlyEditedLocale); - } - } + // This is what we call base record fallback + // It's technically possible to figure out which locale the content is coming from but + // displaying this information may actually be confusing so just displaying no source might be more helpful return null; }