Skip to content

Commit c6f239a

Browse files
committed
Fix fatal error on IIS after r16797. props peaceablewhale. Limit variable string searching when possible. See WordPress#10187
git-svn-id: https://develop.svn.wordpress.org/trunk@16904 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 7f21740 commit c6f239a

3 files changed

Lines changed: 30 additions & 30 deletions

File tree

wp-admin/includes/misc.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -378,34 +378,6 @@ function wp_menu_unfold() {
378378
}
379379
}
380380

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

wp-includes/canonical.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
* not needed or the string of the URL
3636
*/
3737
function redirect_canonical( $requested_url = null, $do_redirect = true ) {
38-
global $wp_rewrite, $is_IIS, $wp_query, $wpdb;
38+
global $wp_rewrite, $is_iis7, $wp_query, $wpdb;
3939

40-
if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || !empty($_POST) || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) )
40+
if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || !empty($_POST) || is_preview() || is_robots() || ( $is_iis7 && !iis7_supports_permalinks() ) )
4141
return;
4242

4343
if ( !$requested_url ) {

wp-includes/functions.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3421,6 +3421,34 @@ function apache_mod_loaded($mod, $default = false) {
34213421
return $default;
34223422
}
34233423

3424+
/**
3425+
* Check if IIS 7 supports pretty permalinks
3426+
*
3427+
* @since 2.8.0
3428+
*
3429+
* @return bool
3430+
*/
3431+
function iis7_supports_permalinks() {
3432+
global $is_iis7;
3433+
3434+
$supports_permalinks = false;
3435+
if ( $is_iis7 ) {
3436+
/* First we check if the DOMDocument class exists. If it does not exist,
3437+
* which is the case for PHP 4.X, then we cannot easily update the xml configuration file,
3438+
* hence we just bail out and tell user that pretty permalinks cannot be used.
3439+
* This is not a big issue because PHP 4.X is going to be depricated and for IIS it
3440+
* is recommended to use PHP 5.X NTS.
3441+
* Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When
3442+
* URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'.
3443+
* Lastly we make sure that PHP is running via FastCGI. This is important because if it runs
3444+
* via ISAPI then pretty permalinks will not work.
3445+
*/
3446+
$supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' );
3447+
}
3448+
3449+
return apply_filters('iis7_supports_permalinks', $supports_permalinks);
3450+
}
3451+
34243452
/**
34253453
* File validates against allowed set of defined rules.
34263454
*

0 commit comments

Comments
 (0)