Fix: Corregir loop infinito en performance.php causado por función apus_remove_dns_prefetch
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 <noreply@anthropic.com>
This commit is contained in:
@@ -306,7 +306,14 @@ function apus_disable_rest_api( $result ) {
|
|||||||
*/
|
*/
|
||||||
function apus_remove_dns_prefetch( $hints, $relation_type ) {
|
function apus_remove_dns_prefetch( $hints, $relation_type ) {
|
||||||
if ( 'dns-prefetch' === $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;
|
return $hints;
|
||||||
|
|||||||
Reference in New Issue
Block a user