Make WordPress Core

Ticket #10187: 10187-10435-merged.patch

File 10187-10435-merged.patch, 4.9 KB (added by peaceablewhale, 15 years ago)
  • wp-admin/includes/misc.php

     
    433433}
    434434
    435435/**
    436  * Check if IIS 7 supports pretty permalinks
    437  *
    438  * @since 2.8.0
    439  *
    440  * @return bool
    441  */
    442 function iis7_supports_permalinks() {
    443         global $is_iis7;
    444 
    445         $supports_permalinks = false;
    446         if ( $is_iis7 ) {
    447                 /* First we check if the DOMDocument class exists. If it does not exist,
    448                  * which is the case for PHP 4.X, then we cannot easily update the xml configuration file,
    449                  * hence we just bail out and tell user that pretty permalinks cannot be used.
    450                  * This is not a big issue because PHP 4.X is going to be depricated and for IIS it
    451                  * is recommended to use PHP 5.X NTS.
    452                  * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When
    453                  * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'.
    454                  * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs
    455                  * via ISAPI then pretty permalinks will not work.
    456                  */
    457                 $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' );
    458         }
    459 
    460         return apply_filters('iis7_supports_permalinks', $supports_permalinks);
    461 }
    462 
    463 /**
    464436 * Check if rewrite rule for WordPress already exists in the IIS 7 configuration file
    465437 *
    466438 * @since 2.8.0
  • wp-includes/canonical.php

     
    3939function redirect_canonical($requested_url=null, $do_redirect=true) {
    4040        global $wp_rewrite, $is_IIS, $wp_query, $wpdb;
    4141
    42         if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() )
     42        if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || ( $is_IIS && !iis7_supports_permalinks() ) || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() )
    4343                return;
    4444
    4545        if ( !$requested_url ) {
  • wp-includes/pluggable.php

     
    839839
    840840if ( !function_exists('wp_redirect') ) :
    841841/**
    842  * Redirects to another page, with a workaround for the IIS Set-Cookie bug.
     842 * Redirects to another page
    843843 *
    844  * @link http://support.microsoft.com/kb/q176113/
    845844 * @since 1.5.1
    846845 * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
    847846 *
     
    850849 * @return bool False if $location is not set
    851850 */
    852851function wp_redirect($location, $status = 302) {
    853         global $is_IIS;
    854 
    855852        $location = apply_filters('wp_redirect', $location, $status);
    856853        $status = apply_filters('wp_redirect_status', $status, $location);
    857 
     854       
    858855        if ( !$location ) // allows the wp_redirect filter to cancel a redirect
    859856                return false;
    860 
     857       
    861858        $location = wp_sanitize_redirect($location);
    862 
    863         if ( $is_IIS ) {
    864                 header("Refresh: 0;url=$location");
    865         } else {
    866                 if ( php_sapi_name() != 'cgi-fcgi' )
    867                         status_header($status); // This causes problems on IIS and some FastCGI setups
    868                 header("Location: $location", true, $status);
    869         }
     859       
     860        header("Location: $location", true, $status);
    870861}
    871862endif;
    872863
  • wp-includes/vars.php

     
    8282 */
    8383$is_iis7 = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false);
    8484
     85/**
     86 * Check if IIS 7 supports pretty permalinks
     87 *
     88 * @since 2.8.0
     89 *
     90 * @return bool
     91 */
     92function iis7_supports_permalinks() {
     93        global $is_iis7;
    8594
     95        $supports_permalinks = false;
     96        if ( $is_iis7 ) {
     97                /* First we check if the DOMDocument class exists. If it does not exist,
     98                 * which is the case for PHP 4.X, then we cannot easily update the xml configuration file,
     99                 * hence we just bail out and tell user that pretty permalinks cannot be used.
     100                 * This is not a big issue because PHP 4.X is going to be depricated and for IIS it
     101                 * is recommended to use PHP 5.X NTS.
     102                 * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When
     103                 * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'.
     104                 * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs
     105                 * via ISAPI then pretty permalinks will not work.
     106                 */
     107                $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' );
     108        }
     109
     110        return apply_filters('iis7_supports_permalinks', $supports_permalinks);
     111}
    86112?>
     113 No newline at end of file