WP_Ajax_Upgrader_Skin::error( string|WP_Error $errors, mixed $args )
- Since
- 4.6.0, 5.3.0
- Source
wp-admin/includes/class-wp-ajax-upgrader-skin.php:114
Compatibility
- WordPress
- since 5.3.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.
Parameters
$errorsstring|WP_Error- Errors.
$argsmixed- Optional text replacements.
Performance profile
How much work a call to WP_Ajax_Upgrader_Skin::error() 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
- Light
- Scaling
- Scales with input
- Instructions
- 14–40
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 62.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
do_action()one call below WP_Ajax_Upgrader_Skin::error()
What one call costs · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Ajax_Upgrader_Skin::error() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!is_string($errors) && !is_wp_error() | 14 | is_wp_error(), ::error() |
!is_string($errors) && is_wp_error() | 18–19 | is_wp_error(), ->get_error_codes(), ::error() |
is_string($errors) | 29–35 | ->get_error_codes(), ->add(), ::error() |
is_string($errors) && $string && !empty($args) | 36–40 | vsprintf(), ->get_error_codes(), ->add(), ::error() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 62 | 14–40 | 7 | |
| 8.5 | 62 | 14–40 | 7 | |
| 8.4 | 62 | 14–40 | 7 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 65 | 14–43 | 7 | |
| 8.2 | 65 | 14–43 | 7 | |
| 8.1 | 65 | 14–43 | 7 | 1 more instruction than PHP 7.4 |
| 7.4 | 64 | 13–42 | 7 |
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 · 3
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- Automatic_Upgrader_Skin::error()
Source code
public function error( $errors, ...$args ) { if ( is_string( $errors ) ) { $string = $errors; if ( ! empty( $this->upgrader->strings[ $string ] ) ) { $string = $this->upgrader->strings[ $string ]; } if ( str_contains( $string, '%' ) ) { if ( ! empty( $args ) ) { $string = vsprintf( $string, $args ); } } // Count existing errors to generate a unique error code. $errors_count = count( $this->errors->get_error_codes() ); $this->errors->add( 'unknown_upgrade_error_' . ( $errors_count + 1 ), $string ); } elseif ( is_wp_error( $errors ) ) { foreach ( $errors->get_error_codes() as $error_code ) { $this->errors->add( $error_code, $errors->get_error_message( $error_code ), $errors->get_error_data( $error_code ) ); } } parent::error( $errors, ...$args ); }Changelog
Introduced in 4.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
...$args parameter by adding it to the function signature.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-admin/includes/class-wp-ajax-upgrader-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.