From f98515aa037e893e1ef6b5a9f520599c8f3531b0 Mon Sep 17 00:00:00 2001 From: cschantz Date: Wed, 3 Dec 2025 00:58:21 -0500 Subject: [PATCH] Fix SCRIPT_DIR variable collision preventing PHP optimizer from running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL BUG FIX: - PHP optimizer failed with 'php-config-manager.sh not found' error - Root cause: Multiple sourced libraries redefining SCRIPT_DIR variable - Sourcing chain: php-optimizer → php-detector → system-detect + user-manager - Each library was overwriting parent's SCRIPT_DIR causing /lib/lib/ double paths CHANGES: - php-optimizer.sh: Renamed SCRIPT_DIR → PHP_TOOLKIT_DIR (unique variable) - user-manager.sh: Renamed SCRIPT_DIR → _LIB_SRCDIR to avoid collision - php-optimizer.sh: Fixed detect_system() → initialize_system_detection() - Removed 2>/dev/null error suppression to see actual errors during debug RESULT: - Script now loads all libraries successfully - Menu displays correctly with all 9 options - System detection runs properly - Ready for testing Files modified: - lib/user-manager.sh (3 lines) - modules/performance/php-optimizer.sh (10 lines) --- lib/user-manager.sh | 6 +++--- modules/performance/php-optimizer.sh | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/user-manager.sh b/lib/user-manager.sh index c860456..85d095a 100755 --- a/lib/user-manager.sh +++ b/lib/user-manager.sh @@ -7,9 +7,9 @@ # Source dependencies if [ -z "$TOOLKIT_BASE_DIR" ]; then - SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "$SCRIPT_DIR/common-functions.sh" - source "$SCRIPT_DIR/system-detect.sh" + _LIB_SRCDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + source "$_LIB_SRCDIR/common-functions.sh" + source "$_LIB_SRCDIR/system-detect.sh" fi # Initialize temp session directory if not set diff --git a/modules/performance/php-optimizer.sh b/modules/performance/php-optimizer.sh index 35dc71d..5324405 100755 --- a/modules/performance/php-optimizer.sh +++ b/modules/performance/php-optimizer.sh @@ -4,12 +4,12 @@ # Part of Server Toolkit - Phase 3: Main Interactive Script # Source required libraries -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd ../.. && pwd)" -source "$SCRIPT_DIR/lib/php-detector.sh" 2>/dev/null || { echo "ERROR: php-detector.sh not found"; exit 1; } -source "$SCRIPT_DIR/lib/php-analyzer.sh" 2>/dev/null || { echo "ERROR: php-analyzer.sh not found"; exit 1; } -source "$SCRIPT_DIR/lib/php-config-manager.sh" 2>/dev/null || { echo "ERROR: php-config-manager.sh not found"; exit 1; } -source "$SCRIPT_DIR/lib/system-detect.sh" 2>/dev/null || { echo "ERROR: system-detect.sh not found"; exit 1; } -source "$SCRIPT_DIR/lib/user-manager.sh" 2>/dev/null || { echo "ERROR: user-manager.sh not found"; exit 1; } +PHP_TOOLKIT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd ../.. && pwd)" +source "$PHP_TOOLKIT_DIR/lib/php-detector.sh" || { echo "ERROR: php-detector.sh not found"; exit 1; } +source "$PHP_TOOLKIT_DIR/lib/php-analyzer.sh" || { echo "ERROR: php-analyzer.sh not found"; exit 1; } +source "$PHP_TOOLKIT_DIR/lib/php-config-manager.sh" || { echo "ERROR: php-config-manager.sh not found"; exit 1; } +source "$PHP_TOOLKIT_DIR/lib/system-detect.sh" || { echo "ERROR: system-detect.sh not found"; exit 1; } +source "$PHP_TOOLKIT_DIR/lib/user-manager.sh" || { echo "ERROR: user-manager.sh not found"; exit 1; } # Color codes (using safe echo -e) RED='\033[0;31m' @@ -1109,7 +1109,7 @@ restore_configurations() { main() { # Detect system - detect_system + initialize_system_detection # Check if running as root if [ "$EUID" -ne 0 ]; then