From 7affd91ab6cbef068b56d050c20224382d922d7f Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Sat, 12 Jun 2010 08:15:15 +0000 Subject: #551658 follow-up by pwolanin: Revert back to D6-style temporary folder logic to avoid various platform issues. --- includes/bootstrap.inc | 2 +- includes/file.inc | 45 ++++++++++++++++++++++++++++++++++++++++++++ includes/stream_wrappers.inc | 2 +- 3 files changed, 47 insertions(+), 2 deletions(-) (limited to 'includes') 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 @@ -1957,6 +1957,51 @@ 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()); } /** -- cgit v1.2.3