Plugin_Installer_Skin::do_overwrite(): bool
- Since
- 5.5.0
- Source
wp-admin/includes/class-plugin-installer-skin.php:192
Compatibility
- WordPress
- since 5.5.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- Whether the plugin can be overwritten and HTML was outputted.
Performance profile
How much work a call to Plugin_Installer_Skin::do_overwrite() 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
- Moderate
- Scaling
- Scales with input
- Instructions
- 4–257
- Plugin surface
- 2 hooks
- Called by
- 1
Only touches the object cache, via wp_cache_get().
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 330.
Third-party callbacks on 'install_plugin_overwrite_comparison', 'install_plugin_overwrite_actions' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly - cacheobject cache
wp_cache_get()one call below Plugin_Installer_Skin::do_overwrite()
Further down the call graph this can also reach option, 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 · 20 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost Plugin_Installer_Skin::do_overwrite() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 4 | none |
!is_wp_error() | 10 | is_wp_error() |
is_wp_error() | 15 | is_wp_error(), ->get_error_code() |
is_wp_error() | 37–39 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins() |
is_wp_error() && is_php_version_compatible() && is_wp_version_compatible() && empty($install_actions) | 160–164 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), is_wp_version_compatible(), add_query_arg(), wp_nonce_url(), __(), apply_filters() |
is_wp_error() && is_php_version_compatible() && is_wp_version_compatible() && !empty($install_actions) | 172–176 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), is_wp_version_compatible(), add_query_arg(), wp_nonce_url(), __(), apply_filters(), __(), printf() |
is_wp_error() && !is_php_version_compatible() && is_wp_version_compatible() && empty($install_actions) | 176–180 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), __(), sprintf(), esc_html(), is_wp_version_compatible(), add_query_arg(), wp_nonce_url(), __(), apply_filters() |
is_wp_error() && is_php_version_compatible() && !is_wp_version_compatible() && empty($install_actions) | 181–185 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), is_wp_version_compatible(), __(), wp_get_wp_version(), esc_html(), sprintf(), esc_html(), add_query_arg(), wp_nonce_url(), __(), apply_filters() |
is_wp_error() && !is_php_version_compatible() && is_wp_version_compatible() && !empty($install_actions) | 188–192 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), __(), sprintf(), esc_html(), is_wp_version_compatible(), add_query_arg(), wp_nonce_url(), __(), apply_filters(), __(), printf() |
is_wp_error() && is_php_version_compatible() && !is_wp_version_compatible() && !empty($install_actions) | 193–197 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), is_wp_version_compatible(), __(), wp_get_wp_version(), esc_html(), sprintf(), esc_html(), add_query_arg(), wp_nonce_url(), __(), apply_filters(), __(), printf() |
is_wp_error() && !is_php_version_compatible() && !is_wp_version_compatible() && empty($install_actions) | 197–201 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), __(), sprintf(), esc_html(), is_wp_version_compatible(), __(), wp_get_wp_version(), esc_html(), sprintf(), esc_html(), add_query_arg(), wp_nonce_url(), __(), apply_filters() |
is_wp_error() && is_php_version_compatible() && is_wp_version_compatible() && empty($install_actions) | 202–208 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), is_wp_version_compatible(), __(), __(), sprintf(), add_query_arg(), wp_nonce_url(), _x(), add_query_arg(), wp_nonce_url(), __(), apply_filters() |
8 further outcomes, up to 257 instructions
is_wp_error() && !is_php_version_compatible() && !is_wp_version_compatible() && !empty($install_actions) | 209–213 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), __(), sprintf(), esc_html(), is_wp_version_compatible(), __(), wp_get_wp_version(), esc_html(), sprintf(), esc_html(), add_query_arg(), wp_nonce_url(), __(), apply_filters(), __(), printf() |
is_wp_error() && is_php_version_compatible() && is_wp_version_compatible() && !empty($install_actions) | 214–220 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), is_wp_version_compatible(), __(), __(), sprintf(), add_query_arg(), wp_nonce_url(), _x(), add_query_arg(), wp_nonce_url(), __(), apply_filters(), __(), printf() |
is_wp_error() && !is_php_version_compatible() && is_wp_version_compatible() && empty($install_actions) | 218–224 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), __(), sprintf(), esc_html(), is_wp_version_compatible(), __(), __(), sprintf(), add_query_arg(), wp_nonce_url(), _x(), add_query_arg(), wp_nonce_url(), __(), apply_filters() |
is_wp_error() && is_php_version_compatible() && !is_wp_version_compatible() && empty($install_actions) | 223–229 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), is_wp_version_compatible(), __(), wp_get_wp_version(), esc_html(), sprintf(), esc_html(), __(), __(), sprintf(), add_query_arg(), wp_nonce_url(), _x(), add_query_arg(), wp_nonce_url(), __(), apply_filters() |
is_wp_error() && !is_php_version_compatible() && is_wp_version_compatible() && !empty($install_actions) | 230–236 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), __(), sprintf(), esc_html(), is_wp_version_compatible(), __(), __(), sprintf(), add_query_arg(), wp_nonce_url(), _x(), add_query_arg(), wp_nonce_url(), __(), apply_filters(), __(), printf() |
is_wp_error() && is_php_version_compatible() && !is_wp_version_compatible() && !empty($install_actions) | 235–241 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), is_wp_version_compatible(), __(), wp_get_wp_version(), esc_html(), sprintf(), esc_html(), __(), __(), sprintf(), add_query_arg(), wp_nonce_url(), _x(), add_query_arg(), wp_nonce_url(), __(), apply_filters(), __(), printf() |
is_wp_error() && !is_php_version_compatible() && !is_wp_version_compatible() && empty($install_actions) | 239–245 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), __(), sprintf(), esc_html(), is_wp_version_compatible(), __(), wp_get_wp_version(), esc_html(), sprintf(), esc_html(), __(), __(), sprintf(), add_query_arg(), wp_nonce_url(), _x(), add_query_arg(), wp_nonce_url(), __(), apply_filters() |
is_wp_error() && !is_php_version_compatible() && !is_wp_version_compatible() && !empty($install_actions) | 251–257 | is_wp_error(), ->get_error_code(), ->get_error_data(), ltrim(), get_plugins(), esc_html__(), version_compare(), __(), __(), __(), __(), __(), esc_html_x(), esc_html_x(), apply_filters(), esc_html__(), is_php_version_compatible(), __(), sprintf(), esc_html(), is_wp_version_compatible(), __(), wp_get_wp_version(), esc_html(), sprintf(), esc_html(), __(), __(), sprintf(), add_query_arg(), wp_nonce_url(), _x(), add_query_arg(), wp_nonce_url(), __(), apply_filters(), __(), printf() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 330 | 4–257 | 25 | |
| 8.5 | 330 | 4–257 | 25 | |
| 8.4 | 330 | 4–257 | 25 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 336 | 4–263 | 25 | |
| 8.2 | 336 | 4–263 | 25 | |
| 8.1 | 336 | 4–263 | 25 | 4 fewer instructions than PHP 7.4 |
| 7.4 | 340 | 4–265 | 25 |
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.
Hooks and filters fired · 2
2 hooks fire while Plugin_Installer_Skin::do_overwrite() runs, in this order:
- apply_filters( install_plugin_overwrite_comparison )filterline 260 (+68 into the body)
Filters the compare table output for overwriting a plugin package on upload.
- apply_filters( install_plugin_overwrite_actions )filterline 343 (+151 into the body)
Filters the list of action links available following a single plugin installation failure when overwriting is allowed.
Uses · 14
- is_wp_error()Checks whether the given variable is a WordPress Error.
- get_plugins()Checks the plugins directory and retrieve all plugin files with plugin data.
- esc_html__()Retrieves the translation of $text and escapes it for safe use in HTML output.
- __()Retrieves the translation of $text.
- esc_html_x()Translates string with gettext context, and escapes it for safe use in HTML output.
- wp_strip_all_tags()Properly strips all HTML tags including 'script' and 'style'.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- is_php_version_compatible()Checks compatibility with the current PHP version.
- esc_html()Escaping for HTML blocks.
- is_wp_version_compatible()Checks compatibility with the current WordPress version.
- wp_get_wp_version()Returns the current WordPress version.
- wp_nonce_url()Retrieves URL with nonce added to URL query.
Show all 14
- add_query_arg()Retrieves a modified URL query string.
- _x()Retrieves translated string with gettext context.
Used by · 1
- Plugin_Installer_Skin::after()Performs an action following a plugin install.
Source code
private function do_overwrite() { if ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) { return false; } $folder = $this->result->get_error_data( 'folder_exists' ); $folder = ltrim( substr( $folder, strlen( WP_PLUGIN_DIR ) ), '/' ); $current_plugin_data = false; $all_plugins = get_plugins(); foreach ( $all_plugins as $plugin => $plugin_data ) { if ( strrpos( $plugin, $folder ) !== 0 ) { continue; } $current_plugin_data = $plugin_data; } $new_plugin_data = $this->upgrader->new_plugin_data; if ( ! $current_plugin_data || ! $new_plugin_data ) { return false; } echo '<h2 class="update-from-upload-heading">' . esc_html__( 'This plugin is already installed.' ) . '</h2>'; $this->is_downgrading = version_compare( $current_plugin_data['Version'], $new_plugin_data['Version'], '>' ); $rows = array( 'Name' => __( 'Plugin name' ), 'Version' => __( 'Version' ), 'Author' => __( 'Author' ), 'RequiresWP' => __( 'Required WordPress version' ), 'RequiresPHP' => __( 'Required PHP version' ), ); $table = '<table class="update-from-upload-comparison"><tbody>'; $table .= '<tr><th></th><th>' . esc_html_x( 'Current', 'plugin' ) . '</th>'; $table .= '<th>' . esc_html_x( 'Uploaded', 'plugin' ) . '</th></tr>'; $is_same_plugin = true; // Let's consider only these rows. foreach ( $rows as $field => $label ) { $old_value = ! empty( $current_plugin_data[ $field ] ) ? (string) $current_plugin_data[ $field ] : '-'; $new_value = ! empty( $new_plugin_data[ $field ] ) ? (string) $new_plugin_data[ $field ] : '-'; $is_same_plugin = $is_same_plugin && ( $old_value === $new_value ); $diff_field = ( 'Version' !== $field && $new_value !== $old_value ); $diff_version = ( 'Version' === $field && $this->is_downgrading ); $table .= '<tr><td class="name-label">' . $label . '</td><td>' . wp_strip_all_tags( $old_value ) . '</td>'; $table .= ( $diff_field || $diff_version ) ? '<td class="warning">' : '<td>'; $table .= wp_strip_all_tags( $new_value ) . '</td></tr>'; } $table .= '</tbody></table>'; /** * Filters the compare table output for overwriting a plugin package on upload. * * @since 5.5.0 * * @param string $table The output table with Name, Version, Author, RequiresWP, and RequiresPHP info. * @param array $current_plugin_data Array with current plugin data. * @param array $new_plugin_data Array with uploaded plugin data. */ echo apply_filters( 'install_plugin_overwrite_comparison', $table, $current_plugin_data, $new_plugin_data ); $install_actions = array(); $can_update = true; $blocked_message = '<p>' . esc_html__( 'The plugin cannot be updated due to the following:' ) . '</p>'; $blocked_message .= '<ul class="ul-disc">'; $requires_php = isset( $new_plugin_data['RequiresPHP'] ) ? $new_plugin_data['RequiresPHP'] : null; $requires_wp = isset( $new_plugin_data['RequiresWP'] ) ? $new_plugin_data['RequiresWP'] : null; if ( ! is_php_version_compatible( $requires_php ) ) {Changelog
Introduced in 5.5.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 6.7.7 tag, from
src/wp-admin/includes/class-plugin-installer-skin.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.