diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index b1ea3fba1bda2..091317669b9b6 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -1040,7 +1040,9 @@ function wp_handle_upload_error( &$file, $message ) { // Set correct file permissions. $stat = stat( dirname( $new_file ) ); $perms = $stat['mode'] & 0000666; - chmod( $new_file, $perms ); + if( function_exists('chmod') ) { + chmod( $new_file, $perms ); + } // Compute the URL. $url = $uploads['url'] . "/$filename"; @@ -2019,7 +2021,9 @@ function copy_dir( $from, $to, $skip_list = array() ) { if ( 'f' === $fileinfo['type'] ) { if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) { // If copy failed, chmod file to 0644 and try again. - $wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE ); + if( function_exists('chmod') ) { + $wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE ); + } if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) { return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename ); diff --git a/src/wp-admin/plugins.php b/src/wp-admin/plugins.php index 339056b28278d..f36630f5cba9e 100644 --- a/src/wp-admin/plugins.php +++ b/src/wp-admin/plugins.php @@ -189,7 +189,9 @@ 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. + if ( function_exists( 'ini_set' ) ) { + ini_set( 'display_errors', true ); // Ensure that fatal errors are displayed. + } // Go back to "sandbox" scope so we get the same errors as before. plugin_sandbox_scrape( $plugin ); /** This action is documented in wp-admin/includes/plugin.php */ diff --git a/src/wp-admin/update.php b/src/wp-admin/update.php index 090c37cfc4dfe..541947158b8f6 100644 --- a/src/wp-admin/update.php +++ b/src/wp-admin/update.php @@ -96,7 +96,9 @@ echo '
' . __( '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. + if ( function_exists( 'ini_set' ) ) { + 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/src/wp-includes/PHPMailer/PHPMailer.php b/src/wp-includes/PHPMailer/PHPMailer.php index 31731594f12ec..197e5e6e32f85 100644 --- a/src/wp-includes/PHPMailer/PHPMailer.php +++ b/src/wp-includes/PHPMailer/PHPMailer.php @@ -1946,7 +1946,9 @@ protected function mailSend($header, $body) $params = sprintf('-f%s', $this->Sender); } $old_from = ini_get('sendmail_from'); - ini_set('sendmail_from', $this->Sender); + if ( function_exists('ini_set') ) { + ini_set('sendmail_from', $this->Sender); + } } $result = false; if ($this->SingleTo && count($toArr) > 1) { @@ -1969,7 +1971,9 @@ protected function mailSend($header, $body) $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, []); } if (isset($old_from)) { - ini_set('sendmail_from', $old_from); + if ( function_exists('ini_set') ) { + ini_set('sendmail_from', $old_from); + } } if (!$result) { throw new Exception($this->lang('instantiate'), self::STOP_CRITICAL); diff --git a/src/wp-includes/default-constants.php b/src/wp-includes/default-constants.php index acfc878fb7138..519986f0a792f 100644 --- a/src/wp-includes/default-constants.php +++ b/src/wp-includes/default-constants.php @@ -68,7 +68,9 @@ 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 ); + if ( function_exists( 'ini_set' ) ) { + ini_set( 'memory_limit', WP_MEMORY_LIMIT ); + } } if ( ! isset( $blog_id ) ) { diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 7e46dd53cab2d..a46bb346cff56 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -7883,13 +7883,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 ( function_exists( 'ini_set' ) && 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 ( function_exists( 'ini_set' ) && false !== ini_set( 'memory_limit', $wp_max_limit ) ) { return $wp_max_limit; } else { return false; diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 5066cd16ee341..632b2d0c3d532 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -585,9 +585,13 @@ function wp_debug_mode() { error_reporting( E_ALL ); if ( WP_DEBUG_DISPLAY ) { - ini_set( 'display_errors', 1 ); + if ( function_exists( 'ini_set' ) ) { + ini_set( 'display_errors', 1 ); + } } elseif ( null !== WP_DEBUG_DISPLAY ) { - ini_set( 'display_errors', 0 ); + if ( function_exists( 'ini_set' ) ) { + ini_set( 'display_errors', 0 ); + } } if ( in_array( strtolower( (string) WP_DEBUG_LOG ), array( 'true', '1' ), true ) ) { @@ -599,8 +603,10 @@ function wp_debug_mode() { } if ( $log_path ) { - ini_set( 'log_errors', 1 ); - ini_set( 'error_log', $log_path ); + if ( function_exists( 'ini_set' ) ) { + ini_set( 'log_errors', 1 ); + ini_set( 'error_log', $log_path ); + } } } else { 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 ); @@ -614,7 +620,9 @@ function wp_debug_mode() { || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() || wp_is_json_request() ) { - ini_set( 'display_errors', 0 ); + if ( function_exists( 'ini_set' ) ) { + ini_set( 'display_errors', 0 ); + } } } diff --git a/src/wp-includes/pomo/po.php b/src/wp-includes/pomo/po.php index a4e3cab4ef17a..4be50a567c175 100644 --- a/src/wp-includes/pomo/po.php +++ b/src/wp-includes/pomo/po.php @@ -21,7 +21,9 @@ * which still use the old MacOS standalone `\r` as a line ending. * This fix should be revisited when PHP 9.0 is in alpha/beta. */ -@ini_set( 'auto_detect_line_endings', 1 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged +if ( function_exists( 'ini_set' ) ) { + @ini_set( 'auto_detect_line_endings', 1 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged +} /** * Routines for working with PO files