WordPress.org

Make WordPress Core

Ticket #10435: 10435.patch

File 10435.patch, 3.6 KB (added by peaceablewhale, 6 years ago)
  • wp-admin/includes/misc.php

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

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