[wp-trac] [WordPress Trac] #40013: Inifinite loop in subfolder

WordPress Trac noreply at wordpress.org
Thu Mar 2 08:00:34 UTC 2017


#40013: Inifinite loop in subfolder
--------------------------+-----------------------------
 Reporter:  dSero         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.7.2
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Hi,

 We implemented WP on a dedicated server, where /blog serves as a subfolder
 behind an AWS application ELB that directs all /blog traffic to this
 server. The ELB also offloads the SSL.

 When configuring the WP, we faced an inifinte loop (301 redirect) on the
 /blog/ path, while intenral paths works great (/blog/trial for exmample).

 When debugging the code, we found out that the "protect against chained
 redirects"  in /var/www/html/wp-includes/canonical.php actually doesn't
 work, as the if state should be true instead of false:

 Please find trace below:

 Pages flow:
 index.php
 wp-blog-header.php
 require_once( ABSPATH . WPINC . '/template-loader.php' );
 /var/www/html/wp-includes/template-loader.php
 do_action( 'template_redirect' ); ==>
 /var/www/html/wp-includes/default-filters.php
 add_action( 'template_redirect', 'redirect_canonical' );
 The actual broken code is in:
 /var/www/html/wp-includes/canonical.php
 => $redirect_url is empty inside, so return;
 And the broken code in it is:
 {{{#!php
 <?php
 !redirect_canonical($redirect_url, false)
                 // protect against chained redirects
                 if (!redirect_canonical($redirect_url, false) ) {
                         wp_redirect($redirect_url, 301);
                         exit();
 }}}

 Looks like there is a bug when there a sub folder model is being used.
 Instead of protecting from chained redirects, the if actually causes them,
 since the return from the funciton when URLs are the same if return;
 So correct code should be:
 {{{#!php
 <?php
 if (redirect_canonical($redirect_url, false) ) {
 }}}

 And not
 {{{#!php
 <?php
 if (!redirect_canonical($redirect_url, false) ) {
 }}}

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


More information about the wp-trac mailing list