summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-09-19 10:38:47 +0000
committerDries Buytaert <dries@buytaert.net>2009-09-19 10:38:47 +0000
commitdb81ff520543dc6584336c736cdb4d3f8b62996f (patch)
treec459608d7f0cea5aedc23a030f1a4a41d8d29be9 /includes
parent2bc3de6a4ffa99e47ddfd05fbe75927c882412d4 (diff)
downloadbrdo-db81ff520543dc6584336c736cdb4d3f8b62996f.tar.gz
brdo-db81ff520543dc6584336c736cdb4d3f8b62996f.tar.bz2
- Patch #581286 by David Strauss | moshe weitzman: fixed detection of CLI environments properly.
Diffstat (limited to 'includes')
-rw-r--r--includes/bootstrap.inc13
1 files changed, 10 insertions, 3 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 3dc80262b..18a370923 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -431,7 +431,7 @@ function drupal_override_server_variables($variables = array()) {
'REMOTE_ADDR' => '127.0.0.1',
'REQUEST_METHOD' => 'GET',
'SERVER_NAME' => NULL,
- 'SERVER_SOFTWARE' => 'PHP CLI',
+ 'SERVER_SOFTWARE' => NULL,
'HTTP_USER_AGENT' => NULL,
);
// Replace elements of the $_SERVER array, as appropriate.
@@ -787,7 +787,7 @@ function drupal_page_is_cacheable($allow_caching = NULL) {
}
return $allow_caching_static && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD')
- && $_SERVER['SERVER_SOFTWARE'] !== 'PHP CLI';
+ && !drupal_is_cli();
}
/**
@@ -1546,7 +1546,7 @@ function _drupal_bootstrap($phase) {
require_once DRUPAL_ROOT . '/' . variable_get('lock_inc', 'includes/lock.inc');
lock_initialize();
- if ($_SERVER['SERVER_SOFTWARE'] !== 'PHP CLI') {
+ if (!drupal_is_cli()) {
ob_start();
drupal_page_header();
}
@@ -1999,3 +1999,10 @@ function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
function drupal_static_reset($name = NULL) {
drupal_static($name, NULL, TRUE);
}
+
+/**
+ * Detect 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)));
+}