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
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.
$slugstringThe extension slug. The directory of the plugin or theme.$typestringThe 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
- Scaling
- Constant
- Instructions
- 116–148
- Plugin surface
- 3 hooks
- Called by
- 1
Sends mail via wp_mail().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 151.
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.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()called directly - mailsends mail
wp_mail()called directly - cacheobject cache
wp_cache_get()one call below WP_Recovery_Mode_Email_Service::send_recovery_mode_email() - serializeserialisation
maybe_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.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 116–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() |
| always | 118–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() |
| always | 126–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() |
| always | 128–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() |
| always | 143–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() |
| always | 145–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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 151 | 116–148 | 4 | |
| 8.5 | 151 | 116–148 | 4 | |
| 8.4 | 151 | 116–148 | 4 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 157 | 122–154 | 4 | |
| 8.2 | 157 | 122–154 | 4 | |
| 8.1 | 157 | 122–154 | 4 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 158 | 122–155 | 4 |
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:
- apply_filters( recovery_email_support_info )filterline 141 (+27 into the body)
Filters the support message sent with the fatal error protection email.
- apply_filters( recovery_email_debug_info )filterline 150 (+36 into the body)
Filters the debug information included in the fatal error protection email.
- apply_filters( recovery_mode_email )filterline 223 (+109 into the body)
Filters the contents of the Recovery Mode email.
Uses · 15
- wp_specialchars_decode()Converts a number of HTML entities into their special characters.
- get_option()Retrieves an option value based on an option name.
- switch_to_locale()Switches the translations according to the given locale.
- get_locale()Retrieves the current locale.
- wp_strip_all_tags()Properly strips all HTML tags including 'script' and 'style'.
- wp_get_extension_error_description()Get a human readable description of an extension's error.
- __()Retrieves the translation of $text.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- human_time_diff()Determines the difference between two timestamps.
- home_url()Retrieves the URL for the current site where the front end is accessible.
- wp_mail()Sends an email, similar to PHP's mail function.
- restore_previous_locale()Restores the translations according to the previous locale.
Show all 15
- WP_Recovery_Mode_Email_Service::get_cause()Gets the description indicating the possible cause for the error.
- WP_Recovery_Mode_Email_Service::get_debug()Return debug information in an easy to manipulate format.
- WP_Recovery_Mode_Email_Service::get_recovery_mode_email_address()Gets the email address to send the recovery mode link to.
Used by · 1
- WP_Recovery_Mode_Email_Service::maybe_send_recovery_mode_email()Sends the recovery mode email if the rate limit has not been sent.
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 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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 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.