summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-01-02 21:45:11 +0000
committerDries Buytaert <dries@buytaert.net>2009-01-02 21:45:11 +0000
commit86aa636c8b5b2a3ef9437352af28cb8ed5f04523 (patch)
tree8a797a99ff808bb2820889f5e6fe800849363596
parentb3649703d59c4eca97383855eb4f27572a8634cb (diff)
downloadbrdo-86aa636c8b5b2a3ef9437352af28cb8ed5f04523.tar.gz
brdo-86aa636c8b5b2a3ef9437352af28cb8ed5f04523.tar.bz2
- Patch #353207 by CitizenKane and drewish: cleaned up the FILE_STATUS_TEMPORARY field.
-rw-r--r--includes/file.inc29
-rw-r--r--modules/simpletest/tests/file.test2
-rw-r--r--modules/system/system.test4
-rw-r--r--modules/upload/upload.module2
4 files changed, 14 insertions, 23 deletions
diff --git a/includes/file.inc b/includes/file.inc
index 360b66fc4..54485aede 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -20,9 +20,10 @@
* - filepath - Path of the file relative to Drupal root.
* - filemime - The file's MIME type.
* - filesize - The size of the file in bytes.
- * - status - 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.
+ * - status - A bitmapped field indicating the status of the file. The first 8
+ * bits are reserved for Drupal core. The least sigifigant bit indicates
+ * temporary (0) or permanent (1). Temporary files older than
+ * DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during cron runs.
* - timestamp - UNIX timestamp for the date the file was added to the database.
*/
@@ -68,19 +69,10 @@ define('FILE_EXISTS_REPLACE', 1);
define('FILE_EXISTS_ERROR', 2);
/**
- * File status -- File has been temporarily saved to the {files} tables.
- *
- * Drupal's file garbage collection will delete the file and remove it from the
- * files table after a set period of time.
- */
-define('FILE_STATUS_TEMPORARY', 0);
-
-/**
- * File status -- File has been permanently saved to the {files} tables.
- *
- * If you wish to add custom statuses for use by contrib modules please expand
- * as binary flags and consider the first 8 bits reserved.
- * (0,1,2,4,8,16,32,64,128).
+ * File status -- This bit in the status indicates that the file is permanent
+ * and should not be deleted during file garbage collection process. Temporary
+ * files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during cron
+ * runs.
*/
define('FILE_STATUS_PERMANENT', 1);
@@ -854,7 +846,7 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
// Begin building file object.
$file = new stdClass();
$file->uid = $user->uid;
- $file->status = FILE_STATUS_TEMPORARY;
+ $file->status = 0;
$file->filename = file_munge_filename(trim(basename($_FILES['files']['name'][$source]), '.'), $extensions);
$file->filepath = $_FILES['files']['tmp_name'][$source];
$file->filemime = file_get_mimetype($file->filename);
@@ -1138,7 +1130,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
$file->filename = basename($file->filepath);
$file->filemime = file_get_mimetype($file->filepath);
$file->uid = $user->uid;
- $file->status = FILE_STATUS_PERMANENT;
+ $file->status |= FILE_STATUS_PERMANENT;
return file_save($file);
}
return FALSE;
@@ -1758,7 +1750,6 @@ function file_get_mimetype($filename, $mapping = NULL) {
return 'application/octet-stream';
}
-
/**
* @} End of "defgroup file".
*/
diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test
index 861cbdc17..dc9f08f61 100644
--- a/modules/simpletest/tests/file.test
+++ b/modules/simpletest/tests/file.test
@@ -86,7 +86,7 @@ class FileTestCase extends DrupalWebTestCase {
$file->uid = 1;
$file->timestamp = REQUEST_TIME;
$file->filesize = filesize($file->filepath);
- $file->status = FILE_STATUS_TEMPORARY;
+ $file->status = 0;
$this->assertNotIdentical(drupal_write_record('files', $file), FALSE, t('The file was added to the database.'));
return $file;
diff --git a/modules/system/system.test b/modules/system/system.test
index c751bcdc8..3773af13c 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -263,12 +263,12 @@ class CronRunTestCase extends DrupalWebTestCase {
// Temporary file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
$temp_old = file_save_data('');
- db_query('UPDATE {files} SET status = :status, timestamp = :timestamp WHERE fid = :fid', array(':status' => FILE_STATUS_TEMPORARY, ':timestamp' => 1, ':fid' => $temp_old->fid));
+ db_query('UPDATE {files} SET status = :status, timestamp = :timestamp WHERE fid = :fid', array(':status' => 0, ':timestamp' => 1, ':fid' => $temp_old->fid));
$this->assertTrue(file_exists($temp_old->filepath), t('Old temp file was created correctly.'));
// Temporary file that is less than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
$temp_new = file_save_data('');
- db_query('UPDATE {files} SET status = :status WHERE fid = :fid', array(':status' => FILE_STATUS_TEMPORARY, ':fid' => $temp_new->fid));
+ db_query('UPDATE {files} SET status = :status WHERE fid = :fid', array(':status' => 0, ':fid' => $temp_new->fid));
$this->assertTrue(file_exists($temp_new->filepath), t('New temp file was created correctly.'));
// Permanent file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 3b9a87b6b..4a3ed59f6 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -528,7 +528,7 @@ function upload_save(&$node) {
->condition('vid', $node->vid, '=')
->execute();
}
- $file->status &= FILE_STATUS_PERMANENT;
+ $file->status |= FILE_STATUS_PERMANENT;
$file = file_save($file);
}
}