diff --git a/modules/website/wordpress/wordpress-cron-manager.sh b/modules/website/wordpress/wordpress-cron-manager.sh index 0745b9b..31cc184 100755 --- a/modules/website/wordpress/wordpress-cron-manager.sh +++ b/modules/website/wordpress/wordpress-cron-manager.sh @@ -256,42 +256,31 @@ function_get_description() { # PERFORMANCE OPTIMIZATION: Use system domain discovery instead of find commands # References already-discovered domains from main management system (much faster!) # Returns wp-config.php paths for all WordPress installations +# CRITICAL FIX: Use find directly (much faster than list_all_domains + get_domain_docroot) +# Direct find approach: O(1) scan vs. domain discovery approach: O(N) system calls get_wp_search_paths() { local panel="${1:-$SYS_CONTROL_PANEL}" - # Use domain discovery to get all domains (faster than find) - # This leverages discovery that's already done by the main management system - local all_domains - all_domains=$(list_all_domains 2>/dev/null) - - if [ -z "$all_domains" ]; then - # Fallback to find if domain discovery fails - case "$panel" in - cpanel) - find /home/*/public_html -name "wp-config.php" -type f 2>/dev/null - ;; - interworx) - find /home/*/*/html -name "wp-config.php" -type f 2>/dev/null - ;; - plesk) - find /var/www/vhosts/*/httpdocs -name "wp-config.php" -type f 2>/dev/null - ;; - *) + # Use direct find search - fastest method for locating all wp-config.php files + # This avoids expensive list_all_domains + per-domain docroot lookups + case "$panel" in + cpanel) + find /home/*/public_html -name "wp-config.php" -type f 2>/dev/null | head -1000 + ;; + interworx) + find /home/*/*/html -name "wp-config.php" -type f 2>/dev/null | head -1000 + ;; + plesk) + find /var/www/vhosts/*/httpdocs -name "wp-config.php" -type f 2>/dev/null | head -1000 + ;; + *) + # Standalone: check common paths + { find /var/www/html -name "wp-config.php" -type f 2>/dev/null - ;; - esac - return - fi - - # For each domain, check its docroot for wp-config.php - while IFS= read -r domain; do - local docroot - docroot=$(get_domain_docroot "$domain" 2>/dev/null) - - if [ -n "$docroot" ] && [ -f "$docroot/$WP_CONFIG_FILENAME" ]; then - echo "$docroot/$WP_CONFIG_FILENAME" - fi - done <<< "$all_domains" + find /home/*/public_html -name "wp-config.php" -type f 2>/dev/null + } | head -1000 + ;; + esac } # OPTIMIZATION: Build home path based on control panel and username