WP_Recovery_Mode_Email_Service::maybe_send_recovery_mode_email( int $rate_limit, array $error, array $extension ): true|WP_Error
- Since
- 5.2.0
- Source
wp-includes/class-wp-recovery-mode-email-service.php:53
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 plugin or theme's directory.$typestringThe extension type. Either 'plugin' or 'theme'.
Return value
true|WP_Error- True if email sent, WP_Error otherwise.
Performance profile
How much work a call to WP_Recovery_Mode_Email_Service::maybe_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
- Moderate
- Scaling
- Constant
- Instructions
- 25–41
- Plugin surface
- None
- Called by
- 0
Reads stored settings via get_option(), cached per request but not free on a cold cache.
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 71.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()one call below WP_Recovery_Mode_Email_Service::maybe_send_recovery_mode_email() - cacheobject cache
wp_cache_get()one call below WP_Recovery_Mode_Email_Service::maybe_send_recovery_mode_email() - serializeserialisation
maybe_unserialize()one call below WP_Recovery_Mode_Email_Service::maybe_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 · 7 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::maybe_send_recovery_mode_email() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
update_option() | 25 | get_option(), time(), update_option(), ->send_recovery_mode_email() |
!update_option() | 25 | get_option(), time(), update_option(), __() |
update_option() | 30 | get_option(), time(), time(), update_option(), ->send_recovery_mode_email() |
!update_option() | 30 | get_option(), time(), time(), update_option(), __() |
| always | 35 | get_option(), time(), __(), human_time_diff(), human_time_diff(), sprintf() |
update_option() | 36 | get_option(), time(), update_option(), ->send_recovery_mode_email(), __(), sprintf() |
update_option() | 41 | get_option(), time(), time(), update_option(), ->send_recovery_mode_email(), __(), sprintf() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 71 instructions, 25–41 executed per call, 4 branches. The work does not change between versions.
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 · 6
- get_option()Retrieves an option value based on an option name.
- update_option()Updates the value of an option that was already added.
- __()Retrieves the translation of $text.
- human_time_diff()Determines the difference between two timestamps.
- WP_Error::__construct()Initializes the error.
- WP_Recovery_Mode_Email_Service::send_recovery_mode_email()Sends the Recovery Mode email to the site admin email address.
Source code
public function maybe_send_recovery_mode_email( $rate_limit, $error, $extension ) { $last_sent = get_option( self::RATE_LIMIT_OPTION ); if ( ! $last_sent || time() > $last_sent + $rate_limit ) { if ( ! update_option( self::RATE_LIMIT_OPTION, time() ) ) { return new WP_Error( 'storage_error', __( 'Could not update the email last sent time.' ) ); } $sent = $this->send_recovery_mode_email( $rate_limit, $error, $extension ); if ( $sent ) { return true; } return new WP_Error( 'email_failed', sprintf( /* translators: %s: mail() */ __( 'The email could not be sent. Possible reason: your host may have disabled the %s function.' ), 'mail()' ) ); } $err_message = sprintf( /* translators: 1: Last sent as a human time diff, 2: Wait time as a human time diff. */ __( 'A recovery link was already sent %1$s ago. Please wait another %2$s before requesting a new email.' ), human_time_diff( $last_sent ), human_time_diff( $last_sent + $rate_limit ) ); return new WP_Error( 'email_sent_already', $err_message ); }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 6.7.7 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.