diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-08-22 13:52:59 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-08-22 13:52:59 +0000 |
commit | 4a7bb638fb3243a35dd2ce82a4cafc78d2f6b9d2 (patch) | |
tree | 3e17684510b739dafb359a17a1d26027fe168ec6 /modules/system/system.install | |
parent | b36d4959ef2244298fd28d02575c88b0259555b4 (diff) | |
download | brdo-4a7bb638fb3243a35dd2ce82a4cafc78d2f6b9d2.tar.gz brdo-4a7bb638fb3243a35dd2ce82a4cafc78d2f6b9d2.tar.bz2 |
- Patch #353458 by quicksketch, drewish, jpetso, sun, noahb, aaron, chx, mikey_p, dhthwy: hook_file_references() was not designed for a highly flexible field storage.
Diffstat (limited to 'modules/system/system.install')
-rw-r--r-- | modules/system/system.install | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/modules/system/system.install b/modules/system/system.install index d4da8b4a7..174416c05 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -835,6 +835,52 @@ function system_schema() { ), ); + $schema['file_usage'] = array( + 'description' => 'Track where a file is used.', + 'fields' => array( + 'fid' => array( + 'description' => 'File ID.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + ), + 'module' => array( + 'description' => 'The name of the module that is using the file.', + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + ), + 'type' => array( + 'description' => 'The name of the object type in which the file is used.', + 'type' => 'varchar', + 'length' => 64, + 'not null' => TRUE, + 'default' => '', + ), + 'id' => array( + 'description' => 'The primary key of the object using the file.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'count' => array( + 'description' => 'The number of times this file is used by this object.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('fid', 'type', 'id', 'module'), + 'indexes' => array( + 'type_id' => array('type', 'id'), + 'fid_count' => array('fid', 'count'), + 'fid_module' => array('fid', 'module'), + ), + ); + $schema['flood'] = array( 'description' => 'Flood controls the threshold of events, such as the number of contact attempts.', 'fields' => array( @@ -2763,6 +2809,10 @@ function system_update_7059(&$sandbox) { // Update the node field with the file URI. $revision['file'][LANGUAGE_NONE][$delta] = $file; + + // Add the usage entry for the file. + $file = (object) $file; + file_usage_add($file, 'file', 'node', $revision->nid); } // Insert the revision's files into the field_upload table. @@ -2786,6 +2836,58 @@ function system_update_7059(&$sandbox) { } /** + * Create the file_usage table. + */ +function system_update_7060() { + $spec = array( + 'description' => 'Track where a file is used.', + 'fields' => array( + 'fid' => array( + 'description' => 'File ID.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + ), + 'module' => array( + 'description' => 'The name of the module that is using the file.', + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + ), + 'type' => array( + 'description' => 'The name of the object type in which the file is used.', + 'type' => 'varchar', + 'length' => 64, + 'not null' => TRUE, + 'default' => '', + ), + 'id' => array( + 'description' => 'The primary key of the object using the file.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'count' => array( + 'description' => 'The number of times this file is used by this object.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('fid', 'type', 'id', 'module'), + 'indexes' => array( + 'type_id' => array('type', 'id'), + 'fid_count' => array('fid', 'count'), + 'fid_module' => array('fid', 'module'), + ), + ); + db_create_table('file_usage', $spec); +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ |