Index: src/wp-admin/includes/class-plugin-upgrader.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/wp-admin/includes/class-plugin-upgrader.php	(revision 2904099432764ad1a9bf4c2ab4ba34b4098a1926)
+++ src/wp-admin/includes/class-plugin-upgrader.php	(revision )
@@ -406,7 +406,7 @@
 			return $return;
 
 		// When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it
-		if ( defined( 'DOING_CRON' ) && DOING_CRON )
+		if ( wp_doing_cron() )
 			return $return;
 
 		$plugin = isset($plugin['plugin']) ? $plugin['plugin'] : '';
Index: src/wp-admin/includes/file.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/wp-admin/includes/file.php	(revision 2904099432764ad1a9bf4c2ab4ba34b4098a1926)
+++ src/wp-admin/includes/file.php	(revision )
@@ -663,7 +663,7 @@
 	 * A disk that has zero free bytes has bigger problems.
 	 * Require we have enough space to unzip the file and copy its contents, with a 10% buffer.
 	 */
-	if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
+	if ( wp_doing_cron() ) {
 		$available_space = @disk_free_space( WP_CONTENT_DIR );
 		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
 			return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
@@ -769,7 +769,7 @@
 	 * A disk that has zero free bytes has bigger problems.
 	 * Require we have enough space to unzip the file and copy its contents, with a 10% buffer.
 	 */
-	if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
+	if ( wp_doing_cron() ) {
 		$available_space = @disk_free_space( WP_CONTENT_DIR );
 		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
 			return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
Index: src/wp-includes/update.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/wp-includes/update.php	(revision 2904099432764ad1a9bf4c2ab4ba34b4098a1926)
+++ src/wp-includes/update.php	(revision )
@@ -108,8 +108,10 @@
 	if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
 		$url = set_url_scheme( $url, 'https' );
 
+	$doing_cron = wp_doing_cron();
+
 	$options = array(
-		'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
+		'timeout' => $doing_cron ? 30 : 3,
 		'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
 		'headers' => array(
 			'wp_install' => $wp_install,
@@ -177,7 +179,7 @@
 	}
 
 	// Trigger background updates if running non-interactively, and we weren't called from the update handler.
-	if ( defined( 'DOING_CRON' ) && DOING_CRON && ! doing_action( 'wp_maybe_auto_update' ) ) {
+	if ( $doing_cron && ! doing_action( 'wp_maybe_auto_update' ) ) {
 		do_action( 'wp_maybe_auto_update' );
 	}
 }
@@ -217,6 +219,8 @@
 	$new_option = new stdClass;
 	$new_option->last_checked = time();
 
+	$doing_cron = wp_doing_cron();
+
 	// Check for update on a different schedule, depending on the page.
 	switch ( current_filter() ) {
 		case 'upgrader_process_complete' :
@@ -230,7 +234,7 @@
 			$timeout = HOUR_IN_SECONDS;
 			break;
 		default :
-			if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
+			if ( $doing_cron ) {
 				$timeout = 0;
 			} else {
 				$timeout = 12 * HOUR_IN_SECONDS;
@@ -282,7 +286,7 @@
 	$locales = apply_filters( 'plugins_update_check_locales', $locales );
 	$locales = array_unique( $locales );
 
-	if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
+	if ( $doing_cron ) {
 		$timeout = 30;
 	} else {
 		// Three seconds, plus one extra second for every 10 plugins
@@ -400,6 +404,8 @@
 		);
 	}
 
+	$doing_cron = wp_doing_cron();
+
 	// Check for update on a different schedule, depending on the page.
 	switch ( current_filter() ) {
 		case 'upgrader_process_complete' :
@@ -413,11 +419,7 @@
 			$timeout = HOUR_IN_SECONDS;
 			break;
 		default :
-			if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
-				$timeout = 0;
-			} else {
-				$timeout = 12 * HOUR_IN_SECONDS;
-			}
+			$timeout = $doing_cron ? 0 : 12 * HOUR_IN_SECONDS;
 	}
 
 	$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked );
@@ -463,7 +465,7 @@
 	$locales = apply_filters( 'themes_update_check_locales', $locales );
 	$locales = array_unique( $locales );
 
-	if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
+	if ( $doing_cron ) {
 		$timeout = 30;
 	} else {
 		// Three seconds, plus one extra second for every 10 themes
Index: src/wp-includes/load.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/wp-includes/load.php	(revision 2904099432764ad1a9bf4c2ab4ba34b4098a1926)
+++ src/wp-includes/load.php	(revision )
@@ -1059,6 +1059,24 @@
 	return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX );
 }
 
+/**
+ * Determines whether the current request is doing a CRON task.
+ *
+ * @since 4.8.0
+ *
+ * @return bool True if we are doing a CRON task, false otherwise.
+ */
+function wp_doing_cron() {
+	/**
+	 * Filters whether the current request is doing a CRON task.
+	 *
+	 * @since 4.8.0
+	 *
+	 * @param bool $wp_doing_cron Whether the current request is doing a CRON task.
+	 */
+	return apply_filters( 'wp_doing_cron', defined( 'DOING_CRON' ) && DOING_CRON );
+}
+
 /**
  * Check whether variable is a WordPress Error.
  *
Index: src/wp-admin/includes/update.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/wp-admin/includes/update.php	(revision 2904099432764ad1a9bf4c2ab4ba34b4098a1926)
+++ src/wp-admin/includes/update.php	(revision )
@@ -107,7 +107,7 @@
 		$url = set_url_scheme( $url, 'https' );
 
 	$options = array(
-		'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
+		'timeout' => wp_doing_cron() ? 30 : 3,
 	);
 
 	$response = wp_remote_get( $url, $options );
