Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/wp-admin/includes/class-wp-plugins-list-table.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -791,9 +791,9 @@ public function single_row( $item ) {
$class .= ' update';
}

$paused = is_plugin_paused( $plugin_file );
$paused_on_network_sites_count = $screen->in_admin( 'network' ) ? count_paused_plugin_sites_for_network( $plugin_file ) : 0;
if ( $paused || $paused_on_network_sites_count ) {
$paused = is_plugin_paused( $plugin_file );

if ( $paused ) {
$class .= ' paused';
}

Expand DownExpand Up@@ -885,15 +885,8 @@ public function single_row( $item ) {

echo '</div>';

if ( $paused || $paused_on_network_sites_count ) {
$notice_text = __( 'This plugin failed to load properly and was paused within the admin backend.' );
if ( $screen->in_admin( 'network' ) && $paused_on_network_sites_count ) {
$notice_text = sprintf(
/* translators: %s: number of sites */
_n( 'This plugin failed to load properly and was paused within the admin backend for %s site.', 'This plugin failed to load properly and was paused within the admin backend for %s sites.', $paused_on_network_sites_count ),
number_format_i18n( $paused_on_network_sites_count )
);
}
if ( $paused ) {
$notice_text = __( 'This plugin failed to load properly and is paused during recovery mode.' );

printf( '<p><span class="dashicons dashicons-warning"></span> <strong>%s</strong></p>', $notice_text );

Expand All@@ -911,11 +904,18 @@ public function single_row( $item ) {

$error['type'] = $core_errors[ $error['type'] ];

if ( empty( $error['wp_is_protected'] ) ) {
/* translators: 1: error type, 2: error line number, 3: error file name, 4: error message */
$error_message = __( 'The plugin caused an error of type %1$s in line %2$s of the file %3$s. Error message: %4$s' );
} else {
/* translators: 1: error type, 2: error line number, 3: error file name, 4: error message */
$error_message = __( 'The plugin caused an error in the <strong>admin backend</strong> of type %1$s in line %2$s of the file %3$s. Error message: %4$s' );
}

printf(
'<div class="error-display"><p>%s</p></div>',
sprintf(
/* translators: 1: error type, 2: error line number, 3: error file name, 4: error message */
__( 'The plugin caused an error of type %1$s in line %2$s of the file %3$s. Error message: %4$s' ),
$error_message,
"<code>{$error['type']}</code>",
"<code>{$error['line']}</code>",
"<code>{$error['file']}</code>",
Expand Down
20 changes: 6 additions & 14 deletions src/wp-includes/class-wp-fatal-error-handler.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,10 +40,12 @@ public function handle() {

// If the error was stored and thus the extension paused,
// redirect the request to catch multiple errors in one go.
if ( $this->store_error( $error ) ) {
if ( $this->store_error( $error ) && wp_is_recovery_mode() ) {
$this->redirect_protected();
}

maybe_send_recovery_mode_email();

// Display the PHP error template.
$this->display_error_template();
} catch ( Exception $e ) {
Expand DownExpand Up@@ -83,11 +85,6 @@ protected function detect_error() {
* @return bool True if the error was stored successfully, false otherwise.
*/
protected function store_error( $error ) {
// Do not pause extensions if they only crash on a non-protected endpoint.
if ( ! is_protected_endpoint() ) {
return false;
}

return wp_record_extension_error( $error );
}

Expand All@@ -102,11 +99,6 @@ protected function store_error( $error ) {
* @since 5.1.0
*/
protected function redirect_protected() {
// Do not redirect requests on non-protected endpoints.
if ( ! is_protected_endpoint() ) {
return;
}

// Pluggable is usually loaded after plugins, so we manually include it here for redirection functionality.
if ( ! function_exists( 'wp_redirect' ) ) {
include ABSPATH . WPINC . '/pluggable.php';
Expand DownExpand Up@@ -171,9 +163,9 @@ protected function display_default_error_template() {
'response' => 500,
'exit' => false,
);
if ( function_exists( 'admin_url' ) ) {
$args['link_url'] = admin_url();
$args['link_text'] = __( 'Log into the admin backend to fix this.' );
if ( function_exists( 'wp_login_url' ) ) {
$args['link_url'] = get_recovery_mode_request_url();
$args['link_text'] = __( 'Request a Recovery Mode email to fix this.' );
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/wp-includes/default-constants.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -302,6 +302,11 @@ function wp_cookie_constants() {
if ( ! defined( 'COOKIE_DOMAIN' ) ) {
define( 'COOKIE_DOMAIN', false );
}

/**
* @since 5.1.0
*/
define( 'RECOVERY_MODE_COOKIE', 'wordpress_rec_' . COOKIEHASH );
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/error-protection.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,6 +88,8 @@ function wp_record_extension_error( $error ) {
$parts = explode( '/', $path );
$extension = array_shift( $parts );

$error['wp_is_protected'] = is_protected_endpoint();

return call_user_func( $callback )->record( $extension, $error );
}

Expand Down
Loading