Fix SCRIPT_DIR variable collision in PHP libraries

CRITICAL BUG FIX:

Problem: php-detector.sh and php-analyzer.sh were setting SCRIPT_DIR
which collided with parent script's SCRIPT_DIR variable causing
/lib/lib/ double path bug when sourcing libraries.

Solution:
- Changed SCRIPT_DIR to _LIB_DIR in both php-detector.sh and php-analyzer.sh
- Changed exit 1 to return 1 in sourced libraries (exit kills parent script)

Files modified:
- lib/php-detector.sh: Use _LIB_DIR instead of SCRIPT_DIR
- lib/php-analyzer.sh: Use _LIB_DIR instead of SCRIPT_DIR, return instead of exit

This prevents variable collision when libraries are sourced by modules.
This commit is contained in:
cschantz
2025-12-03 00:52:44 -05:00
parent 4ce27dfbc1
commit 9ebf06a62e
2 changed files with 431 additions and 3 deletions
+3 -3
View File
@@ -4,9 +4,9 @@
# Dependencies: lib/php-detector.sh, lib/system-detect.sh
# Source required libraries
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/php-detector.sh" 2>/dev/null || { echo "ERROR: php-detector.sh not found"; exit 1; }
source "$SCRIPT_DIR/system-detect.sh" 2>/dev/null || { echo "ERROR: system-detect.sh not found"; exit 1; }
_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$_LIB_DIR/php-detector.sh" 2>/dev/null || { echo "ERROR: php-detector.sh not found"; return 1; }
source "$_LIB_DIR/system-detect.sh" 2>/dev/null || { echo "ERROR: system-detect.sh not found"; return 1; }
# ============================================================================
# ERROR LOG ANALYSIS