iis7_save_url_rewrite_rules(): bool|null
- Since
- 2.8.0
- Source
wp-admin/includes/misc.php:302
Description
If the permalinks do not require rewrite rules then the rules are deleted from the web.config file.
Compatibility
- WordPress
- since 2.8.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Return value
bool|null- True on write success, false on failure. Null in multisite.
Performance profile
How much work a call to iis7_save_url_rewrite_rules() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Constant
- Instructions
- 5–41
- Plugin surface
- None
- Called by
- 1
Reads or writes the filesystem via file_exists().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 47.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- filesystemfilesystem access
file_exists()called directly - optionoption read or write
get_option()one call below iis7_save_url_rewrite_rules() - hookthird-party callbacks
apply_filters()one call below iis7_save_url_rewrite_rules()
Further down the call graph this can also reach cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 13 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost iis7_save_url_rewrite_rules() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
is_multisite() | 5 | is_multisite() |
!is_multisite() && !iis7_supports_permalinks() | 16 | is_multisite(), get_home_path(), iis7_supports_permalinks() |
!is_multisite() && iis7_supports_permalinks() && file_exists() && !win_is_writable() | 24 | is_multisite(), get_home_path(), iis7_supports_permalinks(), file_exists(), win_is_writable() |
!is_multisite() && iis7_supports_permalinks() && !file_exists() && !win_is_writable() | 28 | is_multisite(), get_home_path(), iis7_supports_permalinks(), file_exists(), win_is_writable(), win_is_writable() |
!is_multisite() && iis7_supports_permalinks() && !file_exists() && !->using_mod_rewrite_permalinks() | 31 | is_multisite(), get_home_path(), iis7_supports_permalinks(), file_exists(), win_is_writable(), ->using_mod_rewrite_permalinks(), win_is_writable() |
!is_multisite() && iis7_supports_permalinks() && file_exists() && win_is_writable() && empty($rule) | 33 | is_multisite(), get_home_path(), iis7_supports_permalinks(), file_exists(), win_is_writable(), ->iis7_url_rewrite_rules(), iis7_delete_rewrite_rule() |
!is_multisite() && iis7_supports_permalinks() && file_exists() && win_is_writable() && !empty($rule) | 34 | is_multisite(), get_home_path(), iis7_supports_permalinks(), file_exists(), win_is_writable(), ->iis7_url_rewrite_rules(), iis7_add_rewrite_rule() |
!is_multisite() && iis7_supports_permalinks() && !file_exists() && win_is_writable() && ->using_mod_rewrite_permalinks() && empty($rule) | 36 | is_multisite(), get_home_path(), iis7_supports_permalinks(), file_exists(), win_is_writable(), ->using_mod_rewrite_permalinks(), ->iis7_url_rewrite_rules(), iis7_delete_rewrite_rule() |
!is_multisite() && iis7_supports_permalinks() && !file_exists() && empty($rule) | 37 | is_multisite(), get_home_path(), iis7_supports_permalinks(), file_exists(), win_is_writable(), win_is_writable(), ->iis7_url_rewrite_rules(), iis7_delete_rewrite_rule() |
!is_multisite() && iis7_supports_permalinks() && !file_exists() && win_is_writable() && ->using_mod_rewrite_permalinks() && !empty($rule) | 37 | is_multisite(), get_home_path(), iis7_supports_permalinks(), file_exists(), win_is_writable(), ->using_mod_rewrite_permalinks(), ->iis7_url_rewrite_rules(), iis7_add_rewrite_rule() |
!is_multisite() && iis7_supports_permalinks() && !file_exists() && !empty($rule) | 38 | is_multisite(), get_home_path(), iis7_supports_permalinks(), file_exists(), win_is_writable(), win_is_writable(), ->iis7_url_rewrite_rules(), iis7_add_rewrite_rule() |
!is_multisite() && iis7_supports_permalinks() && !file_exists() && win_is_writable() && !->using_mod_rewrite_permalinks() && empty($rule) | 40 | is_multisite(), get_home_path(), iis7_supports_permalinks(), file_exists(), win_is_writable(), ->using_mod_rewrite_permalinks(), win_is_writable(), ->iis7_url_rewrite_rules(), iis7_delete_rewrite_rule() |
1 further outcome, up to 41 instructions
!is_multisite() && iis7_supports_permalinks() && !file_exists() && win_is_writable() && !->using_mod_rewrite_permalinks() && !empty($rule) | 41 | is_multisite(), get_home_path(), iis7_supports_permalinks(), file_exists(), win_is_writable(), ->using_mod_rewrite_permalinks(), win_is_writable(), ->iis7_url_rewrite_rules(), iis7_add_rewrite_rule() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 47 instructions, 5–41 executed per call, 7 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 6
- is_multisite()Determines whether Multisite is enabled.
- get_home_path()Gets the absolute filesystem path to the root of the WordPress installation.
- iis7_supports_permalinks()Checks if IIS 7+ supports pretty permalinks.
- win_is_writable()Workaround for Windows bug in is_writable() function
- iis7_add_rewrite_rule()Adds WordPress rewrite rule to the IIS 7+ configuration file.
- iis7_delete_rewrite_rule()Deletes WordPress rewrite rule from web.config file if it exists there.
Used by · 1
- WP_Rewrite::flush_rules()Removes rewrite rules and then recreate rewrite rules.
Source code
function iis7_save_url_rewrite_rules() { global $wp_rewrite; if ( is_multisite() ) { return null; } // Ensure get_home_path() is declared. require_once ABSPATH . 'wp-admin/includes/file.php'; $home_path = get_home_path(); $web_config_file = $home_path . 'web.config'; // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP. if ( iis7_supports_permalinks() && ( ! file_exists( $web_config_file ) && win_is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() || win_is_writable( $web_config_file ) ) ) { $rule = $wp_rewrite->iis7_url_rewrite_rules( false ); if ( ! empty( $rule ) ) { return iis7_add_rewrite_rule( $web_config_file, $rule ); } else { return iis7_delete_rewrite_rule( $web_config_file ); } } return false;}Changelog
Introduced in 2.8.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-admin/includes/misc.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.