운영 Whoops 방지를 위해 메뉴 활성 계산 의존성을 단순화

레이아웃에서 내부 헬퍼 함수를 직접 호출하지 않고 공개 메뉴 매칭 함수만 사용하도록 변경해 운영 환경 차이에 따른 오류 가능성을 줄였습니다.
This commit is contained in:
taekyoungc
2026-04-14 00:38:51 +09:00
parent 48e5578611
commit c8d1612f0e
2 changed files with 14 additions and 22 deletions

View File

@@ -16,21 +16,17 @@ $userNav = session_user_nav_display();
$currentPath = current_nav_request_path(); $currentPath = current_nav_request_path();
$adminNavTree = get_admin_nav_tree(); $adminNavTree = get_admin_nav_tree();
$resolveAdminNavNodeMatchLen = static function (object $node) use ($currentPath): int {
$maxLen = -1;
foreach (menu_link_candidate_paths($node->mm_link ?? null, $currentPath) as $cand) {
if (menu_single_path_matches_request($cand, $currentPath, [])) {
$maxLen = max($maxLen, strlen($cand));
}
}
return $maxLen;
};
$activeAdminTopNav = null; $activeAdminTopNav = null;
$activeAdminTopLen = -1; $activeAdminTopLen = -1;
$activeAdminTopNum = PHP_INT_MAX; $activeAdminTopNum = PHP_INT_MAX;
foreach ($adminNavTree as $topNode) { foreach ($adminNavTree as $topNode) {
$nodeLen = $resolveAdminNavNodeMatchLen($topNode); $nodeLen = -1;
$activeChild = site_nav_active_child_for_parent($topNode, $currentPath, []);
if ($activeChild !== null) {
$nodeLen = strlen(menu_link_preferred_href_path($activeChild->mm_link ?? null, $currentPath));
} elseif (menu_link_matches_request($topNode->mm_link ?? null, $currentPath, [])) {
$nodeLen = strlen(menu_link_preferred_href_path($topNode->mm_link ?? null, $currentPath));
}
if ($nodeLen > $activeAdminTopLen || ($nodeLen === $activeAdminTopLen && (int) ($topNode->mm_num ?? 0) < $activeAdminTopNum)) { if ($nodeLen > $activeAdminTopLen || ($nodeLen === $activeAdminTopLen && (int) ($topNode->mm_num ?? 0) < $activeAdminTopNum)) {
$activeAdminTopNav = $topNode; $activeAdminTopNav = $topNode;
$activeAdminTopLen = $nodeLen; $activeAdminTopLen = $nodeLen;

View File

@@ -14,21 +14,17 @@ if ($effectiveLgIdx) {
} }
$userNav = session_user_nav_display(); $userNav = session_user_nav_display();
$resolveNavNodeMatchLen = static function (object $node) use ($currentPath, $dashboardPathAliases): int {
$maxLen = -1;
foreach (menu_link_candidate_paths($node->mm_link ?? null, $currentPath) as $cand) {
if (menu_single_path_matches_request($cand, $currentPath, $dashboardPathAliases)) {
$maxLen = max($maxLen, strlen($cand));
}
}
return $maxLen;
};
$activeTopNav = null; $activeTopNav = null;
$activeTopLen = -1; $activeTopLen = -1;
$activeTopNum = PHP_INT_MAX; $activeTopNum = PHP_INT_MAX;
foreach ($siteNavTree as $topNode) { foreach ($siteNavTree as $topNode) {
$nodeLen = $resolveNavNodeMatchLen($topNode); $nodeLen = -1;
$activeChild = site_nav_active_child_for_parent($topNode, $currentPath, $dashboardPathAliases);
if ($activeChild !== null) {
$nodeLen = strlen(menu_link_preferred_href_path($activeChild->mm_link ?? null, $currentPath));
} elseif (site_nav_link_matches_current($topNode->mm_link ?? null, $currentPath, $dashboardPathAliases)) {
$nodeLen = strlen(menu_link_preferred_href_path($topNode->mm_link ?? null, $currentPath));
}
if ($nodeLen > $activeTopLen || ($nodeLen === $activeTopLen && (int) ($topNode->mm_num ?? 0) < $activeTopNum)) { if ($nodeLen > $activeTopLen || ($nodeLen === $activeTopLen && (int) ($topNode->mm_num ?? 0) < $activeTopNum)) {
$activeTop = $topNode; $activeTop = $topNode;
$activeTopLen = $nodeLen; $activeTopLen = $nodeLen;