From 94c486717fecb87e64a75ff40d9ec45b289f3df7 Mon Sep 17 00:00:00 2001 From: Developer Date: Mon, 20 Apr 2026 18:19:36 -0400 Subject: [PATCH] fix: Align Option 5 optimizer with batch analyzer traffic metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL ALIGNMENT FIX Option 5 (Optimize Server-Wide) was NOT using the same traffic percentage calculation as the batch analyzer. It had the SAME BUG we just fixed: passing per-user domains instead of ALL server domains. What was fixed: 1. Added pre-collection loop (lines 2497-2515) to gather all domains • Same approach as batch analyzer • Builds all_domains_string before processing 2. Updated traffic calculation (line 2544) • OLD: get_domain_traffic_percentage(..., $user_domains) • NEW: get_domain_traffic_percentage(..., $all_domains_string) Result: NOW ALIGNED WITH BATCH ANALYZER ✓ Option 5 uses ACTUAL memory per process (140MB) ✓ Option 5 uses CORRECT traffic percentages (all domains) ✓ Option 5 uses THREE-CONSTRAINT intelligent model ✓ Option 5 has SAME safety validation When user selects Option 5, they WILL get same metrics as analysis. --- modules/performance/php-optimizer.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/performance/php-optimizer.sh b/modules/performance/php-optimizer.sh index 247f4a5..13cd099 100755 --- a/modules/performance/php-optimizer.sh +++ b/modules/performance/php-optimizer.sh @@ -2494,6 +2494,18 @@ optimize_level_5_everything() { local users users=$(list_all_users) + # CRITICAL FIX: Build list of ALL domains on server FIRST + # This is needed for accurate traffic percentage calculation (same as batch analyzer) + all_domains_string="" + while IFS= read -r u; do + [ -z "$u" ] && continue + u_domains=$(get_user_domains "$u") + while IFS= read -r d; do + [ -z "$d" ] && continue + all_domains_string="$all_domains_string$d"$'\n' + done <<< "$u_domains" + done <<< "$users" + while IFS= read -r username; do [ -z "$username" ] && continue local user_domains @@ -2527,7 +2539,8 @@ optimize_level_5_everything() { recommended_requests=$(get_max_requests_recommendation "$domain") else # Use intelligent three-constraint model - traffic_pct=$(get_domain_traffic_percentage "$username" "$domain" "$user_domains" 2>/dev/null | cut -d'|' -f1) + # CRITICAL FIX: Pass ALL server domains, not just user's domains! + traffic_pct=$(get_domain_traffic_percentage "$username" "$domain" "$all_domains_string" 2>/dev/null | cut -d'|' -f1) traffic_pct=${traffic_pct:-50} # Call intelligent three-constraint function