Code Modernization: Use wp_trigger_error() instead of trigger_error().
Replaces `trigger_error()` with `wp_trigger_error()`. The usage of `wp_trigger_error()` avoids generating `E_USER` family errors unless `WP_DEBUG` is on. In doing so, users should not see these messages in normal production. Notes: * Removes `E_USER_NOTICE` when passed as an argumnent, as it's the default error level. * An empty string is passed for the function name when its name is already in the error message or does not add value to the error message. * Externally maintained libraries are not included. Follow-up to [55204], [25956], [29630], [38883], [52062], [52049], [54272], [38883], [55245], [51599], [14452], [38883], [24976]. Props prasadkarmalkar, rajinsharwar, thelovekesh, hellofromTonya, swissspidy. Fixes #59652. Built from https://develop.svn.wordpress.org/trunk@58409 git-svn-id: http://core.svn.wordpress.org/trunk@57858 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2889f4d90e
commit
b5ec907fb0
|
@ -2795,7 +2795,7 @@ function wp_opcache_invalidate_directory( $dir ) {
|
|||
__( '%s expects a non-empty string.' ),
|
||||
'<code>wp_opcache_invalidate_directory()</code>'
|
||||
);
|
||||
trigger_error( $error_message );
|
||||
wp_trigger_error( '', $error_message );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -174,7 +174,8 @@ function plugins_api( $action, $args = array() ) {
|
|||
|
||||
if ( $ssl && is_wp_error( $request ) ) {
|
||||
if ( ! wp_is_json_request() ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
__FUNCTION__,
|
||||
sprintf(
|
||||
/* translators: %s: Support forums URL. */
|
||||
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
|
||||
|
|
|
@ -568,7 +568,8 @@ function themes_api( $action, $args = array() ) {
|
|||
|
||||
if ( $ssl && is_wp_error( $request ) ) {
|
||||
if ( ! wp_doing_ajax() ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
__FUNCTION__,
|
||||
sprintf(
|
||||
/* translators: %s: Support forums URL. */
|
||||
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
|
||||
|
|
|
@ -59,7 +59,8 @@ function translations_api( $type, $args = null ) {
|
|||
$request = wp_remote_post( $url, $options );
|
||||
|
||||
if ( $ssl && is_wp_error( $request ) ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
__FUNCTION__,
|
||||
sprintf(
|
||||
/* translators: %s: Support forums URL. */
|
||||
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
|
||||
|
|
|
@ -145,7 +145,8 @@ function get_core_checksums( $version, $locale ) {
|
|||
$response = wp_remote_get( $url, $options );
|
||||
|
||||
if ( $ssl && is_wp_error( $response ) ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
__FUNCTION__,
|
||||
sprintf(
|
||||
/* translators: %s: Support forums URL. */
|
||||
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
|
||||
|
|
|
@ -78,7 +78,7 @@ function endElement( $parser, $tag_name ) { // phpcs:ignore WordPress.NamingConv
|
|||
|
||||
// Create an XML parser.
|
||||
if ( ! function_exists( 'xml_parser_create' ) ) {
|
||||
trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
|
||||
wp_trigger_error( '', __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
|
||||
wp_die( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ function _filter_block_template_part_area( $type ) {
|
|||
$type,
|
||||
WP_TEMPLATE_PART_AREA_UNCATEGORIZED
|
||||
);
|
||||
trigger_error( $warning_message, E_USER_NOTICE );
|
||||
wp_trigger_error( __FUNCTION__, $warning_message );
|
||||
return WP_TEMPLATE_PART_AREA_UNCATEGORIZED;
|
||||
}
|
||||
|
||||
|
|
|
@ -504,7 +504,7 @@ class WP_Theme_JSON_Resolver {
|
|||
|
||||
$json_decoding_error = json_last_error();
|
||||
if ( JSON_ERROR_NONE !== $json_decoding_error ) {
|
||||
trigger_error( 'Error when decoding a theme.json schema for user data. ' . json_last_error_msg() );
|
||||
wp_trigger_error( __METHOD__, 'Error when decoding a theme.json schema for user data. ' . json_last_error_msg() );
|
||||
/**
|
||||
* Filters the data provided by the user for global styles & settings.
|
||||
*
|
||||
|
|
|
@ -3775,7 +3775,8 @@ class WP_Theme_JSON {
|
|||
|| ! is_numeric( $spacing_scale['mediumStep'] )
|
||||
|| ( '+' !== $spacing_scale['operator'] && '*' !== $spacing_scale['operator'] ) ) {
|
||||
if ( ! empty( $spacing_scale ) ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
__METHOD__,
|
||||
sprintf(
|
||||
/* translators: 1: theme.json, 2: settings.spacing.spacingScale */
|
||||
__( 'Some of the %1$s %2$s values are invalid' ),
|
||||
|
|
|
@ -587,7 +587,7 @@ function prep_atom_text_construct( $data ) {
|
|||
}
|
||||
|
||||
if ( ! function_exists( 'xml_parser_create' ) ) {
|
||||
trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
|
||||
wp_trigger_error( '', __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
|
||||
|
||||
return array( 'html', "<![CDATA[$data]]>" );
|
||||
}
|
||||
|
|
|
@ -5518,10 +5518,11 @@ function wp_strip_all_tags( $text, $remove_breaks = false ) {
|
|||
if ( ! is_scalar( $text ) ) {
|
||||
/*
|
||||
* To maintain consistency with pre-PHP 8 error levels,
|
||||
* trigger_error() is used to trigger an E_USER_WARNING,
|
||||
* wp_trigger_error() is used to trigger an E_USER_WARNING,
|
||||
* rather than _doing_it_wrong(), which triggers an E_USER_NOTICE.
|
||||
*/
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
'',
|
||||
sprintf(
|
||||
/* translators: 1: The function name, 2: The argument number, 3: The argument name, 4: The expected type, 5: The provided type. */
|
||||
__( 'Warning: %1$s expects parameter %2$s (%3$s) to be a %4$s, %5$s given.' ),
|
||||
|
|
|
@ -4611,7 +4611,8 @@ function wp_json_file_decode( $filename, $options = array() ) {
|
|||
$filename = wp_normalize_path( realpath( $filename ) );
|
||||
|
||||
if ( ! $filename ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
__FUNCTION__,
|
||||
sprintf(
|
||||
/* translators: %s: Path to the JSON file. */
|
||||
__( "File %s doesn't exist!" ),
|
||||
|
@ -4625,7 +4626,8 @@ function wp_json_file_decode( $filename, $options = array() ) {
|
|||
$decoded_file = json_decode( file_get_contents( $filename ), $options['associative'] );
|
||||
|
||||
if ( JSON_ERROR_NONE !== json_last_error() ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
__FUNCTION__,
|
||||
sprintf(
|
||||
/* translators: 1: Path to the JSON file, 2: Error message. */
|
||||
__( 'Error when decoding a JSON file at path %1$s: %2$s' ),
|
||||
|
@ -8757,7 +8759,8 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul
|
|||
*/
|
||||
function clean_dirsize_cache( $path ) {
|
||||
if ( ! is_string( $path ) || empty( $path ) ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
'',
|
||||
sprintf(
|
||||
/* translators: 1: Function name, 2: A variable type, like "boolean" or "integer". */
|
||||
__( '%1$s only accepts a non-empty path string, received %2$s.' ),
|
||||
|
|
|
@ -147,7 +147,8 @@ function ms_subdomain_constants() {
|
|||
);
|
||||
|
||||
if ( $subdomain_error_warn ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
__FUNCTION__,
|
||||
sprintf(
|
||||
/* translators: 1: VHOST, 2: SUBDOMAIN_INSTALL */
|
||||
__( '<strong>Conflicting values for the constants %1$s and %2$s.</strong> The value of %2$s will be assumed to be your subdomain configuration setting.' ),
|
||||
|
|
|
@ -63,7 +63,8 @@ class MagpieRSS {
|
|||
# Check if PHP xml isn't compiled
|
||||
#
|
||||
if ( ! function_exists('xml_parser_create') ) {
|
||||
return trigger_error( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." );
|
||||
wp_trigger_error( '', "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." );
|
||||
return;
|
||||
}
|
||||
|
||||
$parser = xml_parser_create();
|
||||
|
@ -387,7 +388,7 @@ class MagpieRSS {
|
|||
|
||||
function error( $errormsg, $lvl = E_USER_WARNING ) {
|
||||
if ( MAGPIE_DEBUG ) {
|
||||
trigger_error( $errormsg, $lvl);
|
||||
wp_trigger_error('', $errormsg, $lvl);
|
||||
} else {
|
||||
error_log( $errormsg, 0);
|
||||
}
|
||||
|
@ -823,7 +824,7 @@ class RSSCache {
|
|||
function error ($errormsg, $lvl=E_USER_WARNING) {
|
||||
$this->ERROR = $errormsg;
|
||||
if ( MAGPIE_DEBUG ) {
|
||||
trigger_error( $errormsg, $lvl);
|
||||
wp_trigger_error( '', $errormsg, $lvl);
|
||||
}
|
||||
else {
|
||||
error_log( $errormsg, 0);
|
||||
|
|
|
@ -514,7 +514,7 @@ function search_theme_directories( $force = false ) {
|
|||
// Start with directories in the root of the active theme directory.
|
||||
$dirs = @ scandir( $theme_root );
|
||||
if ( ! $dirs ) {
|
||||
trigger_error( "$theme_root is not readable", E_USER_NOTICE );
|
||||
wp_trigger_error( __FUNCTION__, "$theme_root is not readable" );
|
||||
continue;
|
||||
}
|
||||
foreach ( $dirs as $dir ) {
|
||||
|
@ -538,7 +538,7 @@ function search_theme_directories( $force = false ) {
|
|||
*/
|
||||
$sub_dirs = @ scandir( $theme_root . '/' . $dir );
|
||||
if ( ! $sub_dirs ) {
|
||||
trigger_error( "$theme_root/$dir is not readable", E_USER_NOTICE );
|
||||
wp_trigger_error( __FUNCTION__, "$theme_root/$dir is not readable" );
|
||||
continue;
|
||||
}
|
||||
foreach ( $sub_dirs as $sub_dir ) {
|
||||
|
|
|
@ -202,7 +202,8 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
|
|||
$response = wp_remote_post( $url, $options );
|
||||
|
||||
if ( $ssl && is_wp_error( $response ) ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
__FUNCTION__,
|
||||
sprintf(
|
||||
/* translators: %s: Support forums URL. */
|
||||
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
|
||||
|
@ -440,7 +441,8 @@ function wp_update_plugins( $extra_stats = array() ) {
|
|||
$raw_response = wp_remote_post( $url, $options );
|
||||
|
||||
if ( $ssl && is_wp_error( $raw_response ) ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
__FUNCTION__,
|
||||
sprintf(
|
||||
/* translators: %s: Support forums URL. */
|
||||
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
|
||||
|
@ -721,7 +723,8 @@ function wp_update_themes( $extra_stats = array() ) {
|
|||
$raw_response = wp_remote_post( $url, $options );
|
||||
|
||||
if ( $ssl && is_wp_error( $raw_response ) ) {
|
||||
trigger_error(
|
||||
wp_trigger_error(
|
||||
__FUNCTION__,
|
||||
sprintf(
|
||||
/* translators: %s: Support forums URL. */
|
||||
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.6-beta2-58408';
|
||||
$wp_version = '6.6-beta2-58409';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue