[wp-trac] [WordPress Trac] #39679: Redirect loop on attachment pages

WordPress Trac noreply at wordpress.org
Tue Jan 24 17:12:13 UTC 2017


#39679: Redirect loop on attachment pages
--------------------------+-----------------------------
 Reporter:  OPunWide      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.7.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Summary: a URL to an attachment page will redirect to itself in an
 infinite loop in certain cases.

 Speculation: this may be due to my permalink structure, which would be why
 others are not complaining about it.

 This issue depends on the letter case of the URL. The attachment pages
 exist, and there is a method that allows them to be accessed, however they
 cannot be reached if the link is all lowercase letters. Because that is
 the link generated by the Media Library, users can encounter this.

 It took me a while to convince myself that this is a WP core issue because
 it does not happen on all servers. After adding logging code to some of
 the action hooks, I could see that a URL comes in and then generates a
 redirect, using `wp_redirect`, to the exact same URL that was requested.

 My permalink structure is `/%postname%.html`, and the WP portion of the
 site is in a subdirectory, so WP pages are accessed as:
 http://yourfriendpaul.com/wp/shredding-on-my-guitar.html

 Trying to reach the attachment page using this URL will result in an
 infinite loop:
 http://yourfriendpaul.com/wp/shredding-on-my-guitar.html/good-at-
 shredding-dscn4850-1200x900

 Trying to reach it with this one will succeed, note the uppercase C.
 Making ANY letter in path uppercase will make it succeed:
 http://yourfriendpaul.com/wp/shredding-on-my-guitar.html/good-at-
 shredding-dsCn4850-1200x900

 To complicate matters further, this does not happen on my Ubuntu server,
 but does happen on GoDaddy with the exact same database (other than site
 name).

 This is my first bug report, so I'm not sure how much info to put in the
 initial report. The following is an excerpt from my error log, with some
 notes added. Sorry for the formatting, it is just pasted.

 Thanks in advance for looking into this.
 Paul


 The data is captured using the error log.
 The first entry is made in wp-config.
 The next 3 lines are when yfp_functions is loaded.
 It creates the function that prepends `**yfplog` to an error message.
 The final three lines are from the action hooks indicated.


         ` # A call in all lowercase has multiple tries, in bursts, which
 loop and cause 301 redirects to the original URI,
         ` # but one uppercase letter avoids any redirects and finds the
 content. Only two of the redirects are shown.
         `
         ` [24-Jan-2017 06:19:04 UTC]   *** in wp-config.php, REQUEST_URI
 is /wp/shredding-on-my-guitar.html/good-at-shredding-dscn4850-1200x900
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog - *** Log writing is
 enabled in yfp_functions, making funcion yfp_write_log()
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog -   script: /wp/index.php
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog -   uri:    /wp/shredding-
 on-my-guitar.html/good-at-shredding-dscn4850-1200x900
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog -  wp_loaded() action was
 called.
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog -  wp_redirect() action
 was called, location: http://YourFriendPaul.com/wp/shredding-on-my-
 guitar.html/good-at-shredding-dscn4850-1200x900, status: ""
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog -  wp_redirect_status()
 action was called, location: , status: "301"
         `
         ` [24-Jan-2017 06:19:04 UTC]   *** in wp-config.php, REQUEST_URI
 is /wp/shredding-on-my-guitar.html/good-at-shredding-dscn4850-1200x900
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog - *** Log writing is
 enabled in yfp_functions, making funcion yfp_write_log()
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog -   script: /wp/index.php
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog -   uri:    /wp/shredding-
 on-my-guitar.html/good-at-shredding-dscn4850-1200x900
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog -  wp_loaded() action was
 called.
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog -  wp_redirect() action
 was called, location: http://YourFriendPaul.com/wp/shredding-on-my-
 guitar.html/good-at-shredding-dscn4850-1200x900, status: ""
         ` [24-Jan-2017 06:19:04 UTC]   **fyplog -  wp_redirect_status()
 action was called, location: , status: "301"
         `
         ` [24-Jan-2017 06:19:49 UTC]   *** in wp-config.php, REQUEST_URI
 is /wp/shredding-on-my-guitar.html/good-at-shredding-dsCn4850-1200x900
         ` [24-Jan-2017 06:19:49 UTC]   **fyplog - *** Log writing is
 enabled in yfp_functions, making funcion yfp_write_log()
         ` [24-Jan-2017 06:19:49 UTC]   **fyplog -   script: /wp/index.php
         ` [24-Jan-2017 06:19:49 UTC]   **fyplog -   uri:    /wp/shredding-
 on-my-guitar.html/good-at-shredding-dsCn4850-1200x900
         ` [24-Jan-2017 06:19:49 UTC]   **fyplog -  wp_loaded() action was
 called.
         ` [24-Jan-2017 06:19:49 UTC]   **fyplog -  ******* in function
 get_attachment_link()
         ` [24-Jan-2017 06:19:49 UTC]   **fyplog -  ******* in function
 get_attachment_link()
         ` [24-Jan-2017 06:19:49 UTC]   **fyplog -  ******* in function
 get_attachment_link()
         ` [24-Jan-2017 06:19:49 UTC]   **fyplog -  ******* in function
 get_attachment_link()
         ` [24-Jan-2017 06:19:49 UTC]   **fyplog -  ******* in function
 get_attachment_link()
         ` [24-Jan-2017 06:19:49 UTC]   **fyplog -  ******* in function
 get_attachment_link()

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


More information about the wp-trac mailing list