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

This reverts commit c8d1612f0e.
This commit is contained in:
taekyoungc
2026-04-14 00:41:14 +09:00
parent c8d1612f0e
commit 2629644f90
2 changed files with 22 additions and 14 deletions

View File

@@ -16,17 +16,21 @@ $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 = -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));
}
$nodeLen = $resolveAdminNavNodeMatchLen($topNode);
if ($nodeLen > $activeAdminTopLen || ($nodeLen === $activeAdminTopLen && (int) ($topNode->mm_num ?? 0) < $activeAdminTopNum)) {
$activeAdminTopNav = $topNode;
$activeAdminTopLen = $nodeLen;