WordPress.org

Make WordPress Core

Ticket #10187: 10187-10435-merged.2.patch

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

     
    375375} 
    376376 
    377377/** 
    378  * Check if IIS 7 supports pretty permalinks 
    379  * 
    380  * @since 2.8.0 
    381  * 
    382  * @return bool 
    383  */ 
    384 function iis7_supports_permalinks() { 
    385         global $is_iis7; 
    386  
    387         $supports_permalinks = false; 
    388         if ( $is_iis7 ) { 
    389                 /* First we check if the DOMDocument class exists. If it does not exist, 
    390                  * which is the case for PHP 4.X, then we cannot easily update the xml configuration file, 
    391                  * hence we just bail out and tell user that pretty permalinks cannot be used. 
    392                  * This is not a big issue because PHP 4.X is going to be depricated and for IIS it 
    393                  * is recommended to use PHP 5.X NTS. 
    394                  * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When 
    395                  * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'. 
    396                  * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs 
    397                  * via ISAPI then pretty permalinks will not work. 
    398                  */ 
    399                 $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' ); 
    400         } 
    401  
    402         return apply_filters('iis7_supports_permalinks', $supports_permalinks); 
    403 } 
    404  
    405 /** 
    406378 * Check if rewrite rule for WordPress already exists in the IIS 7 configuration file 
    407379 * 
    408380 * @since 2.8.0 
  • wp-includes/canonical.php

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

     
    861861 
    862862if ( !function_exists('wp_redirect') ) : 
    863863/** 
    864  * Redirects to another page, with a workaround for the IIS Set-Cookie bug. 
     864 * Redirects to another page 
    865865 * 
    866  * @link http://support.microsoft.com/kb/q176113/ 
    867866 * @since 1.5.1 
    868867 * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status. 
    869868 * 
     
    872871 * @return bool False if $location is not set 
    873872 */ 
    874873function wp_redirect($location, $status = 302) { 
    875         global $is_IIS; 
    876  
    877874        $location = apply_filters('wp_redirect', $location, $status); 
    878875        $status = apply_filters('wp_redirect_status', $status, $location); 
    879876 
     
    881878                return false; 
    882879 
    883880        $location = wp_sanitize_redirect($location); 
    884  
    885         if ( $is_IIS ) { 
    886                 header("Refresh: 0;url=$location"); 
    887         } else { 
    888                 if ( php_sapi_name() != 'cgi-fcgi' ) 
    889                         status_header($status); // This causes problems on IIS and some FastCGI setups 
    890                 header("Location: $location", true, $status); 
    891         } 
     881        header("Location: $location", true, $status); 
    892882} 
    893883endif; 
    894884 
  • 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