diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 8f78e269b8cf220dd8b72b0391e64bbd5d2167a6..4b6dbb8b843b63ebab8204f1efdee7b44ee67f97 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -2461,7 +2461,7 @@ function drupal_static_reset($name = NULL) {
  * Detects whether the current script is running in a command-line environment.
  */
 function drupal_is_cli() {
-  return (!isset($_SERVER['SERVER_SOFTWARE']) && (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0)));
+  return PHP_SAPI === 'cli';
 }
 
 /**