[wp-trac] [WordPress Trac] #11305: WP_Http won't follow redirects if open_basedir is in effect

WordPress Trac wp-trac at lists.automattic.com
Wed Mar 23 22:36:36 UTC 2011


#11305: WP_Http won't follow redirects if open_basedir is in effect
-------------------------------+---------------------
 Reporter:  calin              |       Owner:  dd32
     Type:  defect (bug)       |      Status:  closed
 Priority:  low                |   Milestone:  3.0
Component:  HTTP               |     Version:  2.8.5
 Severity:  minor              |  Resolution:  fixed
 Keywords:  reporter-feedback  |
-------------------------------+---------------------

Comment (by cogmios):

 ah I see why I get so many additional 'Too many redirects.' under non
 empty basepath on the server + redirect=0 (so on topic but not the
 complete topic)

 {{{
 // See #11305 - When running under safe mode, redirection is disabled
 above. Handle it manually.
                 if ( !empty($theHeaders['headers']['location']) &&
 (ini_get('safe_mode') || ini_get('open_basedir')) ) {
                         if ( $r['redirection']-- > 0 ) {
                                 return
 $this->request($theHeaders['headers']['location'], $r);
                         } else {
                                 return new WP_Error('http_request_failed',
 __('Too many redirects.'));
                         }
 }}}

 Where in this case  [ ' redirection ' ]  == 0 so it will always give this
 error. It should not check for the redirection amount but if the is_array
 location is present IMHO.

 So... this works better:

 {{{
 // See #11305 - When running under safe mode, redirection is disabled
 above. Handle it manually.
 if ( !empty($theHeaders['headers']['location']) && (ini_get('safe_mode')
 || ini_get('open_basedir')) ) {
   // EDL see: 16855
   if (array_key_exists('location',$theHeaders['headers']))
  {
    return $this->request($theHeaders['headers']['location'], $r);
  }
                         //if ( $r['redirection']-- > 0 ) {
                         //      return
 $this->request($theHeaders['headers']['location'], $r);
                         //} else {
                         //      return new WP_Error('http_request_failed',
 __('Too many redirects.'));
                         //}
 }
 }}}

 Now the correct redirection URL is stored in my request database.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11305#comment:16>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list