CRITICAL: Fix SYS_* variable reset bug in system-detect.sh

Problem:
- Lines 16-24 reset ALL SYS_* variables to empty EVERY time system-detect.sh is sourced
- When php-analyzer.sh sources system-detect.sh again, it wipes out SYS_CONTROL_PANEL
- Result: get_user_domains() returns empty because SYS_CONTROL_PANEL is empty
- This broke ALL multi-file sourcing scenarios

Root cause:
- export SYS_CONTROL_PANEL="" runs unconditionally on every source
- Multiple libraries source system-detect.sh (user-manager, php-detector, php-analyzer)
- Second sourcing wipes first initialization

Fix:
- Wrap variable initialization in SYS_DETECTION_COMPLETE check
- Variables only reset if detection hasn't run yet
- Preserves values across multiple sourcings

Impact:
- Memory capacity analysis now works (was showing 0 pools)
- All domain iteration works correctly
- Any script that sources multiple libraries now works
This commit is contained in:
cschantz
2025-12-03 01:30:58 -05:00
parent 09d51a786e
commit 2593e87489
+3 -1
View File
@@ -12,7 +12,8 @@ if [ -z "$TOOLKIT_BASE_DIR" ]; then
source "$SCRIPT_DIR/common-functions.sh" source "$SCRIPT_DIR/common-functions.sh"
fi fi
# Global variables (session-only) # Global variables (session-only) - only initialize if not already set
if [ -z "$SYS_DETECTION_COMPLETE" ]; then
export SYS_CONTROL_PANEL="" export SYS_CONTROL_PANEL=""
export SYS_CONTROL_PANEL_VERSION="" export SYS_CONTROL_PANEL_VERSION=""
export SYS_OS_TYPE="" export SYS_OS_TYPE=""
@@ -22,6 +23,7 @@ export SYS_WEB_SERVER_VERSION=""
export SYS_DB_TYPE="" export SYS_DB_TYPE=""
export SYS_DB_VERSION="" export SYS_DB_VERSION=""
export SYS_LOG_DIR="" export SYS_LOG_DIR=""
fi
export SYS_USER_HOME_BASE="" export SYS_USER_HOME_BASE=""
export SYS_PHP_VERSIONS=() export SYS_PHP_VERSIONS=()
export SYS_CLOUDFLARE_ACTIVE="" export SYS_CLOUDFLARE_ACTIVE=""