From a5e2e0623bc6304d6f11aed6ff14f8cb6c2f46c4 Mon Sep 17 00:00:00 2001 From: Xika Date: Wed, 10 Jun 2026 17:54:57 +0000 Subject: [PATCH] fix(crm): resolve PathManager root for MoneyFlix standalone clone findRootPath() fell back to /opt/bitreport when composer.json lives under crm/ with Modules/, breaking auth layout resolution and /login 500. Co-authored-by: Cursor --- crm/Core/PathManager.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/crm/Core/PathManager.php b/crm/Core/PathManager.php index a86d9d2..9784cbd 100644 --- a/crm/Core/PathManager.php +++ b/crm/Core/PathManager.php @@ -54,20 +54,33 @@ class PathManager */ private static function findRootPath(): string { - // Force root path to be the directory containing the app folder - // This fixes the issue where composer.json exists in both root and app directories $currentPath = __DIR__; - - // Go up directories until we find the directory that contains both composer.json and app folder + while ($currentPath !== '/' && $currentPath !== '') { - if (file_exists($currentPath . '/composer.json') && is_dir($currentPath . '/app')) { + if (!file_exists($currentPath . '/composer.json')) { + $currentPath = dirname($currentPath); + continue; + } + + // Standard monorepo (CRM_Project): composer.json at repo root + app/ + if (is_dir($currentPath . '/app')) { return $currentPath; } + + // Standalone CRM clone (MoneyFlix): composer.json lives in crm/ with Modules/ + if (is_dir($currentPath . '/Modules')) { + $parentPath = dirname($currentPath); + if ($parentPath !== $currentPath && is_dir($parentPath . '/storage')) { + return $parentPath; + } + + return $currentPath; + } + $currentPath = dirname($currentPath); } - - // Fallback to current directory if composer.json not found - return dirname(__DIR__, 3); + + return dirname(__DIR__, 2); } /** -- 2.47.3