diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 8d412dd9b8..f284387945 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -35,8 +35,8 @@ require_once( ABSPATH . 'wp-admin/includes/admin.php' ); /** Load Ajax Handlers for WordPress Core */ require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' ); -@header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); -@header( 'X-Robots-Tag: noindex' ); +header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); +header( 'X-Robots-Tag: noindex' ); send_nosniff_header(); nocache_headers(); diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 525942ed79..8342c961ac 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -6,7 +6,7 @@ * @subpackage Administration */ -@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); +header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); if ( ! defined( 'WP_ADMIN' ) ) { require_once( dirname( __FILE__ ) . '/admin.php' ); } diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php index 2cf26600d2..97e7c08e7b 100644 --- a/wp-admin/custom-header.php +++ b/wp-admin/custom-header.php @@ -778,7 +778,7 @@ endif; } if ( file_exists( $file ) ) { - list( $width, $height, $type, $attr ) = getimagesize( $file ); + list( $width, $height, $type, $attr ) = @getimagesize( $file ); } else { $data = wp_get_attachment_metadata( $attachment_id ); $height = isset( $data['height'] ) ? $data['height'] : 0; diff --git a/wp-admin/customize.php b/wp-admin/customize.php index 2486f90145..e742a47f2b 100644 --- a/wp-admin/customize.php +++ b/wp-admin/customize.php @@ -123,7 +123,7 @@ wp_enqueue_style( 'customize-controls' ); do_action( 'customize_controls_enqueue_scripts' ); // Let's roll. -@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); +header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); wp_user_settings(); _wp_admin_html_begin(); diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 29cd94c2c8..4b91154c09 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -3251,7 +3251,7 @@ function wp_ajax_get_revision_diffs() { } $return = array(); - @set_time_limit( 0 ); + set_time_limit( 0 ); foreach ( $_REQUEST['compare'] as $compare_key ) { list( $compare_from, $compare_to ) = explode( ':', $compare_key ); // from:to diff --git a/wp-admin/includes/class-wp-filesystem-direct.php b/wp-admin/includes/class-wp-filesystem-direct.php index 9b1757cc65..f282c3b907 100644 --- a/wp-admin/includes/class-wp-filesystem-direct.php +++ b/wp-admin/includes/class-wp-filesystem-direct.php @@ -95,7 +95,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { * @return string|false The current working directory on success, false on failure. */ public function cwd() { - return @getcwd(); + return getcwd(); } /** @@ -126,10 +126,10 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { return false; } if ( ! $recursive ) { - return @chgrp( $file, $group ); + return chgrp( $file, $group ); } if ( ! $this->is_dir( $file ) ) { - return @chgrp( $file, $group ); + return chgrp( $file, $group ); } // Is a directory, and we want recursive $file = trailingslashit( $file ); @@ -165,7 +165,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { } if ( ! $recursive || ! $this->is_dir( $file ) ) { - return @chmod( $file, $mode ); + return chmod( $file, $mode ); } // Is a directory, and we want recursive $file = trailingslashit( $file ); @@ -193,10 +193,10 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { return false; } if ( ! $recursive ) { - return @chown( $file, $owner ); + return chown( $file, $owner ); } if ( ! $this->is_dir( $file ) ) { - return @chown( $file, $owner ); + return chown( $file, $owner ); } // Is a directory, and we want recursive $filelist = $this->dirlist( $file ); @@ -476,7 +476,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { if ( $atime == 0 ) { $atime = time(); } - return @touch( $file, $time, $atime ); + return touch( $file, $time, $atime ); } /** @@ -564,11 +564,11 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { $limit_file = false; } - if ( ! $this->is_dir( $path ) ) { + if ( ! $this->is_dir( $path ) || ! $this->is_readable( $dir ) ) { return false; } - $dir = @dir( $path ); + $dir = dir( $path ); if ( ! $dir ) { return false; } diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index c60f80a024..1a936cfd41 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -114,7 +114,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { } // Set the Connection to use Passive FTP - @ftp_pasv( $this->link, true ); + ftp_pasv( $this->link, true ); if ( @ftp_get_option( $this->link, FTP_TIMEOUT_SEC ) < FS_TIMEOUT ) { @ftp_set_option( $this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT ); } @@ -140,7 +140,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { return false; } - if ( ! @ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) { + if ( ! ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) { fclose( $temp ); unlink( $tempfile ); return false; @@ -205,7 +205,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { fseek( $temp, 0 ); // Skip back to the start of the file being written to - $ret = @ftp_fput( $this->link, $file, $temp, FTP_BINARY ); + $ret = ftp_fput( $this->link, $file, $temp, FTP_BINARY ); fclose( $temp ); unlink( $tempfile ); @@ -223,7 +223,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { * @return string|false The current working directory on success, false on failure. */ public function cwd() { - $cwd = @ftp_pwd( $this->link ); + $cwd = ftp_pwd( $this->link ); if ( $cwd ) { $cwd = trailingslashit( $cwd ); } @@ -275,9 +275,9 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { // chmod the file or directory if ( ! function_exists( 'ftp_chmod' ) ) { - return (bool) @ftp_site( $this->link, sprintf( 'CHMOD %o %s', $mode, $file ) ); + return (bool) ftp_site( $this->link, sprintf( 'CHMOD %o %s', $mode, $file ) ); } - return (bool) @ftp_chmod( $this->link, $mode, $file ); + return (bool) ftp_chmod( $this->link, $mode, $file ); } /** @@ -375,10 +375,10 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { return false; } if ( 'f' == $type || $this->is_file( $file ) ) { - return @ftp_delete( $this->link, $file ); + return ftp_delete( $this->link, $file ); } if ( ! $recursive ) { - return @ftp_rmdir( $this->link, $file ); + return ftp_rmdir( $this->link, $file ); } $filelist = $this->dirlist( trailingslashit( $file ) ); @@ -387,7 +387,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { $this->delete( trailingslashit( $file ) . $delete_file['name'], $recursive, $delete_file['type'] ); } } - return @ftp_rmdir( $this->link, $file ); + return ftp_rmdir( $this->link, $file ); } /** @@ -399,7 +399,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { * @return bool Whether $file exists or not. */ public function exists( $file ) { - $list = @ftp_nlist( $this->link, $file ); + $list = ftp_nlist( $this->link, $file ); if ( empty( $list ) && $this->is_dir( $file ) ) { return true; // File is an empty directory. @@ -536,7 +536,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { return false; } - if ( ! @ftp_mkdir( $this->link, $path ) ) { + if ( ! ftp_mkdir( $this->link, $path ) ) { return false; } $this->chmod( $path, $chmod ); @@ -587,7 +587,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { $b['year'] = $lucifer[3]; $b['hour'] = $lucifer[4]; $b['minute'] = $lucifer[5]; - $b['time'] = @mktime( $lucifer[4] + ( strcasecmp( $lucifer[6], 'PM' ) == 0 ? 12 : 0 ), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3] ); + $b['time'] = mktime( $lucifer[4] + ( strcasecmp( $lucifer[6], 'PM' ) == 0 ? 12 : 0 ), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3] ); $b['am/pm'] = $lucifer[6]; $b['name'] = $lucifer[8]; } elseif ( ! $is_windows ) { @@ -617,7 +617,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { if ( $lcount == 8 ) { sscanf( $lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day'] ); sscanf( $lucifer[6], '%d:%d', $b['hour'], $b['minute'] ); - $b['time'] = @mktime( $b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year'] ); + $b['time'] = mktime( $b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year'] ); $b['name'] = $lucifer[7]; } else { $b['month'] = $lucifer[5]; @@ -678,11 +678,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { $limit_file = false; } - $pwd = @ftp_pwd( $this->link ); + $pwd = ftp_pwd( $this->link ); if ( ! @ftp_chdir( $this->link, $path ) ) { // Can't change to folder = folder doesn't exist. return false; } - $list = @ftp_rawlist( $this->link, '-a', false ); + $list = ftp_rawlist( $this->link, '-a', false ); @ftp_chdir( $this->link, $pwd ); if ( empty( $list ) ) { // Empty array = non-existent folder (real folder will show . at least). diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php index 8b392f4946..0482663a65 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -33,7 +33,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { $this->errors = new WP_Error(); // Check if possible to use ftp functions. - if ( ! @include_once( ABSPATH . 'wp-admin/includes/class-ftp.php' ) ) { + if ( ! include_once( ABSPATH . 'wp-admin/includes/class-ftp.php' ) ) { return; } $this->ftp = new ftp(); diff --git a/wp-admin/includes/class-wp-filesystem-ssh2.php b/wp-admin/includes/class-wp-filesystem-ssh2.php index 0c12a4cda9..39d830d076 100644 --- a/wp-admin/includes/class-wp-filesystem-ssh2.php +++ b/wp-admin/includes/class-wp-filesystem-ssh2.php @@ -484,7 +484,17 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { * @return bool True on success, false on failure. */ public function move( $source, $destination, $overwrite = false ) { - return @ssh2_sftp_rename( $this->sftp_link, $source, $destination ); + if ( $this->exists( $destination ) ) { + if ( $overwrite ) { + // We need to remove the destination file before we can rename the source. + $this->delete( $destination, false, 'f' ); + } else { + // If we're not overwriting, the rename will fail, so return early. + return false; + } + } + + return ssh2_sftp_rename( $this->sftp_link, $source, $destination ); } /** @@ -711,12 +721,12 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { $limit_file = false; } - if ( ! $this->is_dir( $path ) ) { + if ( ! $this->is_dir( $path ) || ! $this->is_readable( $path ) ) { return false; } $ret = array(); - $dir = @dir( $this->sftp_path( $path ) ); + $dir = dir( $this->sftp_path( $path ) ); if ( ! $dir ) { return false; diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index b9c77f8ed3..d99c7a2f9d 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -465,7 +465,7 @@ class WP_Upgrader { $destination = $args['destination']; $clear_destination = $args['clear_destination']; - @set_time_limit( 300 ); + set_time_limit( 300 ); if ( empty( $source ) || empty( $destination ) ) { return new WP_Error( 'bad_request', $this->strings['bad_request'] ); diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index 722cdb6657..49f89382c6 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -165,8 +165,9 @@ function list_files( $folder = '', $levels = 100, $exclusions = array() ) { $files[] = $folder . $file; } } + + closedir( $dir ); } - @closedir( $dir ); return $files; } @@ -514,7 +515,7 @@ function wp_edit_theme_plugin_file( $args ) { } // Make sure PHP process doesn't die before loopback requests complete. - @set_time_limit( 300 ); + set_time_limit( 300 ); // Time to wait for loopback requests to finish. $timeout = 100; @@ -780,7 +781,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) { } // A properly uploaded file will pass this test. There should be no reason to override this one. - $test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_readable( $file['tmp_name'] ); + $test_uploaded_file = 'wp_handle_upload' === $action ? is_uploaded_file( $file['tmp_name'] ) : @is_readable( $file['tmp_name'] ); if ( ! $test_uploaded_file ) { return call_user_func_array( $upload_error_handler, array( &$file, __( 'Specified file failed upload test.' ) ) ); } @@ -848,10 +849,11 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) { if ( null === $move_new_file ) { if ( 'wp_handle_upload' === $action ) { - $move_new_file = @ move_uploaded_file( $file['tmp_name'], $new_file ); + $move_new_file = @move_uploaded_file( $file['tmp_name'], $new_file ); } else { // use copy and unlink because rename breaks streams. - $move_new_file = @ copy( $file['tmp_name'], $new_file ); + // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged + $move_new_file = @copy( $file['tmp_name'], $new_file ); unlink( $file['tmp_name'] ); } @@ -868,7 +870,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) { // Set correct file permissions. $stat = stat( dirname( $new_file ) ); $perms = $stat['mode'] & 0000666; - @ chmod( $new_file, $perms ); + chmod( $new_file, $perms ); // Compute the URL. $url = $uploads['url'] . "/$filename"; @@ -1854,7 +1856,7 @@ function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_f $GLOBALS['_wp_filesystem_direct_method'] = 'relaxed_ownership'; } - @fclose( $temp_handle ); + fclose( $temp_handle ); @unlink( $temp_file_name ); } } diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 951f51fc60..374bde41c8 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -163,7 +163,7 @@ function wp_update_image_subsizes( $attachment_id ) { function wp_create_image_subsizes( $file, $image_meta, $attachment_id ) { if ( empty( $image_meta ) || ! isset( $image_meta['width'], $image_meta['height'] ) ) { // New uploaded image. - $imagesize = getimagesize( $file ); + $imagesize = @getimagesize( $file ); $image_meta['width'] = $imagesize[0]; $image_meta['height'] = $imagesize[1]; @@ -450,7 +450,11 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) { * @return int|float */ function wp_exif_frac2dec( $str ) { - @list( $n, $d ) = explode( '/', $str ); + if ( false === strpos( $str, '/' ) ) { + return $str; + } + + list( $n, $d ) = explode( '/', $str ); if ( ! empty( $d ) ) { return $n / $d; } @@ -466,8 +470,8 @@ function wp_exif_frac2dec( $str ) { * @return int */ function wp_exif_date2ts( $str ) { - @list( $date, $time ) = explode( ' ', trim( $str ) ); - @list( $y, $m, $d ) = explode( ':', $date ); + list( $date, $time ) = explode( ' ', trim( $str ) ); + list( $y, $m, $d ) = explode( ':', $date ); return strtotime( "{$y}-{$m}-{$d} {$time}" ); } @@ -863,7 +867,7 @@ function _copy_image_file( $attachment_id ) { */ wp_mkdir_p( dirname( $dst_file ) ); - if ( ! @copy( $src_file, $dst_file ) ) { + if ( ! copy( $src_file, $dst_file ) ) { $dst_file = false; } } else { diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 3b8e545b7f..a01e104757 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -376,7 +376,7 @@ function get_mu_plugins() { return $wp_plugins; } - @closedir( $plugins_dir ); + closedir( $plugins_dir ); if ( empty( $plugin_files ) ) { return $wp_plugins; @@ -444,7 +444,7 @@ function get_dropins() { return $dropins; } - @closedir( $plugins_dir ); + closedir( $plugins_dir ); if ( empty( $plugin_files ) ) { return $dropins; diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 36d04147ea..3d4c1aacf5 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1901,7 +1901,7 @@ function iframe_header( $title = '', $deprecated = false ) { $current_screen = get_current_screen(); - @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); + header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); _wp_admin_html_begin(); ?>
' . __( 'Plugin failed to reactivate due to a fatal 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 ); - @ini_set( 'display_errors', true ); //Ensure that Fatal errors are displayed. + ini_set( 'display_errors', true ); //Ensure that Fatal errors are displayed. wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); include( WP_PLUGIN_DIR . '/' . $plugin ); } diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php index 2047c16881..1e7feb8a16 100644 --- a/wp-admin/upgrade.php +++ b/wp-admin/upgrade.php @@ -54,7 +54,7 @@ if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) { $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ); } -@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); +header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); ?> > diff --git a/wp-includes/class-wp-dependency.php b/wp-includes/class-wp-dependency.php index 6934eb11d9..fc8099d5b9 100644 --- a/wp-includes/class-wp-dependency.php +++ b/wp-includes/class-wp-dependency.php @@ -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(); } diff --git a/wp-includes/class-wp-http-streams.php b/wp-includes/class-wp-http-streams.php index 841fc24a96..ee7ea4d2a7 100644 --- a/wp-includes/class-wp-http-streams.php +++ b/wp-includes/class-wp-http-streams.php @@ -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 ); } diff --git a/wp-includes/class-wp-image-editor-gd.php b/wp-includes/class-wp-image-editor-gd.php index 182e8e1efe..daec6b3d04 100644 --- a/wp-includes/class-wp-image-editor-gd.php +++ b/wp-includes/class-wp-image-editor-gd.php @@ -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. diff --git a/wp-includes/class-wp-image-editor-imagick.php b/wp-includes/class-wp-image-editor-imagick.php index d3ba054b25..1228ca0575 100644 --- a/wp-includes/class-wp-image-editor-imagick.php +++ b/wp-includes/class-wp-image-editor-imagick.php @@ -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( diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index f939e33ac0..ec9565266d 100644 --- a/wp-includes/class-wp.php +++ b/wp-includes/class-wp.php @@ -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 diff --git a/wp-includes/comment.php b/wp-includes/comment.php index ac85eaa247..6cd0eb4610 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -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 ); diff --git a/wp-includes/compat.php b/wp-includes/compat.php index 827a943980..38d51900c4 100644 --- a/wp-includes/compat.php +++ b/wp-includes/compat.php @@ -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' ); } diff --git a/wp-includes/cron.php b/wp-includes/cron.php index bd6138256c..5d26dd8df1 100644 --- a/wp-includes/cron.php +++ b/wp-includes/cron.php @@ -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; } diff --git a/wp-includes/default-constants.php b/wp-includes/default-constants.php index a004c9e663..6b55025ae6 100644 --- a/wp-includes/default-constants.php +++ b/wp-includes/default-constants.php @@ -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 ) ) { diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index 55079717a6..677a9b5d44 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -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]; diff --git a/wp-includes/feed.php b/wp-includes/feed.php index ecb4a25293..bd0c06fc25 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -407,7 +407,7 @@ function get_the_category_rss( $type = null ) { } elseif ( 'atom' == $type ) { $the_list .= sprintf( '