mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-05 15:16:59 +00:00
Coding Standards: Fix instances of WordPress.PHP.NoSilencedErrors.Discouraged.
Noteable changes: - The `magic_quotes_runtime` and `magic_quotes_sybase` settings were removed in PHP 5.4, so no longer need to be set. - Some functions that use external libraries can generate errors that can't be tested for, so are globally allowed to silence errors. - Quite a few functions would cause errors if `safe_mode` was set. This setting was removed in PHP 5.4. - Only a handful of `header()` calls needed corresponding `headers_sent()` checks for unit tests to pass, but more may need to be added as the nightlies builds are tested. See #46732. git-svn-id: https://develop.svn.wordpress.org/trunk@45611 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -89,7 +89,7 @@ class _WP_Dependency {
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function __construct() {
|
||||
@list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = func_get_args();
|
||||
list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = func_get_args();
|
||||
if ( ! is_array( $this->deps ) ) {
|
||||
$this->deps = array();
|
||||
}
|
||||
|
||||
@@ -140,8 +140,10 @@ class WP_Http_Streams {
|
||||
}
|
||||
|
||||
if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
$handle = @stream_socket_client( 'tcp://' . $proxy->host() . ':' . $proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context );
|
||||
} else {
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
$handle = @stream_socket_client( $connect_host . ':' . $arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context );
|
||||
}
|
||||
|
||||
|
||||
@@ -436,7 +436,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
||||
// Set correct file permissions
|
||||
$stat = stat( dirname( $filename ) );
|
||||
$perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
|
||||
@ chmod( $filename, $perms );
|
||||
chmod( $filename, $perms );
|
||||
|
||||
/**
|
||||
* Filters the name of the saved image file.
|
||||
|
||||
@@ -113,6 +113,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
|
||||
}
|
||||
|
||||
try {
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
return ( (bool) @Imagick::queryFormats( $imagick_extension ) );
|
||||
} catch ( Exception $e ) {
|
||||
return false;
|
||||
@@ -654,7 +655,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
|
||||
// Set correct file permissions
|
||||
$stat = stat( dirname( $filename ) );
|
||||
$perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
|
||||
@ chmod( $filename, $perms );
|
||||
chmod( $filename, $perms );
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-image-editor-gd.php */
|
||||
return array(
|
||||
|
||||
@@ -492,23 +492,15 @@ class WP {
|
||||
if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) {
|
||||
unset( $headers['Last-Modified'] );
|
||||
|
||||
// In PHP 5.3+, make sure we are not sending a Last-Modified header.
|
||||
if ( function_exists( 'header_remove' ) ) {
|
||||
@header_remove( 'Last-Modified' );
|
||||
} else {
|
||||
// In PHP 5.2, send an empty Last-Modified header, but only as a
|
||||
// last resort to override a header already sent. #WP23021
|
||||
foreach ( headers_list() as $header ) {
|
||||
if ( 0 === stripos( $header, 'Last-Modified' ) ) {
|
||||
$headers['Last-Modified'] = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( ! headers_sent() ) {
|
||||
header_remove( 'Last-Modified' );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( (array) $headers as $name => $field_value ) {
|
||||
@header( "{$name}: {$field_value}" );
|
||||
if ( ! headers_sent() ) {
|
||||
foreach ( (array) $headers as $name => $field_value ) {
|
||||
header( "{$name}: {$field_value}" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $exit_required ) {
|
||||
@@ -674,8 +666,8 @@ class WP {
|
||||
}
|
||||
|
||||
// Only set X-Pingback for single posts that allow pings.
|
||||
if ( $p && pings_open( $p ) ) {
|
||||
@header( 'X-Pingback: ' . get_bloginfo( 'pingback_url', 'display' ) );
|
||||
if ( $p && pings_open( $p ) && ! headers_sent() ) {
|
||||
header( 'X-Pingback: ' . get_bloginfo( 'pingback_url', 'display' ) );
|
||||
}
|
||||
|
||||
// check for paged content that exceeds the max number of pages
|
||||
|
||||
@@ -2608,9 +2608,9 @@ function discover_pingback_server_uri( $url, $deprecated = '' ) {
|
||||
if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) {
|
||||
$quote = ( $pingback_link_offset_dquote ) ? '"' : '\'';
|
||||
$pingback_link_offset = ( $quote == '"' ) ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
|
||||
$pingback_href_pos = @strpos( $contents, 'href=', $pingback_link_offset );
|
||||
$pingback_href_pos = strpos( $contents, 'href=', $pingback_link_offset );
|
||||
$pingback_href_start = $pingback_href_pos + 6;
|
||||
$pingback_href_end = @strpos( $contents, $quote, $pingback_href_start );
|
||||
$pingback_href_end = strpos( $contents, $quote, $pingback_href_start );
|
||||
$pingback_server_url_len = $pingback_href_end - $pingback_href_start;
|
||||
$pingback_server_url = substr( $contents, $pingback_href_start, $pingback_server_url_len );
|
||||
|
||||
@@ -2808,7 +2808,7 @@ function pingback( $content, $post_id ) {
|
||||
$pingback_server_url = discover_pingback_server_uri( $pagelinkedto );
|
||||
|
||||
if ( $pingback_server_url ) {
|
||||
@ set_time_limit( 60 );
|
||||
set_time_limit( 60 );
|
||||
// Now, the RPC call
|
||||
$pagelinkedfrom = get_permalink( $post );
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ function _wp_can_use_pcre_u( $set = null ) {
|
||||
}
|
||||
|
||||
if ( 'reset' === $utf8_pcre ) {
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- intentional error generated to detect PCRE/u support.
|
||||
$utf8_pcre = @preg_match( '/^./u', 'a' );
|
||||
}
|
||||
|
||||
|
||||
@@ -677,11 +677,10 @@ function spawn_cron( $gmt_time = 0 ) {
|
||||
echo ' ';
|
||||
|
||||
// flush any buffers and send the headers
|
||||
while ( @ob_end_flush() ) {
|
||||
}
|
||||
wp_ob_end_flush_all();
|
||||
flush();
|
||||
|
||||
WP_DEBUG ? include_once( ABSPATH . 'wp-cron.php' ) : @include_once( ABSPATH . 'wp-cron.php' );
|
||||
include_once( ABSPATH . 'wp-cron.php' );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ function wp_initial_constants() {
|
||||
define( 'WP_START_TIMESTAMP', microtime( true ) );
|
||||
}
|
||||
|
||||
$current_limit = @ini_get( 'memory_limit' );
|
||||
$current_limit = ini_get( 'memory_limit' );
|
||||
$current_limit_int = wp_convert_hr_to_bytes( $current_limit );
|
||||
|
||||
// Define memory limits.
|
||||
@@ -61,7 +61,7 @@ function wp_initial_constants() {
|
||||
// Set memory limits.
|
||||
$wp_limit_int = wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
|
||||
if ( -1 !== $current_limit_int && ( -1 === $wp_limit_int || $wp_limit_int > $current_limit_int ) ) {
|
||||
@ini_set( 'memory_limit', WP_MEMORY_LIMIT );
|
||||
ini_set( 'memory_limit', WP_MEMORY_LIMIT );
|
||||
}
|
||||
|
||||
if ( ! isset( $blog_id ) ) {
|
||||
|
||||
@@ -1923,7 +1923,7 @@ function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
|
||||
// Do we need to constrain the image?
|
||||
if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
|
||||
|
||||
$imagesize = getimagesize($src_file);
|
||||
$imagesize = @getimagesize($src_file);
|
||||
|
||||
if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
|
||||
$actual_aspect = $imagesize[0] / $imagesize[1];
|
||||
|
||||
@@ -407,7 +407,7 @@ function get_the_category_rss( $type = null ) {
|
||||
} elseif ( 'atom' == $type ) {
|
||||
$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) );
|
||||
} else {
|
||||
$the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option( 'blog_charset' ) ) . "]]></category>\n";
|
||||
$the_list .= "\t\t<category><![CDATA[" . html_entity_decode( $cat_name, ENT_COMPAT, get_option( 'blog_charset' ) ) . "]]></category>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -994,7 +994,7 @@ function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = fals
|
||||
$string = wp_kses_normalize_entities( $string );
|
||||
}
|
||||
|
||||
$string = @htmlspecialchars( $string, $quote_style, $charset, $double_encode );
|
||||
$string = htmlspecialchars( $string, $quote_style, $charset, $double_encode );
|
||||
|
||||
// Back-compat.
|
||||
if ( 'single' === $_quote_style ) {
|
||||
@@ -1129,6 +1129,7 @@ function wp_check_invalid_utf8( $string, $strip = false ) {
|
||||
// Check for support for utf8 in the installed PCRE library once and store the result in a static
|
||||
static $utf8_pcre = null;
|
||||
if ( ! isset( $utf8_pcre ) ) {
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
$utf8_pcre = @preg_match( '/^./u', 'a' );
|
||||
}
|
||||
// We can't demand utf8 in the PCRE installation, so just return the string in those cases
|
||||
@@ -1136,7 +1137,7 @@ function wp_check_invalid_utf8( $string, $strip = false ) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
// preg_match fails when it encounters invalid UTF8 in $string
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- preg_match fails when it encounters invalid UTF8 in $string
|
||||
if ( 1 === @preg_match( '/^./us', $string ) ) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ function date_i18n( $dateformatstring, $timestamp_with_offset = false, $gmt = fa
|
||||
global $wp_locale;
|
||||
$i = $timestamp_with_offset;
|
||||
|
||||
if ( false === $i ) {
|
||||
if ( ! is_numeric( $i ) ) {
|
||||
$i = current_time( 'timestamp', $gmt );
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ function date_i18n( $dateformatstring, $timestamp_with_offset = false, $gmt = fa
|
||||
}
|
||||
}
|
||||
}
|
||||
$j = @gmdate( $dateformatstring, $i );
|
||||
$j = gmdate( $dateformatstring, $i );
|
||||
|
||||
/**
|
||||
* Filters the date formatted based on the locale.
|
||||
@@ -224,7 +224,7 @@ function wp_maybe_decline_date( $date ) {
|
||||
$months_genitive = $wp_locale->month_genitive;
|
||||
|
||||
// Match a format like 'j F Y' or 'j. F'
|
||||
if ( @preg_match( '#^\d{1,2}\.? [^\d ]+#u', $date ) ) {
|
||||
if ( preg_match( '#^\d{1,2}\.? [^\d ]+#u', $date ) ) {
|
||||
|
||||
foreach ( $months as $key => $month ) {
|
||||
$months[ $key ] = '# ' . $month . '( |$)#u';
|
||||
@@ -238,7 +238,7 @@ function wp_maybe_decline_date( $date ) {
|
||||
}
|
||||
|
||||
// Match a format like 'F jS' or 'F j' and change it to 'j F'
|
||||
if ( @preg_match( '#^[^\d ]+ \d{1,2}(st|nd|rd|th)? #u', trim( $date ) ) ) {
|
||||
if ( preg_match( '#^[^\d ]+ \d{1,2}(st|nd|rd|th)? #u', trim( $date ) ) ) {
|
||||
foreach ( $months as $key => $month ) {
|
||||
$months[ $key ] = '#' . $month . ' (\d{1,2})(st|nd|rd|th)?#u';
|
||||
}
|
||||
@@ -1258,7 +1258,9 @@ function status_header( $code, $description = '' ) {
|
||||
$status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol );
|
||||
}
|
||||
|
||||
@header( $status_header, true, $code );
|
||||
if ( ! headers_sent() ) {
|
||||
header( $status_header, true, $code );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1310,26 +1312,18 @@ function wp_get_nocache_headers() {
|
||||
* @see wp_get_nocache_headers()
|
||||
*/
|
||||
function nocache_headers() {
|
||||
if ( headers_sent() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$headers = wp_get_nocache_headers();
|
||||
|
||||
unset( $headers['Last-Modified'] );
|
||||
|
||||
// In PHP 5.3+, make sure we are not sending a Last-Modified header.
|
||||
if ( function_exists( 'header_remove' ) ) {
|
||||
@header_remove( 'Last-Modified' );
|
||||
} else {
|
||||
// In PHP 5.2, send an empty Last-Modified header, but only as a
|
||||
// last resort to override a header already sent. #WP23021
|
||||
foreach ( headers_list() as $header ) {
|
||||
if ( 0 === stripos( $header, 'Last-Modified' ) ) {
|
||||
$headers['Last-Modified'] = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
header_remove( 'Last-Modified' );
|
||||
|
||||
foreach ( $headers as $name => $field_value ) {
|
||||
@header( "{$name}: {$field_value}" );
|
||||
header( "{$name}: {$field_value}" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1829,7 +1823,7 @@ function wp_mkdir_p( $target ) {
|
||||
if ( $dir_perms != ( $dir_perms & ~umask() ) ) {
|
||||
$folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
|
||||
for ( $i = 1, $c = count( $folder_parts ); $i <= $c; $i++ ) {
|
||||
@chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );
|
||||
chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2421,12 +2415,12 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
|
||||
return array( 'error' => $message );
|
||||
}
|
||||
|
||||
$ifp = @ fopen( $new_file, 'wb' );
|
||||
$ifp = @fopen( $new_file, 'wb' );
|
||||
if ( ! $ifp ) {
|
||||
return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
|
||||
}
|
||||
|
||||
@fwrite( $ifp, $bits );
|
||||
fwrite( $ifp, $bits );
|
||||
fclose( $ifp );
|
||||
clearstatcache();
|
||||
|
||||
@@ -2434,7 +2428,7 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
|
||||
$stat = @ stat( dirname( $new_file ) );
|
||||
$perms = $stat['mode'] & 0007777;
|
||||
$perms = $perms & 0000666;
|
||||
@ chmod( $new_file, $perms );
|
||||
chmod( $new_file, $perms );
|
||||
clearstatcache();
|
||||
|
||||
// Compute the URL
|
||||
@@ -2707,7 +2701,7 @@ function wp_get_image_mime( $file ) {
|
||||
$imagetype = exif_imagetype( $file );
|
||||
$mime = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false;
|
||||
} elseif ( function_exists( 'getimagesize' ) ) {
|
||||
$imagesize = getimagesize( $file );
|
||||
$imagesize = @getimagesize( $file );
|
||||
$mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
|
||||
} else {
|
||||
$mime = false;
|
||||
@@ -3601,6 +3595,7 @@ function wp_json_encode( $data, $options = 0, $depth = 512 ) {
|
||||
// Prepare the data for JSON serialization.
|
||||
$args[0] = _wp_json_prepare_data( $data );
|
||||
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- json_encode() errors are handled after this call
|
||||
$json = @call_user_func_array( 'json_encode', $args );
|
||||
|
||||
// If json_encode() was successful, no need to do more sanity checking.
|
||||
@@ -3775,10 +3770,13 @@ function _wp_json_prepare_data( $data ) {
|
||||
* @param int $status_code The HTTP status code to output.
|
||||
*/
|
||||
function wp_send_json( $response, $status_code = null ) {
|
||||
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
|
||||
if ( null !== $status_code ) {
|
||||
status_header( $status_code );
|
||||
if ( ! headers_sent() ) {
|
||||
header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
|
||||
if ( null !== $status_code ) {
|
||||
status_header( $status_code );
|
||||
}
|
||||
}
|
||||
|
||||
echo wp_json_encode( $response );
|
||||
|
||||
if ( wp_doing_ajax() ) {
|
||||
@@ -5726,7 +5724,7 @@ function __return_empty_string() { // phpcs:ignore WordPress.NamingConventions.V
|
||||
* @see https://src.chromium.org/viewvc/chrome?view=rev&revision=6985
|
||||
*/
|
||||
function send_nosniff_header() {
|
||||
@header( 'X-Content-Type-Options: nosniff' );
|
||||
header( 'X-Content-Type-Options: nosniff' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5840,7 +5838,7 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar
|
||||
* @see https://developer.mozilla.org/en/the_x-frame-options_response_header
|
||||
*/
|
||||
function send_frame_options_header() {
|
||||
@header( 'X-Frame-Options: SAMEORIGIN' );
|
||||
header( 'X-Frame-Options: SAMEORIGIN' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6414,7 +6412,7 @@ function wp_raise_memory_limit( $context = 'admin' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$current_limit = @ini_get( 'memory_limit' );
|
||||
$current_limit = ini_get( 'memory_limit' );
|
||||
$current_limit_int = wp_convert_hr_to_bytes( $current_limit );
|
||||
|
||||
if ( -1 === $current_limit_int ) {
|
||||
@@ -6486,13 +6484,13 @@ function wp_raise_memory_limit( $context = 'admin' ) {
|
||||
$filtered_limit_int = wp_convert_hr_to_bytes( $filtered_limit );
|
||||
|
||||
if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) {
|
||||
if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) {
|
||||
if ( false !== ini_set( 'memory_limit', $filtered_limit ) ) {
|
||||
return $filtered_limit;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) {
|
||||
if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) {
|
||||
if ( false !== ini_set( 'memory_limit', $wp_max_limit ) ) {
|
||||
return $wp_max_limit;
|
||||
} else {
|
||||
return false;
|
||||
@@ -7179,13 +7177,13 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks compatibility with the current WordPress version.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $required Minimum required WordPress version.
|
||||
* @return bool True if required version is compatible or empty, false if not.
|
||||
*/
|
||||
* Checks compatibility with the current WordPress version.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $required Minimum required WordPress version.
|
||||
* @return bool True if required version is compatible or empty, false if not.
|
||||
*/
|
||||
function is_wp_version_compatible( $required ) {
|
||||
return empty( $required ) || version_compare( get_bloginfo( 'version' ), $required, '>=' );
|
||||
}
|
||||
|
||||
@@ -496,8 +496,8 @@ function send_origin_headers() {
|
||||
$origin = get_http_origin();
|
||||
|
||||
if ( is_allowed_http_origin( $origin ) ) {
|
||||
@header( 'Access-Control-Allow-Origin: ' . $origin );
|
||||
@header( 'Access-Control-Allow-Credentials: true' );
|
||||
header( 'Access-Control-Allow-Origin: ' . $origin );
|
||||
header( 'Access-Control-Allow-Credentials: true' );
|
||||
if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ function wp_debug_mode() {
|
||||
}
|
||||
|
||||
if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() || wp_is_json_request() ) {
|
||||
@ini_set( 'display_errors', 0 );
|
||||
ini_set( 'display_errors', 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -908,6 +908,7 @@ function is_protected_ajax_action() {
|
||||
function wp_set_internal_encoding() {
|
||||
if ( function_exists( 'mb_internal_encoding' ) ) {
|
||||
$charset = get_option( 'blog_charset' );
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
if ( ! $charset || ! @mb_internal_encoding( $charset ) ) {
|
||||
mb_internal_encoding( 'UTF-8' );
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ function image_downsize( $id, $size = 'medium' ) {
|
||||
$info = null;
|
||||
|
||||
if ( $thumb_file ) {
|
||||
$info = getimagesize( $thumb_file );
|
||||
$info = @getimagesize( $thumb_file );
|
||||
}
|
||||
|
||||
if ( $thumb_file && $info ) {
|
||||
@@ -910,8 +910,8 @@ function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon
|
||||
/** This filter is documented in wp-includes/post.php */
|
||||
$icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );
|
||||
|
||||
$src_file = $icon_dir . '/' . wp_basename( $src );
|
||||
@list( $width, $height ) = getimagesize( $src_file );
|
||||
$src_file = $icon_dir . '/' . wp_basename( $src );
|
||||
list( $width, $height ) = @getimagesize( $src_file );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1522,7 +1522,10 @@ if ( ! function_exists( 'wp_notify_postauthor' ) ) :
|
||||
|
||||
$switched_locale = switch_to_locale( get_locale() );
|
||||
|
||||
$comment_author_domain = @gethostbyaddr( $comment->comment_author_IP );
|
||||
$comment_author_domain = '';
|
||||
if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) {
|
||||
$comment_author_domain = gethostbyaddr( $comment->comment_author_IP );
|
||||
}
|
||||
|
||||
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
|
||||
// we want to reverse this for the plain text arena of emails.
|
||||
@@ -1639,7 +1642,7 @@ if ( ! function_exists( 'wp_notify_postauthor' ) ) :
|
||||
$message_headers = apply_filters( 'comment_notification_headers', $message_headers, $comment->comment_ID );
|
||||
|
||||
foreach ( $emails as $email ) {
|
||||
@wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
|
||||
wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
|
||||
}
|
||||
|
||||
if ( $switched_locale ) {
|
||||
@@ -1696,8 +1699,12 @@ if ( ! function_exists( 'wp_notify_moderator' ) ) :
|
||||
|
||||
$switched_locale = switch_to_locale( get_locale() );
|
||||
|
||||
$comment_author_domain = @gethostbyaddr( $comment->comment_author_IP );
|
||||
$comments_waiting = $wpdb->get_var( "SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'" );
|
||||
$comment_author_domain = '';
|
||||
if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) {
|
||||
$comment_author_domain = gethostbyaddr( $comment->comment_author_IP );
|
||||
}
|
||||
|
||||
$comments_waiting = $wpdb->get_var( "SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'" );
|
||||
|
||||
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
|
||||
// we want to reverse this for the plain text arena of emails.
|
||||
@@ -1810,7 +1817,7 @@ if ( ! function_exists( 'wp_notify_moderator' ) ) :
|
||||
$message_headers = apply_filters( 'comment_moderation_headers', $message_headers, $comment_id );
|
||||
|
||||
foreach ( $emails as $email ) {
|
||||
@wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
|
||||
wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
|
||||
}
|
||||
|
||||
if ( $switched_locale ) {
|
||||
@@ -1947,7 +1954,7 @@ if ( ! function_exists( 'wp_new_user_notification' ) ) :
|
||||
*/
|
||||
$wp_new_user_notification_email_admin = apply_filters( 'wp_new_user_notification_email_admin', $wp_new_user_notification_email_admin, $user, $blogname );
|
||||
|
||||
@wp_mail(
|
||||
wp_mail(
|
||||
$wp_new_user_notification_email_admin['to'],
|
||||
wp_specialchars_decode( sprintf( $wp_new_user_notification_email_admin['subject'], $blogname ) ),
|
||||
$wp_new_user_notification_email_admin['message'],
|
||||
|
||||
@@ -1279,19 +1279,7 @@ class WP_REST_Server {
|
||||
* @param string $key Header key.
|
||||
*/
|
||||
public function remove_header( $key ) {
|
||||
if ( function_exists( 'header_remove' ) ) {
|
||||
// In PHP 5.3+ there is a way to remove an already set header.
|
||||
header_remove( $key );
|
||||
} else {
|
||||
// In PHP 5.2, send an empty header, but only as a last resort to
|
||||
// override a header already sent.
|
||||
foreach ( headers_list() as $header ) {
|
||||
if ( 0 === stripos( $header, "$key:" ) ) {
|
||||
$this->send_header( $key, '' );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
header_remove( $key );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1493,7 +1493,7 @@ function wp_widget_rss_output( $rss, $args = array() ) {
|
||||
$title = __( 'Untitled' );
|
||||
}
|
||||
|
||||
$desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
|
||||
$desc = html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
|
||||
$desc = esc_attr( wp_trim_words( $desc, 55, ' […]' ) );
|
||||
|
||||
$summary = '';
|
||||
|
||||
@@ -67,7 +67,7 @@ class WP_Widget_RSS extends WP_Widget {
|
||||
$link = '';
|
||||
|
||||
if ( ! is_wp_error( $rss ) ) {
|
||||
$desc = esc_attr( strip_tags( @html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) );
|
||||
$desc = esc_attr( strip_tags( html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) );
|
||||
if ( empty( $title ) ) {
|
||||
$title = strip_tags( $rss->get_title() );
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ class WP_Widget_Text extends WP_Widget {
|
||||
|
||||
// Suppress warnings generated by loadHTML
|
||||
$errors = libxml_use_internal_errors( true );
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
@$doc->loadHTML(
|
||||
sprintf(
|
||||
'<!DOCTYPE html><html><head><meta charset="%s"></head><body>%s</body></html>',
|
||||
|
||||
@@ -1376,7 +1376,7 @@ class wpdb {
|
||||
}
|
||||
|
||||
array_walk( $args, array( $this, 'escape_by_ref' ) );
|
||||
$query = @vsprintf( $query, $args );
|
||||
$query = vsprintf( $query, $args );
|
||||
|
||||
return $this->add_placeholder_escape( $query );
|
||||
}
|
||||
@@ -1614,6 +1614,7 @@ class wpdb {
|
||||
if ( WP_DEBUG ) {
|
||||
mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
|
||||
} else {
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
@mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
|
||||
}
|
||||
|
||||
@@ -1645,6 +1646,7 @@ class wpdb {
|
||||
if ( WP_DEBUG ) {
|
||||
$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
|
||||
} else {
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
$this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user