diff options
-rw-r--r-- | includes/file.inc | 6 | ||||
-rw-r--r-- | modules/simpletest/tests/file.test | 13 | ||||
-rw-r--r-- | modules/system/system.module | 7 |
3 files changed, 19 insertions, 7 deletions
diff --git a/includes/file.inc b/includes/file.inc index fa72e195f..715ab7ed3 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -2277,9 +2277,9 @@ 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); + $temporary_directory = variable_get('file_temporary_path', NULL); - if (!isset($temporary_directory)) { + if (empty($temporary_directory)) { $directories = array(); // Has PHP been set with an upload_tmp_dir? @@ -2316,7 +2316,7 @@ function file_directory_temp() { $temporary_directory = variable_get('file_public_path', conf_path() . '/files') . $path_delimiter . 'tmp'; } // Save the path of the discovered directory. - variable_set('file_directory_temp', $temporary_directory); + variable_set('file_temporary_path', $temporary_directory); } return $temporary_directory; diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test index 94a65938e..36a7170b2 100644 --- a/modules/simpletest/tests/file.test +++ b/modules/simpletest/tests/file.test @@ -972,8 +972,19 @@ class FileDirectoryTest extends FileTestCase { $path = file_destination($destination, FILE_EXISTS_ERROR); $this->assertEqual($path, FALSE, t('An error is returned when filepath destination already exists with FILE_EXISTS_ERROR.'), 'File'); } -} + /** + * Ensure that the file_directory_temp() function always returns a value. + */ + function testFileDirectoryTemp() { + // Start with an empty variable to ensure we have a clean slate. + variable_set('file_temporary_path', ''); + $tmp_directory = file_directory_temp(); + $this->assertEqual(empty($tmp_directory), FALSE, t('file_directory_temp() returned a non-empty value.')); + $setting = variable_get('file_temporary_path', ''); + $this->assertEqual($setting, $tmp_directory, t("The 'file_temporary_path' variable has the same value that file_directory_temp() returned.")); + } +} /** * Tests the file_scan_directory() function. diff --git a/modules/system/system.module b/modules/system/system.module index bfbdc285c..08d2010cc 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -2069,9 +2069,10 @@ function system_admin_menu_block($item) { } /** - * Checks the existence of the directory specified in $form_element. This - * function is called from the system_settings form to check both core file - * directories (file_public_path, file_private_path, file_temporary_path). + * Checks the existence of the directory specified in $form_element. + * + * This function is called from the system_settings form to check all core + * file directories (file_public_path, file_private_path, file_temporary_path). * * @param $form_element * The form element containing the name of the directory to check. |