From ff8c01a1692800acb1c0800812fe1dc19d8e7975 Mon Sep 17 00:00:00 2001 From: Developer Date: Mon, 20 Apr 2026 22:16:34 -0400 Subject: [PATCH] CRITICAL FIX: Correct MySQL memory field extraction The calculate_server_capacity() function was extracting the wrong field from detect_mysql_memory_usage(), causing incorrect available memory calculations and resulting in 0 max_children recommendations. Bug: Was extracting field 1 (buffer_pool_mb) Fix: Now extracts field 3 (estimated_total_mb - actual usage) detect_mysql_memory_usage returns: buffer_pool|connections|total_mb|status This fix allows Level 5 optimization to correctly calculate PHP-FPM capacity and make proper recommendations instead of recommending 0. --- lib/php-calculator-improved.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/php-calculator-improved.sh b/lib/php-calculator-improved.sh index ca60dd4..091c966 100644 --- a/lib/php-calculator-improved.sh +++ b/lib/php-calculator-improved.sh @@ -122,8 +122,9 @@ calculate_max_children_memory_based() { local mysql_info mysql_info=$(detect_mysql_memory_usage 2>/dev/null) if [ $? -eq 0 ]; then - # FIX: detect_mysql_memory_usage returns: memory|status (only 2 fields) - mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f1) + # FIX: detect_mysql_memory_usage returns: buffer_pool|connections|estimated_total_mb|status (4 fields) + # Extract field 3 (estimated_total_mb - the actual memory usage) + mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f3) fi # Available memory for PHP-FPM (after system + MySQL reserves) @@ -372,8 +373,9 @@ calculate_server_capacity() { local mysql_info mysql_info=$(detect_mysql_memory_usage 2>/dev/null) if [ $? -eq 0 ]; then - # FIX: detect_mysql_memory_usage returns: memory|status (only 2 fields) - mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f1) + # FIX: detect_mysql_memory_usage returns: buffer_pool|connections|estimated_total_mb|status (4 fields) + # Extract field 3 (estimated_total_mb - the actual memory usage) + mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f3) fi # Available memory for PHP-FPM (after system + MySQL reserves)