Performance: Remove slow php -l check and add progress indicator
Issues: - Script was running php -l (syntax checker) on every file with 500 error - With 7555 errors, this meant running php -l thousands of times - Each php -l takes 100-500ms, causing multi-minute delays Changes: - Removed php -l syntax checking (was causing major slowdown) - Added progress indicator showing "Analyzed X / Y errors..." - Progress updates every 500 errors to show script is working - Completion message when diagnosis finishes Result: Diagnosis now completes in seconds instead of minutes. Users still get comprehensive checks for .htaccess, permissions, file existence, docroot, PHP handler, and WordPress issues. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -190,9 +190,21 @@ DETAILED_DIAGNOSIS="$TEMP_DIR/detailed_diagnosis.txt"
|
||||
declare -A diagnosed_causes
|
||||
declare -A cause_examples
|
||||
|
||||
total_to_diagnose=$(wc -l < "$ERRORS_500")
|
||||
current_line=0
|
||||
|
||||
echo "Analyzing $total_to_diagnose errors for root causes..."
|
||||
echo ""
|
||||
|
||||
while IFS='|' read -r domain user status url timestamp ip; do
|
||||
[ -z "$domain" ] && continue
|
||||
|
||||
((current_line++))
|
||||
# Show progress every 500 errors
|
||||
if [ $((current_line % 500)) -eq 0 ]; then
|
||||
echo -ne "\rAnalyzed $current_line / $total_to_diagnose errors..."
|
||||
fi
|
||||
|
||||
diagnosis=""
|
||||
cause="UNKNOWN"
|
||||
specific_file=""
|
||||
@@ -397,15 +409,6 @@ while IFS='|' read -r domain user status url timestamp ip; do
|
||||
cause="PERMISSION_ERROR"
|
||||
diagnosis="$domain$url - File not readable: $specific_file (perms: $file_perms)"
|
||||
issue_found="yes"
|
||||
else
|
||||
# Check for PHP syntax errors
|
||||
syntax_check=$(php -l "$specific_file" 2>&1)
|
||||
if [[ "$syntax_check" =~ "Parse error" ]] || [[ "$syntax_check" =~ "syntax error" ]]; then
|
||||
cause="PHP_SYNTAX_ERROR"
|
||||
syntax_line=$(echo "$syntax_check" | grep -oP "line \K[0-9]+" | head -1)
|
||||
diagnosis="$domain$url - PHP syntax error in $specific_file${syntax_line:+ at line $syntax_line}"
|
||||
issue_found="yes"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -637,6 +640,9 @@ while IFS='|' read -r domain user status url timestamp ip; do
|
||||
fi
|
||||
done < "$ERRORS_500"
|
||||
|
||||
echo -e "\rAnalyzed $total_to_diagnose / $total_to_diagnose errors - Complete! "
|
||||
echo ""
|
||||
|
||||
# Display diagnosed causes
|
||||
echo -e "${CYAN}${BOLD}ROOT CAUSES IDENTIFIED:${NC}"
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user