From c8d1612f0e5add2f99d251a715d3faf91b3c2c7a Mon Sep 17 00:00:00 2001 From: taekyoungc Date: Tue, 14 Apr 2026 00:38:51 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9A=B4=EC=98=81=20Whoops=20=EB=B0=A9?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=EC=9C=84=ED=95=B4=20=EB=A9=94=EB=89=B4=20?= =?UTF-8?q?=ED=99=9C=EC=84=B1=20=EA=B3=84=EC=82=B0=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=EC=9D=84=20=EB=8B=A8=EC=88=9C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 레이아웃에서 내부 헬퍼 함수를 직접 호출하지 않고 공개 메뉴 매칭 함수만 사용하도록 변경해 운영 환경 차이에 따른 오류 가능성을 줄였습니다. --- app/Views/admin/layout.php | 18 +++++++----------- app/Views/bag/layout/main.php | 18 +++++++----------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/app/Views/admin/layout.php b/app/Views/admin/layout.php index 3494f30..ecc4d1e 100644 --- a/app/Views/admin/layout.php +++ b/app/Views/admin/layout.php @@ -16,21 +16,17 @@ $userNav = session_user_nav_display(); $currentPath = current_nav_request_path(); $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; $activeAdminTopLen = -1; $activeAdminTopNum = PHP_INT_MAX; 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)) { $activeAdminTopNav = $topNode; $activeAdminTopLen = $nodeLen; diff --git a/app/Views/bag/layout/main.php b/app/Views/bag/layout/main.php index 76de08c..cafe28b 100644 --- a/app/Views/bag/layout/main.php +++ b/app/Views/bag/layout/main.php @@ -14,21 +14,17 @@ if ($effectiveLgIdx) { } $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; $activeTopLen = -1; $activeTopNum = PHP_INT_MAX; 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)) { $activeTop = $topNode; $activeTopLen = $nodeLen;