Skip to content

Commit 7d82dea

Browse files
authored
Defensive tweaks to getLocalizedUrls helper
1 parent 4bed40d commit 7d82dea

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

classes/Page.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,12 +773,12 @@ public static function resolveMenuItem(object $item, string $url, Theme $theme):
773773
// Helper to get the processed localized urls from the raw locale URL data array
774774
// that takes into account the enabled locales
775775
$getLocalizedUrls = function (array $pageInfo) {
776-
$localeUrls = $pageInfo['localeUrls'];
777776
$localizedUrls = [];
778777
$enabledLocales = class_exists(Locale::class) ? Locale::listEnabled() : [];
779778

780779
if ($enabledLocales) {
781-
$localizedUrls = [];
780+
$localeUrls = $pageInfo['localeUrls'] ?? [];
781+
782782
foreach ($enabledLocales as $locale => $name) {
783783
$localeUrl = array_get($localeUrls, $locale) ?: $pageInfo['url'];
784784
$pageUrl = static::getLocalizedUrl($localeUrl, $locale);
@@ -791,7 +791,6 @@ public static function resolveMenuItem(object $item, string $url, Theme $theme):
791791
return $localizedUrls;
792792
};
793793

794-
795794
if ($item->type == 'static-page') {
796795
$pageInfo = $tree[$item->reference];
797796
$result = [

0 commit comments

Comments
 (0)