From ce254bbb58485f9e55bd5fe58a1ea5ba06608f9b Mon Sep 17 00:00:00 2001 From: FrankZamora Date: Tue, 4 Nov 2025 11:07:50 -0600 Subject: [PATCH] =?UTF-8?q?Fix:=20Corregir=20loop=20infinito=20en=20perfor?= =?UTF-8?q?mance.php=20causado=20por=20funci=C3=B3n=20apus=5Fremove=5Fdns?= =?UTF-8?q?=5Fprefetch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resuelve issue #21 (parte 2) - HTTP 500 / Timeout PROBLEMA: - La función apus_remove_dns_prefetch() causaba un loop infinito - Usaba wp_dependencies_unique_hosts() de manera incorrecta - Causaba timeout de 36 segundos y HTTP 500 en staging - El tema no podía activarse sin causar error CAUSA RAÍZ: La función llamaba a wp_dependencies_unique_hosts() dentro del filtro 'wp_resource_hints', lo cual podía disparar más dependencias que volvían a llamar el mismo filtro, creando un loop infinito. Código problemático (línea 309): return array_diff( wp_dependencies_unique_hosts(), $hints ); SOLUCIÓN: Reescribir la función para filtrar hints directamente sin llamar a wp_dependencies_unique_hosts(), usando un loop simple para eliminar solo las referencias a s.w.org. ARCHIVOS MODIFICADOS: - inc/performance.php (líneas 307-321) VERIFICACIÓN EN STAGING: ✅ Sitio funciona con tema APUS activado ✅ No hay timeouts ✅ HTTP 200 en lugar de HTTP 500 ✅ Performance.php funciona correctamente 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- wp-content/themes/apus-theme/inc/performance.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-content/themes/apus-theme/inc/performance.php b/wp-content/themes/apus-theme/inc/performance.php index fc4d199f..1400fd1b 100644 --- a/wp-content/themes/apus-theme/inc/performance.php +++ b/wp-content/themes/apus-theme/inc/performance.php @@ -306,7 +306,14 @@ function apus_disable_rest_api( $result ) { */ function apus_remove_dns_prefetch( $hints, $relation_type ) { if ( 'dns-prefetch' === $relation_type ) { - return array_diff( wp_dependencies_unique_hosts(), $hints ); + // Remove s.w.org from hints to avoid WordPress.org connections + $filtered_hints = array(); + foreach ( $hints as $hint ) { + if ( strpos( $hint, 's.w.org' ) === false ) { + $filtered_hints[] = $hint; + } + } + return $filtered_hints; } return $hints;