wppaste
WordPress

WP_Recovery_Mode_Email_Service::send_recovery_mode_email( int $rate_limit, array $error, array $extension ): bool

Since
5.2.0
Source
wp-includes/class-wp-recovery-mode-email-service.php:114
Sends the Recovery Mode email to the site admin email address.

Compatibility

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

$rate_limitint
Number of seconds before another email can be sent.
$errorarray
Error details from error_get_last().
$extensionarray
The extension that caused the error.
  • $slugstring

    The extension slug. The directory of the plugin or theme.
  • $typestring

    The extension type. Either 'plugin' or 'theme'.

Return value

bool
Whether the email was sent successfully.

Performance profile

How much work a call to WP_Recovery_Mode_Email_Service::send_recovery_mode_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
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
116–148

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

Plugin surface
3 hooks

Third-party callbacks on 'recovery_email_support_info', 'recovery_email_debug_info', 'recovery_mode_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

  • optionoption read or writeget_option()called directly
  • hookthird-party callbacksapply_filters()called directly
  • mailsends mailwp_mail()called directly
  • cacheobject cachewp_cache_get()one call below WP_Recovery_Mode_Email_Service::send_recovery_mode_email()
  • serializeserialisationmaybe_unserialize()one call below WP_Recovery_Mode_Email_Service::send_recovery_mode_email()

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

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

WhenInstructionsCalls it makes
always116–119->generate_url(), get_option(), wp_specialchars_decode(), get_locale(), switch_to_locale(), __(), apply_filters(), ->get_debug(), apply_filters(), __(), time(), human_time_diff(), home_url(), home_url(), ->get_recovery_mode_email_address(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail()
always118–121->generate_url(), get_option(), wp_specialchars_decode(), get_locale(), switch_to_locale(), __(), apply_filters(), ->get_debug(), apply_filters(), __(), time(), human_time_diff(), home_url(), home_url(), ->get_recovery_mode_email_address(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
always126–129->generate_url(), get_option(), wp_specialchars_decode(), get_locale(), switch_to_locale(), ->get_cause(), wp_get_extension_error_description(), wp_strip_all_tags(), __(), apply_filters(), ->get_debug(), apply_filters(), __(), time(), human_time_diff(), home_url(), home_url(), ->get_recovery_mode_email_address(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail()
always128–131->generate_url(), get_option(), wp_specialchars_decode(), get_locale(), switch_to_locale(), ->get_cause(), wp_get_extension_error_description(), wp_strip_all_tags(), __(), apply_filters(), ->get_debug(), apply_filters(), __(), time(), human_time_diff(), home_url(), home_url(), ->get_recovery_mode_email_address(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
always143–146->generate_url(), get_option(), wp_specialchars_decode(), get_locale(), switch_to_locale(), ->get_cause(), wp_get_extension_error_description(), wp_strip_all_tags(), __(), str_pad(), __(), apply_filters(), ->get_debug(), apply_filters(), __(), time(), human_time_diff(), home_url(), home_url(), ->get_recovery_mode_email_address(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail()
always145–148->generate_url(), get_option(), wp_specialchars_decode(), get_locale(), switch_to_locale(), ->get_cause(), wp_get_extension_error_description(), wp_strip_all_tags(), __(), str_pad(), __(), apply_filters(), ->get_debug(), apply_filters(), __(), time(), human_time_diff(), home_url(), home_url(), ->get_recovery_mode_email_address(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev151116–1484
8.5151116–1484
8.4151116–14846 fewer instructions than PHP 8.3
8.3157122–1544
8.2157122–1544
8.1157122–15441 fewer instruction than PHP 7.4
7.4158122–1554

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

3 hooks fire while WP_Recovery_Mode_Email_Service::send_recovery_mode_email() runs, in this order:

  1. apply_filters( recovery_email_support_info )filterline 141 (+27 into the body)

    Filters the support message sent with the the fatal error protection email.

  2. apply_filters( recovery_email_debug_info )filterline 150 (+36 into the body)

    Filters the debug information included in the fatal error protection email.

  3. apply_filters( recovery_mode_email )filterline 223 (+109 into the body)

    Filters the contents of the Recovery Mode email.

Uses · 15

Show all 15

Used by · 1

Source code

	private function send_recovery_mode_email( $rate_limit, $error, $extension ) { 		$url      = $this->link_service->generate_url();		$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 		$switched_locale = switch_to_locale( get_locale() ); 		if ( $extension ) {			$cause   = $this->get_cause( $extension );			$details = wp_strip_all_tags( wp_get_extension_error_description( $error ) ); 			if ( $details ) {				$header  = __( 'Error Details' );				$details = "\n\n" . $header . "\n" . str_pad( '', strlen( $header ), '=' ) . "\n" . $details;			}		} else {			$cause   = '';			$details = '';		} 		/**		 * Filters the support message sent with the the fatal error protection email.		 *		 * @since 5.2.0		 *		 * @param string $message The Message to include in the email.		 */		$support = apply_filters( 'recovery_email_support_info', __( 'Please contact your host for assistance with investigating this issue further.' ) ); 		/**		 * Filters the debug information included in the fatal error protection email.		 *		 * @since 5.3.0		 *		 * @param array $message An associative array of debug information.		 */		$debug = apply_filters( 'recovery_email_debug_info', $this->get_debug( $extension ) ); 		/* translators: Do not translate LINK, EXPIRES, CAUSE, DETAILS, SITEURL, PAGEURL, SUPPORT. DEBUG: those are placeholders. */		$message = __(			'Howdy! WordPress has a built-in feature that detects when a plugin or theme causes a fatal error on your site, and notifies you with this automated email.###CAUSE###First, visit your website (###SITEURL###) and check for any visible issues. Next, visit the page where the error was caught (###PAGEURL###) and check for any visible issues. ###SUPPORT### If your site appears broken and you can\'t access your dashboard normally, WordPress now has a special "recovery mode". This lets you safely login to your dashboard and investigate further. ###LINK### To keep your site safe, this link will expire in ###EXPIRES###. Don\'t worry about that, though: a new link will be emailed to you if the error occurs again after it expires. When seeking help with this issue, you may be asked for some of the following information:###DEBUG### ###DETAILS###'		);		$message = str_replace(			array(				'###LINK###',				'###EXPIRES###',				'###CAUSE###',				'###DETAILS###',				'###SITEURL###',				'###PAGEURL###',				'###SUPPORT###',				'###DEBUG###',			),			array(				$url,				human_time_diff( time() + $rate_limit ),				$cause ? "\n{$cause}\n" : "\n",				$details,				home_url( '/' ),				home_url( $_SERVER['REQUEST_URI'] ),				$support,				implode( "\r\n", $debug ),			),

Changelog

Introduced in 5.2.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 7.0.4 tag, from src/wp-includes/class-wp-recovery-mode-email-service.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.