Commit 8074550d authored by alexpott's avatar alexpott

Issue #2294161 by ParisLiakos: Deprecate and remove usages of drupal_is_cli().

parent 1742e5e9
......@@ -405,7 +405,7 @@ function drupal_page_is_cacheable($allow_caching = NULL) {
}
return $allow_caching_static && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD')
&& !drupal_is_cli();
&& PHP_SAPI !== 'cli';
}
/**
......@@ -1728,6 +1728,9 @@ function drupal_static_reset($name = NULL) {
/**
* Detects whether the current script is running in a command-line environment.
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Check the PHP_SAPI value directly instead.
*/
function drupal_is_cli() {
return PHP_SAPI === 'cli';
......
......@@ -158,7 +158,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
\Drupal::logger('php')->log($error['severity_level'], '%type: !message in %function (line %line of %file).', $error);
if (drupal_is_cli()) {
if (PHP_SAPI === 'cli') {
if ($fatal) {
// When called from CLI, simply output a plain text message.
// Should not translate the string to avoid errors producing more errors.
......
......@@ -211,7 +211,7 @@ public static function createFromRequest(Request $request, ClassLoader $class_lo
// Redirect the user to the installation script if Drupal has not been
// installed yet (i.e., if no $databases array has been defined in the
// settings.php file) and we are not already installing.
if (!Database::getConnectionInfo() && !drupal_installation_attempted() && !drupal_is_cli()) {
if (!Database::getConnectionInfo() && !drupal_installation_attempted() && PHP_SAPI !== 'cli') {
$response = new RedirectResponse($request->getBasePath() . '/core/install.php');
$response->prepare($request)->send();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment