From cf391147bf143451c6d77c1e9b2f023b490e0b93 Mon Sep 17 00:00:00 2001 From: Developer Date: Mon, 20 Apr 2026 21:17:39 -0400 Subject: [PATCH] FIX: Properly handle empty mysql_memory_mb in capacity calculation The calculate_server_memory_capacity function was failing when mysql_memory_mb was empty, causing 'integer expression expected' errors. Now: - Validates mysql_info is not empty before parsing - Provides fallback '0' if cut fails - Ensures mysql_memory_mb is always numeric - Uses safe default comparison: ${mysql_memory_mb:-0} --- lib/php-analyzer.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/php-analyzer.sh b/lib/php-analyzer.sh index 293b055..0873645 100644 --- a/lib/php-analyzer.sh +++ b/lib/php-analyzer.sh @@ -1006,9 +1006,12 @@ calculate_server_memory_capacity() { local mysql_status local mysql_info mysql_info=$(detect_mysql_memory_usage 2>/dev/null) - if [ $? -eq 0 ]; then - mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f3) + if [ $? -eq 0 ] && [ -n "$mysql_info" ]; then + mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f3 || echo "0") mysql_status=$(echo "$mysql_info" | cut -d'|' -f4) + # Ensure mysql_memory_mb is numeric + mysql_memory_mb=${mysql_memory_mb:-0} + [ -z "$mysql_memory_mb" ] && mysql_memory_mb=0 total_required_mb=$((total_required_mb + mysql_memory_mb)) fi @@ -1028,7 +1031,7 @@ calculate_server_memory_capacity() { fi # Return formatted result - first line is summary - if [ "$mysql_memory_mb" -gt 0 ]; then + if [ "${mysql_memory_mb:-0}" -gt 0 ]; then echo "$total_required_mb|$total_ram_mb|$percentage|$status|$pool_count pools|$total_max_children max_children|MySQL: ${mysql_memory_mb}MB" else echo "$total_required_mb|$total_ram_mb|$percentage|$status|$pool_count pools|$total_max_children max_children"