Multisite: Log error/warnings/notices from `ms-files.php`.

Previously errors were not displayed or logged, but the original intention was only to prevent them from being displayed. Hiding them from logs makes problems like #53492 much harder to debug.

This makes the handling of errors in `ms-files` consistent with the REST API, `admin-ajax`, and XML-RPC.

Props iandunn, johnjamesjacoby.
Fixes #53493.

Built from https://develop.svn.wordpress.org/trunk@51358


git-svn-id: http://core.svn.wordpress.org/trunk@50967 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
iandunn 2021-07-06 20:21:57 +00:00
parent 72f034f636
commit 8b025acd61
3 changed files with 7 additions and 5 deletions

View File

@ -415,7 +415,7 @@ function timer_stop( $display = 0, $precision = 3 ) {
* When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`. * When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`.
* When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file. * When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file.
* *
* Errors are never displayed for XML-RPC, REST, and Ajax requests. * Errors are never displayed for XML-RPC, REST, `ms-files.php`, and Ajax requests.
* *
* @since 3.0.0 * @since 3.0.0
* @since 5.1.0 `WP_DEBUG_LOG` can be a file path. * @since 5.1.0 `WP_DEBUG_LOG` can be a file path.
@ -481,7 +481,10 @@ function wp_debug_mode() {
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
} }
if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() || wp_is_json_request() ) { if (
defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || defined( 'MS_FILES_REQUEST' ) ||
( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) ||
wp_doing_ajax() || wp_is_json_request() ) {
ini_set( 'display_errors', 0 ); ini_set( 'display_errors', 0 );
} }
} }

View File

@ -8,6 +8,7 @@
* @subpackage Multisite * @subpackage Multisite
*/ */
define( 'MS_FILES_REQUEST', true );
define( 'SHORTINIT', true ); define( 'SHORTINIT', true );
require_once dirname( __DIR__ ) . '/wp-load.php'; require_once dirname( __DIR__ ) . '/wp-load.php';
@ -17,8 +18,6 @@ if ( ! is_multisite() ) {
ms_file_constants(); ms_file_constants();
error_reporting( 0 );
if ( '1' == $current_blog->archived || '1' == $current_blog->spam || '1' == $current_blog->deleted ) { if ( '1' == $current_blog->archived || '1' == $current_blog->spam || '1' == $current_blog->deleted ) {
status_header( 404 ); status_header( 404 );
die( '404 — File not found.' ); die( '404 — File not found.' );

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.9-alpha-51356'; $wp_version = '5.9-alpha-51358';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.