wppaste
WordPress

WP_Automatic_Updater::send_debug_email()

Since
3.7.0
Source
wp-admin/includes/class-wp-automatic-updater.php:1559
Prepares and sends an email of a full log of background update results, useful for debugging and geekery.

Compatibility

WordPress
since 3.7.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.

Performance profile

How much work a call to WP_Automatic_Updater::send_debug_email() 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
Expensive

Sends mail via wp_mail().

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
102–142

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 376.

Plugin surface
1 hook

Third-party callbacks on 'automatic_updates_debug_email' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • querycontent queryget_user_by()called directly
  • optionnetwork optionget_site_option()called directly
  • hookthird-party callbacksapply_filters()called directly
  • mailsends mailwp_mail()called directly

Further down the call graph this can also reach cache, serialize 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 · 48 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Automatic_Updater::send_debug_email() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!isset($value)102–104get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
!isset($value)103–105get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
!isset($value)104–106get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
!isset($value)104–106get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
!isset($value)105–107get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
!isset($value)105–107get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
!isset($value)106–108get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
!isset($value)107–109get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
!isset($value)111–113get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
!isset($value)112–114get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
!isset($value)113–115get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
!isset($value)113–115get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
36 further outcomes, up to 142 instructions
!isset($value)114–116get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
!isset($value)114–116get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
!isset($value)115–117get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
!isset($value)116–118get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && !$result120–122get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && !$result121–123get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && !$result122–124get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && !$result122–124get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && !$result123–125get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && !$result123–125get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && !$result124–126get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && !$result125–127get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && $result126–128get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && $result127–129get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && $result128–130get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && $result128–130get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && $result129–131get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && !$result129–131get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && $result129–131get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && !$result130–132get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && $result130–132get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && !$result131–133get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && $result131–133get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && !$result131–133get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && !$result132–134get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && !$result132–134get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && !$result133–135get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && !$result134–136get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && $result135–137get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && $result136–138get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && $result137–139get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && $result137–139get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && $result138–140get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && $result138–140get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && $result139–141get_site_option(), get_user_by(), get_locale(), switch_to_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
isset($value) && $result140–142get_site_option(), get_user_by(), switch_to_user_locale(), __(), network_home_url(), sprintf(), is_wp_error(), __(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev376102–14232
8.5376102–14232
8.4376102–1423213 fewer instructions than PHP 8.3
8.3389107–14932
8.2389107–14932
8.1389107–14932
7.4389107–14932

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 · 1

One hook fires while WP_Automatic_Updater::send_debug_email() runs, in this order:

  1. apply_filters( automatic_updates_debug_email )filterline 1741 (+182 into the body)

    Filters the debug email that can be sent following an automatic background core update.

Uses · 16

Show all 16
  • home_url()Retrieves the URL for the current site where the front end is accessible.
  • apply_filters()Calls the callback functions that have been added to a filter hook.
  • wp_mail()Sends an email, similar to PHP's mail function.
  • restore_previous_locale()Restores the translations according to the previous locale.

Used by · 1

Source code

	protected function send_debug_email() {		$admin_user = get_user_by( 'email', get_site_option( 'admin_email' ) ); 		if ( $admin_user ) {			$switched_locale = switch_to_user_locale( $admin_user->ID );		} else {			$switched_locale = switch_to_locale( get_locale() );		} 		$body     = array();		$failures = 0; 		/* translators: %s: Network home URL. */		$body[] = sprintf( __( 'WordPress site: %s' ), network_home_url( '/' ) ); 		// Core.		if ( isset( $this->update_results['core'] ) ) {			$result = $this->update_results['core'][0]; 			if ( $result->result && ! is_wp_error( $result->result ) ) {				/* translators: %s: WordPress version. */				$body[] = sprintf( __( 'SUCCESS: WordPress was successfully updated to %s' ), $result->name );			} else {				/* translators: %s: WordPress version. */				$body[] = sprintf( __( 'FAILED: WordPress failed to update to %s' ), $result->name );				++$failures;			} 			$body[] = '';		} 		// Plugins, Themes, Translations.		foreach ( array( 'plugin', 'theme', 'translation' ) as $type ) {			if ( ! isset( $this->update_results[ $type ] ) ) {				continue;			} 			$success_items = wp_list_filter( $this->update_results[ $type ], array( 'result' => true ) ); 			if ( $success_items ) {				$messages = array(					'plugin'      => __( 'The following plugins were successfully updated:' ),					'theme'       => __( 'The following themes were successfully updated:' ),					'translation' => __( 'The following translations were successfully updated:' ),				); 				$body[] = $messages[ $type ];				foreach ( wp_list_pluck( $success_items, 'name' ) as $name ) {					/* translators: %s: Name of plugin / theme / translation. */					$body[] = ' * ' . sprintf( __( 'SUCCESS: %s' ), $name );				}			} 			if ( $success_items !== $this->update_results[ $type ] ) {				// Failed updates.				$messages = array(					'plugin'      => __( 'The following plugins failed to update:' ),					'theme'       => __( 'The following themes failed to update:' ),					'translation' => __( 'The following translations failed to update:' ),				); 				$body[] = $messages[ $type ]; 				foreach ( $this->update_results[ $type ] as $item ) {					if ( ! $item->result || is_wp_error( $item->result ) ) {						/* translators: %s: Name of plugin / theme / translation. */						$body[] = ' * ' . sprintf( __( 'FAILED: %s' ), $item->name );						++$failures;					}				}			} 			$body[] = '';		} 		if ( '' !== get_bloginfo( 'name' ) ) {			$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );		} else {			$site_title = parse_url( home_url(), PHP_URL_HOST );		}

Changelog

Introduced in 3.7.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-admin/includes/class-wp-automatic-updater.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.