Skip to content

Commit c7bdfc1

Browse files
author
flixos90
committed
Bootstrap/Load: Only pause extensions when they cause a crash on a protected endpoint.
This is a first step on pausing extensions less aggressively. If a plugin or theme only causes a crash in the frontend, there is no point in pausing it in the admin backend. See #45940, #44458. Built from https://develop.svn.wordpress.org/trunk@44623 git-svn-id: http://core.svn.wordpress.org/trunk@44454 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 4f64cb6 commit c7bdfc1

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

wp-includes/class-wp-shutdown-handler.php

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ public function handle() {
3131
}
3232

3333
try {
34-
// Bail if no error found or if it could not be stored.
35-
if ( ! $this->detect_error() ) {
34+
// Bail if no error found.
35+
$error = $this->detect_error();
36+
if ( ! $error ) {
3637
return;
3738
}
3839

39-
// Redirect the request to catch multiple errors in one go.
40-
$this->redirect_protected();
40+
// If the error was stored and thus the extension paused,
41+
// redirect the request to catch multiple errors in one go.
42+
if ( $this->store_error( $error ) ) {
43+
$this->redirect_protected();
44+
}
4145

4246
// Display the PHP error template.
4347
$this->display_error_template();
@@ -47,26 +51,42 @@ public function handle() {
4751
}
4852

4953
/**
50-
* Detects the error causing the crash and stores it if one was found.
54+
* Detects the error causing the crash if it should be handled.
5155
*
5256
* @since 5.1.0
5357
*
54-
* @return bool True if an error was found and stored, false otherwise.
58+
* @return array|null Error that was triggered, or null if no error received or if the error should not be handled.
5559
*/
5660
protected function detect_error() {
5761
$error = error_get_last();
5862

5963
// No error, just skip the error handling code.
6064
if ( null === $error ) {
61-
return false;
65+
return null;
6266
}
6367

6468
// Bail if this error should not be handled.
6569
if ( ! wp_should_handle_error( $error ) ) {
70+
return null;
71+
}
72+
73+
return $error;
74+
}
75+
76+
/**
77+
* Stores the given error so that the extension causing it is paused.
78+
*
79+
* @since 5.1.0
80+
*
81+
* @param array $error Error that was triggered.
82+
* @return bool True if the error was stored successfully, false otherwise.
83+
*/
84+
protected function store_error( $error ) {
85+
// Do not pause extensions if they only crash on a non-protected endpoint.
86+
if ( ! is_protected_endpoint() ) {
6687
return false;
6788
}
6889

69-
// Try to store the error so that the respective extension is paused.
7090
return wp_record_extension_error( $error );
7191
}
7292

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @global string $wp_version
1515
*/
16-
$wp_version = '5.1-beta1-44622';
16+
$wp_version = '5.1-beta1-44623';
1717

1818
/**
1919
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)