From 02dd3c52cd66cdc48aeab5834a163ff0321cefca Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 13 May 2011 22:06:30 -0400 Subject: - Patch #843162 by pwolanin, Scott Falconer, Berdir, jhodgdon, a.mikheychik, mtift: creating vocabularies with machine-names 'List' or 'Add' breaks links in taxonomy overview admin area. --- modules/update/update.manager.inc | 26 +--------------- modules/update/update.module | 63 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 28 deletions(-) (limited to 'modules/update') diff --git a/modules/update/update.manager.inc b/modules/update/update.manager.inc index ad8aefdd8..35b292905 100644 --- a/modules/update/update.manager.inc +++ b/modules/update/update.manager.inc @@ -730,26 +730,6 @@ function update_manager_install_form_submit($form, &$form_state) { * and verify archive files. */ -/** - * Return the directory where update archive files should be extracted. - * - * If the directory does not already exist, attempt to create it. - * - * @return - * The full path to the temporary directory where update file archives - * should be extracted. - */ -function _update_manager_extract_directory() { - $directory = &drupal_static(__FUNCTION__, ''); - if (empty($directory)) { - $directory = 'temporary://update-extraction'; - if (!file_exists($directory)) { - mkdir($directory); - } - } - return $directory; -} - /** * Unpack a downloaded archive file. * @@ -829,13 +809,9 @@ function update_manager_file_get($url) { } // Check the cache and download the file if needed. - $cache_directory = 'temporary://update-cache'; + $cache_directory = _update_manager_cache_directory(); $local = $cache_directory . '/' . basename($parsed_url['path']); - if (!file_exists($cache_directory)) { - mkdir($cache_directory); - } - if (!file_exists($local) || update_delete_file_if_stale($local)) { return system_retrieve_file($url, $local, FALSE, FILE_EXISTS_REPLACE); } diff --git a/modules/update/update.module b/modules/update/update.module index 10089649d..a66cfa512 100644 --- a/modules/update/update.module +++ b/modules/update/update.module @@ -856,14 +856,71 @@ function update_flush_caches() { * @} End of "defgroup update_status_cache". */ +/** + * Return a short unique identifier for this Drupal installation. + * + * @return + * An eight character string uniquely identifying this Drupal installation. + */ +function _update_manager_unique_identifier() { + $id = &drupal_static(__FUNCTION__, ''); + if (empty($id)) { + $id = substr(hash('sha256', drupal_get_hash_salt()), 0, 8); + } + return $id; +} + +/** + * Return the directory where update archive files should be extracted. + * + * @param $create + * If TRUE, attempt to create the directory if it does not already exist. + * + * @return + * The full path to the temporary directory where update file archives + * should be extracted. + */ +function _update_manager_extract_directory($create = TRUE) { + $directory = &drupal_static(__FUNCTION__, ''); + if (empty($directory)) { + $directory = 'temporary://update-extraction-' . _update_manager_unique_identifier(); + if ($create && !file_exists($directory)) { + mkdir($directory); + } + } + return $directory; +} + +/** + * Return the directory where update archive files should be cached. + * + * @param $create + * If TRUE, attempt to create the directory if it does not already exist. + * + * @return + * The full path to the temporary directory where update file archives + * should be cached. + */ +function _update_manager_cache_directory($create = TRUE) { + $directory = &drupal_static(__FUNCTION__, ''); + if (empty($directory)) { + $directory = 'temporary://update-cache-' . _update_manager_unique_identifier(); + if ($create && !file_exists($directory)) { + mkdir($directory); + } + } + return $directory; +} + /** * Clear the temporary files and directories based on file age from disk. */ function update_clear_update_disk_cache() { - // List of update module cache directories. + // List of update module cache directories. Do not create the directories if + // they do not exist. $directories = array( - 'temporary://update-cache', - 'temporary://update-extraction', + _update_manager_cache_directory(FALSE), + _update_manager_extract_directory(FALSE), ); // Search for files and directories in base folder only without recursion. -- cgit v1.2.3