WordPress.org

Make WordPress Core

Ticket #10384: 10384-whale.patch

File 10384-whale.patch, 13.4 KB (added by peaceablewhale, 5 years ago)
  • wp-admin/includes/misc.php

     
    141141 * Updates the IIS web.config file with the current rules if it is writable. 
    142142 * If the permalinks do not require rewrite rules then the rules are deleted from the web.config file. 
    143143 * 
    144  * @since 2.8.0 
     144 * @since 2.9.0 
    145145 * 
    146146 * @return bool True if web.config was updated successfully 
    147147 */ 
    148 function iis7_save_url_rewrite_rules(){ 
     148function iis_save_url_rewrite_rules() { 
    149149        global $wp_rewrite; 
    150150 
    151151        $home_path = get_home_path(); 
     
    153153 
    154154        // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP 
    155155        if ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) { 
    156                 if ( iis7_supports_permalinks() ) { 
    157                         $rule = $wp_rewrite->iis7_url_rewrite_rules(); 
     156                if ( iis_supports_permalinks() ) { 
     157                        $rule = $wp_rewrite->iis_url_rewrite_rules(); 
    158158                        if ( ! empty($rule) ) { 
    159                                 return iis7_add_rewrite_rule($web_config_file, $rule); 
     159                                return iis_add_rewrite_rule($web_config_file, $rule); 
    160160                        } else { 
    161                                 return iis7_delete_rewrite_rule($web_config_file); 
     161                                return iis_delete_rewrite_rule($web_config_file); 
    162162                        } 
    163163                } 
    164164        } 
     
    429429} 
    430430 
    431431/** 
    432  * Check if IIS 7 supports pretty permalinks 
     432 * Check if IIS supports pretty permalinks via URL Rewrite Module 
    433433 * 
    434  * @since 2.8.0 
     434 * @since 2.9.0 
    435435 * 
    436436 * @return bool 
    437437 */ 
    438 function iis7_supports_permalinks() { 
    439         global $is_iis7; 
     438function iis_supports_permalinks() { 
     439        global $is_IIS; 
    440440 
    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); 
     441        /* First we check if the DOMDocument class exists. If it does not exist, 
     442         * which is the case for PHP 4.X, then we cannot easily update the xml configuration file, 
     443         * hence we just bail out and tell user that pretty permalinks cannot be used. 
     444         * This is not a big issue because PHP 4.X is going to be depricated and for IIS it 
     445         * is recommended to use PHP 5.X NTS. 
     446         * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When 
     447         * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'. 
     448         * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs 
     449         * via ISAPI then pretty permalinks will not work. 
     450         */ 
     451        $supports_permalinks = $is_IIS && class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' ); 
     452         
     453        $supports_permalinks = apply_filters('iis7_supports_permalinks', $supports_permalinks); 
     454         
     455        return apply_filters('iis_supports_permalinks', $supports_permalinks); 
    457456} 
    458457 
    459458/** 
    460  * Check if rewrite rule for WordPress already exists in the IIS 7 configuration file 
     459 * Check if rewrite rule for WordPress already exists in the IIS configuration file 
    461460 * 
    462  * @since 2.8.0 
     461 * @since 2.9.0 
    463462 * 
    464463 * @return bool 
    465464 * @param string $filename The file path to the configuration file 
    466465 */ 
    467 function iis7_rewrite_rule_exists($filename) { 
     466function iis_rewrite_rule_exists($filename) { 
    468467        if ( ! file_exists($filename) ) 
    469468                return false; 
    470469        if ( ! class_exists('DOMDocument') ) 
     
    484483/** 
    485484 * Delete WordPress rewrite rule from web.config file if it exists there 
    486485 * 
    487  * @since 2.8.0 
     486 * @since 2.9.0 
    488487 * 
    489488 * @param string $filename Name of the configuration file 
    490489 * @return bool 
    491490 */ 
    492 function iis7_delete_rewrite_rule($filename) { 
     491function iis_delete_rewrite_rule($filename) { 
    493492        // If configuration file does not exist then rules also do not exist so there is nothing to delete 
    494493        if ( ! file_exists($filename) ) 
    495494                return true; 
     
    515514} 
    516515 
    517516/** 
    518  * Add WordPress rewrite rule to the IIS 7 configuration file. 
     517 * Add WordPress rewrite rule to the IIS configuration file. 
    519518 * 
    520  * @since 2.8.0 
     519 * @since 2.9.0 
    521520 * 
    522521 * @param string $filename The file path to the configuration file 
    523522 * @param string $rewrite_rule The XML fragment with URL Rewrite rule 
    524523 * @return bool 
    525524 */ 
    526 function iis7_add_rewrite_rule($filename, $rewrite_rule) { 
     525function iis_add_rewrite_rule($filename, $rewrite_rule) { 
    527526        if ( ! class_exists('DOMDocument') ) 
    528527                return false; 
    529528 
  • wp-admin/options-permalink.php

     
    7070include('admin-header.php'); 
    7171 
    7272$home_path = get_home_path(); 
    73 $iis7_permalinks = iis7_supports_permalinks(); 
     73$iis_permalinks = iis_supports_permalinks(); 
    7474 
    7575if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) { 
    7676        check_admin_referer('update-permalink'); 
     
    101101$category_base = get_option('category_base'); 
    102102$tag_base = get_option( 'tag_base' ); 
    103103 
    104 if ( $iis7_permalinks ) { 
     104if ( $iis_permalinks ) { 
    105105        if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') ) 
    106106                $writable = true; 
    107107        else 
     
    123123 
    124124<?php if (isset($_POST['submit'])) : ?> 
    125125<div id="message" class="updated fade"><p><?php 
    126 if ( $iis7_permalinks ) { 
     126if ( $iis_permalinks ) { 
    127127        if ( $permalink_structure && ! $usingpi && ! $writable ) 
    128128                _e('You should update your web.config now'); 
    129129        else if ( $permalink_structure && ! $usingpi && $writable) 
     
    152152<?php 
    153153$prefix = ''; 
    154154 
    155 if ( ! got_mod_rewrite() && ! $iis7_permalinks ) 
     155if ( ! got_mod_rewrite() && ! $iis_permalinks ) 
    156156        $prefix = '/index.php'; 
    157157 
    158158$structures = array( 
     
    197197</table> 
    198198 
    199199<h3><?php _e('Optional'); ?></h3> 
    200 <?php if ( $is_apache || $iis7_permalinks ) : ?> 
     200<?php if ( $is_apache || $iis_permalinks ) : ?> 
    201201        <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <kbd>topics</kbd> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p> 
    202202<?php else : ?> 
    203203        <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code>http://example.org/index.php/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p> 
     
    221221        <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /> 
    222222</p> 
    223223  </form> 
    224 <?php if ($iis7_permalinks) : 
     224<?php if ($iis_permalinks) : 
    225225        if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) : ?> 
    226226<p><?php _e('If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/&lt;configuration&gt;/&lt;system.webServer&gt;/&lt;rewrite&gt;/&lt;rules&gt;</code> element in <code>web.config</code> file.') ?></p> 
    227227<form action="options-permalink.php" method="post"> 
    228228<?php wp_nonce_field('update-permalink') ?> 
    229         <p><textarea rows="10" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_html($wp_rewrite->iis7_url_rewrite_rules()); ?></textarea></p> 
     229        <p><textarea rows="10" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_html($wp_rewrite->iis_url_rewrite_rules()); ?></textarea></p> 
    230230</form> 
    231231<p><?php _e('If you temporarily make your <code>web.config</code> file writable for us to generate rewrite rules automatically, do not forget to revert the permissions after rule has been saved.')  ?></p> 
    232232        <?php endif; ?> 
  • wp-includes/deprecated.php

     
    7474 */ 
    7575$tablepostmeta = $wpdb->postmeta; 
    7676 
     77/** 
     78 * Whether the server software is IIS 7.X 
     79 * @global bool $is_iis7 
     80 * @deprecated Detect IIS version using local code 
     81 */ 
     82$is_iis7 = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false); 
     83 
    7784/* 
    7885 * Deprecated functions come here to die. 
    7986 */ 
     
    16901697        the_author_meta('ID'); 
    16911698} 
    16921699 
     1700/** 
     1701 * Updates the IIS web.config file with the current rules if it is writable. 
     1702 * If the permalinks do not require rewrite rules then the rules are deleted from the web.config file. 
     1703 * 
     1704 * @since 2.8.0 
     1705 * @deprecated 2.9.0 
     1706 * @uses iis_save_url_rewrite_rules() 
     1707 */ 
     1708function iis7_save_url_rewrite_rules() { 
     1709        _deprecated_function(__FUNCTION__, '2.9', 'iis_save_url_rewrite_rules()'); 
     1710        return iis_save_url_rewrite_rules(); 
     1711} 
     1712 
     1713/** 
     1714 * Check if IIS 7 supports pretty permalinks 
     1715 * 
     1716 * @since 2.8.0 
     1717 * @deprecated 2.9.0 
     1718 * @uses iis_supports_permalinks() 
     1719 */ 
     1720function iis7_supports_permalinks() { 
     1721        _deprecated_function(__FUNCTION__, '2.9', 'iis_supports_permalinks()'); 
     1722        return iis_supports_permalinks(); 
     1723} 
     1724 
     1725/** 
     1726 * Check if rewrite rule for WordPress already exists in the IIS 7 configuration file 
     1727 * 
     1728 * @since 2.8.0 
     1729 * @deprecated 2.9.0 
     1730 * @uses iis_supports_permalinks($filename) 
     1731 */ 
     1732function iis7_rewrite_rule_exists($filename) { 
     1733        _deprecated_function(__FUNCTION__, '2.9', 'iis_rewrite_rule_exists($filename)'); 
     1734        return iis_rewrite_rule_exists($filename); 
     1735} 
     1736 
     1737/** 
     1738 * Delete WordPress rewrite rule from web.config file if it exists there 
     1739 * 
     1740 * @since 2.8.0 
     1741 * @deprecated 2.9.0 
     1742 * @uses iis_delete_rewrite_rule($filename) 
     1743 */ 
     1744function iis7_delete_rewrite_rule($filename) { 
     1745        _deprecated_function(__FUNCTION__, '2.9', 'iis_delete_rewrite_rule($filename)'); 
     1746        return iis_delete_rewrite_rule($filename); 
     1747} 
     1748 
     1749/** 
     1750 * Add WordPress rewrite rule to the IIS 7 configuration file. 
     1751 * 
     1752 * @since 2.8.0 
     1753 * @deprecated 2.9.0 
     1754 * @uses iis_add_rewrite_rule($filename, $rewrite_rule) 
     1755 */ 
     1756function iis7_add_rewrite_rule($filename, $rewrite_rule) { 
     1757        _deprecated_function(__FUNCTION__, '2.9', 'iis_add_rewrite_rule($filename, $rewrite_rule)'); 
     1758        return iis_add_rewrite_rule($filename, $rewrite_rule); 
     1759} 
     1760 
     1761 
     1762/** 
     1763 * Retrieve IIS 7 URL Rewrite formatted rewrite rules to write to web.config file. 
     1764 * 
     1765 * Does not actually write to the web.config file, but creates the rules for 
     1766 * the process that will. 
     1767 * 
     1768 * @since 2.8.0 
     1769 * @deprecated 2.9.0 
     1770 * @uses iis_url_rewrite_rules() 
     1771 */ 
     1772function iis7_url_rewrite_rules() { 
     1773        _deprecated_function(__FUNCTION__, '2.9', 'iis_url_rewrite_rules()'); 
     1774        return iis_url_rewrite_rules(); 
     1775} 
    16931776?> 
     1777 No newline at end of file 
  • wp-includes/rewrite.php

     
    17051705        } 
    17061706 
    17071707        /** 
    1708          * Retrieve IIS7 URL Rewrite formatted rewrite rules to write to web.config file. 
     1708         * Retrieve IIS URL Rewrite formatted rewrite rules to write to web.config file. 
    17091709         * 
    17101710         * Does not actually write to the web.config file, but creates the rules for 
    17111711         * the process that will. 
    17121712         * 
    1713          * @since 2.8.0 
     1713         * @since 2.9.0 
    17141714         * @access public 
    17151715         * 
    17161716         * @return string 
    17171717         */ 
    1718         function iis7_url_rewrite_rules(){ 
     1718        function iis_url_rewrite_rules() { 
    17191719 
    17201720                if ( ! $this->using_permalinks()) { 
    17211721                        return ''; 
     
    17301730                $rules .= "</rule>"; 
    17311731 
    17321732                $rules = apply_filters('iis7_url_rewrite_rules', $rules); 
     1733                $rules = apply_filters('iis_url_rewrite_rules', $rules); 
    17331734 
    17341735                return $rules; 
    17351736        } 
     
    18291830                $this->wp_rewrite_rules(); 
    18301831                if ( $hard && function_exists('save_mod_rewrite_rules') ) 
    18311832                        save_mod_rewrite_rules(); 
    1832                 if ( $hard && function_exists('iis7_save_url_rewrite_rules') ) 
    1833                         iis7_save_url_rewrite_rules(); 
     1833                if ( $hard && function_exists('iis_save_url_rewrite_rules') ) 
     1834                        iis_save_url_rewrite_rules(); 
    18341835        } 
    18351836 
    18361837        /** 
  • wp-includes/vars.php

     
    7373 */ 
    7474$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer') !== false); 
    7575 
    76 /** 
    77  * Whether the server software is IIS 7.X 
    78  * @global bool $is_iis7 
    79  */ 
    80 $is_iis7 = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false); 
    81  
    82  
    8376?> 
    84  No newline at end of file