diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/bootstrap.inc | 2 | ||||
-rw-r--r-- | includes/file.inc | 45 | ||||
-rw-r--r-- | includes/stream_wrappers.inc | 2 |
3 files changed, 47 insertions, 2 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 7c8070078..7760c3242 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -19,7 +19,7 @@ define('DRUPAL_CORE_COMPATIBILITY', '7.x'); /** * Minimum supported version of PHP. */ -define('DRUPAL_MINIMUM_PHP', '5.2.1'); +define('DRUPAL_MINIMUM_PHP', '5.2.0'); /** * Minimum recommended value of PHP memory_limit. diff --git a/includes/file.inc b/includes/file.inc index 13a97e56b..dc6b53e96 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -1958,5 +1958,50 @@ function drupal_tempnam($directory, $prefix) { } /** + * Get the path of system-appropriate temporary directory. + */ +function file_directory_temp() { + $temporary_directory = variable_get('file_directory_temp', NULL); + + if (is_null($temporary_directory)) { + $directories = array(); + + // Has PHP been set with an upload_tmp_dir? + if (ini_get('upload_tmp_dir')) { + $directories[] = ini_get('upload_tmp_dir'); + } + + // Operating system specific dirs. + if (substr(PHP_OS, 0, 3) == 'WIN') { + $directories[] = 'c:\\windows\\temp'; + $directories[] = 'c:\\winnt\\temp'; + $path_delimiter = '\\'; + } + else { + $directories[] = '/tmp'; + $path_delimiter = '/'; + } + // PHP may be able to find an alternative tmp directory. + $directories[] = sys_get_temp_dir(); + + foreach ($directories as $directory) { + if (is_dir($directory) && is_writable($directory)) { + $temporary_directory = $directory; + break; + } + } + + // if a directory has been found, use it, otherwise default to 'files/tmp' or 'files\\tmp'; + if (empty($temporary_directory)) { + $temporary_directory = file_directory_path() . $path_delimiter .'tmp'; + } + // Save the path of the discovered directory. + variable_set('file_directory_temp', $temporary_directory); + } + + return $temporary_directory; +} + +/** * @} End of "defgroup file". */ diff --git a/includes/stream_wrappers.inc b/includes/stream_wrappers.inc index 38727aa14..13cd421d4 100644 --- a/includes/stream_wrappers.inc +++ b/includes/stream_wrappers.inc @@ -793,7 +793,7 @@ class DrupalTemporaryStreamWrapper extends DrupalLocalStreamWrapper { * Implements abstract public function getDirectoryPath() */ public function getDirectoryPath() { - return variable_get('file_temporary_path', sys_get_temp_dir()); + return variable_get('file_temporary_path', file_directory_temp()); } /** |