[wp-trac] [WordPress Trac] #58803: Infinite loop in canonical.php

WordPress Trac noreply at wordpress.org
Thu Jul 13 17:49:02 UTC 2023


#58803: Infinite loop in canonical.php
--------------------------+-----------------------------
 Reporter:  emerlen       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Canonical     |    Version:  6.2
 Severity:  minor         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 A site 24x7 monitor that points to a URL on our website leads to an error
 with infinite loops reported.

 This error started after the page being pointed by the monitor received a
 new Slug, leading to HTTP redirection due to autocomplete to the closest
 URL. Still, I believe it occurs only during periods of transient
 availability of our shared host.

 Looking at the source code [REF2] I believe there is potential for an
 infinite loop on line 800. Possible fix in [REF3].

 By assigning the result of redirect_canonical() to a variable
 ($chained_redirect) before the if statement, we ensure that the same value
 is used throughout the if block preventing unnecessary recursive calls.

 References
 ----------

 [REF1]

 HTTP/1.1 508 Loop Detected
 Server : nginx
 ...

 [REF2]
 https://github.com/WordPress/wordpress-develop/blob/6.2/src/wp-
 includes/canonical.php#L780-812

 [REF3]

  // Protect against chained redirects.
     $chained_redirect = redirect_canonical($redirect_url, false);
     if (!$chained_redirect)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58803>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list