[wp-trac] [WordPress Trac] #14904: Install page not redirecting to wp-admin/ on IIS6

WordPress Trac wp-trac at lists.automattic.com
Tue Sep 28 05:13:16 UTC 2010


#14904: Install page not redirecting to wp-admin/ on IIS6
-----------------------------+----------------------------------------------
 Reporter:  knutsp           |       Owner:                 
     Type:  defect (bug)     |      Status:  new            
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Upgrade/Install  |     Version:  3.0.1          
 Severity:  normal           |    Keywords:                 
-----------------------------+----------------------------------------------
Changes (by knutsp):

  * keywords:  reporter-feedback =>


Comment:

 Now I think I can explain this issue a bit deeper.  On my system the
 server software is Microsoft-IIS/6.0.

 In pluggable.php I find this:
 {{{
 function wp_redirect($location, $status = 302) {
         global $is_IIS;
         $is_IIS = TRUE;
         $location = apply_filters('wp_redirect', $location, $status);
         $status = apply_filters('wp_redirect_status', $status, $location);

         if ( !$location ) // allows the wp_redirect filter to cancel a
 redirect
                 return false;

         $location = wp_sanitize_redirect($location);

         if ( $is_IIS ) {
                 header("Refresh: 0;url=$location");
         } else {
                 if ( php_sapi_name() != 'cgi-fcgi' )
                         status_header($status); // This causes problems on
 IIS and some FastCGI setups
                 header("Location: $location", true, $status);
         }
 }
 }}}
 The first thing is that his means that in case the server is IIS the
 redirect method should be the "Refresh" header. Othwerwise the redirect
 method should be the "Location" header. This is strange, because the
 Location header also works on IIS.

 The second thing is that the $is_IIS variable is not initialized inside
 wp-includes/load.php, as this is required from wp-settings.php before the
 vars.php is requierd. In case the blog is not installed yet, but a wp-
 config.php is present, the redirection to wp-admin/install.php is done
 from wp-includes/load.php. This means that the redirect method used for
 any server is the Location header.

 The third thing is that, on my system, when a redirect is done with a
 '''relative''' URL, the redirect is done "internally". This means that the
 browser will not know that actual resource served to it. But, strangely,
 the IIS log file shows the actual wp-admin/install.php as being requested.
 This is very, very strange to me, and I have no explaination. I have no
 other IIS6 systems to etst this on.

 The fourth thing, and this is the main reason (and bug?), is that
 WP_SITEURL is not defined in wp-includes/load.php, as long as it's not
 defined in wp-config.php. This means that the redirection location will
 miss the site part and be relative. Combined with the undefined $is_IIS
 the redirect will fail. From load.php:
 {{{
 function wp_not_installed() {
         if ( is_multisite() ) {
                 if ( ! is_blog_installed() && ! defined( 'WP_INSTALLING' )
 )
                         wp_die( __( 'The site you have requested is not
 installed properly. Please contact the system administrator.' ) );
         } elseif ( ! is_blog_installed() && false === strpos(
 $_SERVER['PHP_SELF'], 'install.php' ) && !defined( 'WP_INSTALLING' ) ) {
                 if ( defined( 'WP_SITEURL' ) )
                         $link = WP_SITEURL . '/wp-admin/install.php';
                 elseif ( false !== strpos( $_SERVER['PHP_SELF'], 'wp-
 admin' ) )
                         $link = preg_replace( '|/wp-admin/?.*?$|', '/',
 $_SERVER['PHP_SELF'] ) . 'wp-admin/install.php';
                 else
                         $link = preg_replace( '|/[^/]+?$|', '/',
 $_SERVER['PHP_SELF'] ) . 'wp-admin/install.php';
                 require( ABSPATH . WPINC . '/kses.php' );
                 require( ABSPATH . WPINC . '/pluggable.php' );
                 require( ABSPATH . WPINC . '/formatting.php' );
                 wp_redirect( $link );
                 die();
         }
 }
 }}}


 '''I suggest:'''

 1. Remove the "Refresh" redirection method from wp_redirect, as I cannot
 see the need for this, and it's not a standard header. I qoute from
 [http://php.net/manual/en/function.header.php]: «frank farmer 04-Aug-2010
 02:10 in response to marcel dot glacki at stud dot fh-swf dot de

 The "refresh" header in your example is not part of the HTTP standard, it
 was a proprietary extension invented by Netscape.  It's use is discouraged
 by the W3C.»

 Then we can remove the $is_IIS test from wp-redirect and it doesn't need
 to be defined there.

 2. Rearrange the loading or constant definition sequence, or move the
 wp_not_installed function declaration, so that WP_SITEURL is defined at
 the time of declaration of wp_not_installed(). This will ensure that a
 redirection location never is a relative URL. A "Location" header should
 always have an "absoluteURI".

 I have also investigated this on IIS7 (Windows Server 2008) and there is
 no problem with relative URLs in a Location header. This is why this
 problem seems only to affect IIS6.

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


More information about the wp-trac mailing list