summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2008-09-15 09:28:50 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2008-09-15 09:28:50 +0000
commite7ac5c58fd101d0de71a1397dd5b33f1b62c5fc7 (patch)
tree93e4aa08fda69ea8bb2ad31c9af38124c2668a2e /modules
parent1806af909cc912e3ae688577b52a4edbcaf25678 (diff)
downloadbrdo-e7ac5c58fd101d0de71a1397dd5b33f1b62c5fc7.tar.gz
brdo-e7ac5c58fd101d0de71a1397dd5b33f1b62c5fc7.tar.bz2
#308434 by drewish, dopry, quicksketch, aaron, jhedstrom, and friends: Massive file.inc cleanup aaaaaand... tests! Yay! :D
Diffstat (limited to 'modules')
-rw-r--r--modules/blogapi/blogapi.module4
-rw-r--r--modules/color/color.module4
-rw-r--r--modules/system/system.admin.inc8
-rw-r--r--modules/system/system.install8
-rw-r--r--modules/upload/upload.module3
-rw-r--r--modules/upload/upload.test4
-rw-r--r--modules/user/user.module6
7 files changed, 18 insertions, 19 deletions
diff --git a/modules/blogapi/blogapi.module b/modules/blogapi/blogapi.module
index e14c1e689..70938c0f1 100644
--- a/modules/blogapi/blogapi.module
+++ b/modules/blogapi/blogapi.module
@@ -385,12 +385,12 @@ function blogapi_metaweblog_new_media_object($blogid, $username, $password, $fil
return blogapi_error(t('No file sent.'));
}
- if (!$file = file_save_data($data, $name)) {
+ if (!$filepath = file_save_data($data, $name)) {
return blogapi_error(t('Error storing file.'));
}
// Return the successful result.
- return array('url' => file_create_url($file), 'struct');
+ return array('url' => file_create_url($filepath), 'struct');
}
/**
* Blogging API callback. Returns a list of the taxonomy terms that can be
diff --git a/modules/color/color.module b/modules/color/color.module
index 0f1d41fe3..c7dbc35c5 100644
--- a/modules/color/color.module
+++ b/modules/color/color.module
@@ -435,8 +435,8 @@ function _color_rewrite_stylesheet($theme, &$info, &$paths, $palette, $style) {
* Save the rewritten stylesheet to disk.
*/
function _color_save_stylesheet($file, $style, &$paths) {
- file_save_data($style, $file, FILE_EXISTS_REPLACE);
- $paths['files'][] = $file;
+ $filepath = file_save_data($style, $file, FILE_EXISTS_REPLACE);
+ $paths['files'][] = $filepath;
// Set standard file permissions for webserver-generated files.
@chmod($file, 0664);
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index c3f7e05b2..1cde4be2b 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -338,9 +338,9 @@ function system_theme_settings(&$form_state, $key = '') {
// The image was saved using file_save_upload() and was added to the
// files table as a temporary file. We'll make a copy and let the garbage
// collector delete the original upload.
- if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
+ if ($filepath = file_copy($file->filepath, $filename, FILE_EXISTS_REPLACE)) {
$_POST['default_logo'] = 0;
- $_POST['logo_path'] = $file->filepath;
+ $_POST['logo_path'] = $filepath;
$_POST['toggle_logo'] = 1;
}
}
@@ -353,9 +353,9 @@ function system_theme_settings(&$form_state, $key = '') {
// The image was saved using file_save_upload() and was added to the
// files table as a temporary file. We'll make a copy and let the garbage
// collector delete the original upload.
- if (file_copy($file, $filename)) {
+ if ($filepath = file_copy($file->filepath, $filename, FILE_EXISTS_REPLACE)) {
$_POST['default_favicon'] = 0;
- $_POST['favicon_path'] = $file->filepath;
+ $_POST['favicon_path'] = $filepath;
$_POST['toggle_favicon'] = 1;
}
}
diff --git a/modules/system/system.install b/modules/system/system.install
index e133d55ec..af2ceab33 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -629,7 +629,7 @@ function system_schema() {
'description' => t('Stores information for uploaded files.'),
'fields' => array(
'fid' => array(
- 'description' => t('Primary Key: Unique files ID.'),
+ 'description' => t('File ID.'),
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
@@ -642,7 +642,7 @@ function system_schema() {
'default' => 0,
),
'filename' => array(
- 'description' => t('Name of the file.'),
+ 'description' => t('Name of the file with no path components. This may differ from the basename of the filepath if the file is renamed to avoid overwriting an existing file.'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
@@ -656,7 +656,7 @@ function system_schema() {
'default' => '',
),
'filemime' => array(
- 'description' => t('The file MIME type.'),
+ 'description' => t("The file's MIME type."),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
@@ -670,7 +670,7 @@ function system_schema() {
'default' => 0,
),
'status' => array(
- 'description' => t('A flag indicating whether file is temporary (1) or permanent (0).'),
+ 'description' => t('A bitmapped field indicating the status of the file the least sigifigant bit indicates temporary (1) or permanent (0). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index bb71adb00..747bacb85 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -420,13 +420,12 @@ function upload_save(&$node) {
// Create a new revision, or associate a new file needed.
if (!empty($node->old_vid) || isset($_SESSION['upload_files'][$fid])) {
db_query("INSERT INTO {upload} (fid, nid, vid, list, description, weight) VALUES (%d, %d, %d, %d, '%s', %d)", $file->fid, $node->nid, $node->vid, $file->list, $file->description, $file->weight);
- file_set_status($file, FILE_STATUS_PERMANENT);
}
// Update existing revision.
else {
db_query("UPDATE {upload} SET list = %d, description = '%s', weight = %d WHERE fid = %d AND vid = %d", $file->list, $file->description, $file->weight, $file->fid, $node->vid);
- file_set_status($file, FILE_STATUS_PERMANENT);
}
+ file_set_status($file, FILE_STATUS_PERMANENT);
}
// Empty the session storage after save. We use this variable to track files
// that haven't been related to the node yet.
diff --git a/modules/upload/upload.test b/modules/upload/upload.test
index 51f9cc81e..842883b54 100644
--- a/modules/upload/upload.test
+++ b/modules/upload/upload.test
@@ -106,7 +106,7 @@ class UploadTestCase extends DrupalWebTestCase {
// Attempt to upload .txt file when .test is only extension allowed.
$this->uploadFile($node, $files[0], FALSE);
- $this->assertRaw(t('The selected file %name could not be uploaded. Only files with the following extensions are allowed: %files-allowed.', array('%name' => basename($files[0]), '%files-allowed' => $settings['upload_extensions'])), 'File '. $files[0] . ' was not allowed to be uploaded');
+ $this->assertRaw(t('The specified file %name could not be uploaded. Only files with the following extensions are allowed: %files-allowed.', array('%name' => basename($files[0]), '%files-allowed' => $settings['upload_extensions'])), 'File '. $files[0] . ' was not allowed to be uploaded');
// Attempt to upload .test file when .test is only extension allowed.
$this->uploadFile($node, $files[1]);
@@ -143,7 +143,7 @@ class UploadTestCase extends DrupalWebTestCase {
$filename = basename($file);
$filesize = format_size($info['size']);
$maxsize = format_size(parse_size(($settings['upload_uploadsize'] * 1024) . 'KB')); // Won't parse decimals.
- $this->assertRaw(t('The selected file %name could not be uploaded. The file is %filesize exceeding the maximum file size of %maxsize.', array('%name' => $filename, '%filesize' => $filesize, '%maxsize' => $maxsize)), t('File upload was blocked since it was larger than maxsize.'));
+ $this->assertRaw(t('The specified file %name could not be uploaded. The file is %filesize exceeding the maximum file size of %maxsize.', array('%name' => $filename, '%filesize' => $filesize, '%maxsize' => $maxsize)), t('File upload was blocked since it was larger than maxsize.'));
}
function setUploadSettings($settings, $rid = NULL) {
diff --git a/modules/user/user.module b/modules/user/user.module
index 40c5d9588..50cd6695d 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -414,9 +414,9 @@ function user_validate_picture(&$form, &$form_state) {
// files table as a temporary file. We'll make a copy and let the garbage
// collector delete the original upload.
$info = image_get_info($file->filepath);
- $destination = variable_get('user_picture_path', 'pictures') . '/picture-' . $form['#uid'] . '.' . $info['extension'];
- if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
- $form_state['values']['picture'] = $file->filepath;
+ $destination = file_create_path(variable_get('user_picture_path', 'pictures') . '/picture-' . $form['#uid'] . '.' . $info['extension']);
+ if ($filepath = file_copy($file->filepath, $destination, FILE_EXISTS_REPLACE)) {
+ $form_state['values']['picture'] = $filepath;
}
else {
form_set_error('picture_upload', t("Failed to upload the picture image; the %directory directory doesn't exist or is not writable.", array('%directory' => variable_get('user_picture_path', 'pictures'))));