wppaste
WordPress

WP_Automatic_Updater::send_debug_email()

Since
3.7.0
Source
wp-admin/includes/class-wp-automatic-updater.php:1536
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
90–128

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

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

  • 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, 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 · 12 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)90–93__(), network_home_url(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
!isset($value)92–95__(), network_home_url(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
!isset($value)99–102__(), network_home_url(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
!isset($value)101–104__(), network_home_url(), sprintf(), get_bloginfo(), get_bloginfo(), wp_specialchars_decode(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && !$result108–111__(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && !$result110–113__(), 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) && $result114–117__(), 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) && $result116–119__(), 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) && !$result117–120__(), network_home_url(), sprintf(), __(), sprintf(), get_bloginfo(), home_url(), parse_url(), __(), __(), sprintf(), __(), get_site_option(), apply_filters(), wp_specialchars_decode(), wp_mail()
isset($value) && !$result119–122__(), 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–126__(), 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) && $result125–128__(), 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()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev36090–12832
8.536090–12832
8.436090–1283213 fewer instructions than PHP 8.3
8.337395–13532
8.237395–13532
8.137395–13532
7.437395–13532

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 1715 (+179 into the body)

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

Uses · 11

  • __()Retrieves the translation of $text.
  • network_home_url()Retrieves the home URL for the current network.
  • is_wp_error()Checks whether the given variable is a WordPress Error.
  • wp_list_filter()Filters a list of objects, based on a set of key => value arguments.
  • wp_list_pluck()Plucks a certain field out of each object or array in an array.
  • get_bloginfo()Retrieves information about the current site.
  • wp_specialchars_decode()Converts a number of HTML entities into their special characters.
  • home_url()Retrieves the URL for the current site where the front end is accessible.
  • get_site_option()Retrieve an option value for the current network based on name of option.
  • 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.

Used by · 1

Source code

	protected function send_debug_email() {		$update_count = 0;		foreach ( $this->update_results as $type => $updates ) {			$update_count += count( $updates );		} 		$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 );		} 		if ( $failures ) {			$body[] = trim(

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.7.7 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.