diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-06-12 08:15:15 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-06-12 08:15:15 +0000 |
commit | 7affd91ab6cbef068b56d050c20224382d922d7f (patch) | |
tree | ad200702d794fa1f85e365e995db753cd46250ba | |
parent | e0adb9306466fc738004e071e3f9b063441814e2 (diff) | |
download | brdo-7affd91ab6cbef068b56d050c20224382d922d7f.tar.gz brdo-7affd91ab6cbef068b56d050c20224382d922d7f.tar.bz2 |
#551658 follow-up by pwolanin: Revert back to D6-style temporary folder logic to avoid various platform issues.
-rw-r--r-- | includes/bootstrap.inc | 2 | ||||
-rw-r--r-- | includes/file.inc | 45 | ||||
-rw-r--r-- | includes/stream_wrappers.inc | 2 | ||||
-rw-r--r-- | modules/simpletest/tests/file.test | 2 |
4 files changed, 48 insertions, 3 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()); } /** diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test index efe55f7ab..e501f57d0 100644 --- a/modules/simpletest/tests/file.test +++ b/modules/simpletest/tests/file.test @@ -752,7 +752,7 @@ class FileDirectoryTest extends FileTestCase { function testFileDirectoryTemp() { // Temporary directory handling. variable_set('file_directory_temp', NULL); - $temp = file_directory_path('temporary'); + $temp = file_directory_temp(); $this->assertTrue(!is_null($temp), t('Properly set and retrieved temp directory %directory.', array('%directory' => $temp)), 'File'); } |