diff options
Diffstat (limited to 'modules/upload/upload.install')
-rw-r--r-- | modules/upload/upload.install | 133 |
1 files changed, 0 insertions, 133 deletions
diff --git a/modules/upload/upload.install b/modules/upload/upload.install deleted file mode 100644 index 0e4637eee..000000000 --- a/modules/upload/upload.install +++ /dev/null @@ -1,133 +0,0 @@ -<?php -// $Id$ - -/** - * @file - * Install, update and uninstall functions for the upload module. - */ - -/** - * @file - * This is the install file for the upload module. - */ - -/** - * Implements hook_schema(). - */ -function upload_schema() { - $schema['upload'] = array( - 'description' => 'Stores uploaded file information and table associations.', - 'fields' => array( - 'fid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Primary Key: The {file}.fid.', - ), - 'nid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The {node}.nid associated with the uploaded file.', - ), - 'vid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Primary Key: The {node}.vid associated with the uploaded file.', - ), - 'description' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - 'description' => 'Description of the uploaded file.', - 'translatable' => TRUE, - ), - 'list' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'size' => 'tiny', - 'description' => 'Whether the file should be visibly listed on the node: yes(1) or no(0).', - ), - 'weight' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'size' => 'tiny', - 'description' => 'Weight of this upload in relation to other uploads in this node.', - ), - ), - 'primary key' => array('vid', 'fid'), - 'foreign keys' => array( - 'fid' => array('files' => 'fid'), - 'nid' => array('node' => 'nid'), - 'vid' => array('node' => 'vid'), - ), - 'indexes' => array( - 'fid' => array('fid'), - 'nid' => array('nid'), - ), - ); - - return $schema; -} - - -/** - * Migrate upload module files from {files} to {file}. - */ -function upload_update_7000(&$sandbox) { - - /* - TODO: Fix the updates. This is broken. See http://drupal.org/node/329301#comment-1404336 - Also note new DB structure http://drupal.org/node/227232#comment-1683976 - */ - - if (!isset($sandbox['progress'])) { - // Initialize batch update information. - $sandbox['progress'] = 0; - $sandbox['last_fid_processed'] = -1; - $sandbox['max'] = db_query("SELECT COUNT(DISTINCT u.fid) FROM {upload} u")->fetchField(); - } - - // As a batch operation move records from {files} into the {file} table. - $limit = 500; - $result = db_query_range("SELECT DISTINCT u.fid FROM {upload} u ORDER BY u.vid", array(), 0, $limit); - foreach ($result as $record) { - $old_file = db_query('SELECT f.* FROM {files} f WHERE f.fid = :fid', array(':fid' => $record->fid))->fetch(PDO::FETCH_OBJ); - if (!$old_file) { - continue; - } - - $new_file = db_query('SELECT f.* FROM {files} f WHERE f.filepath = :filepath', array(':filepath' => $old_file->uri))->fetch(PDO::FETCH_OBJ); - if (!$new_file) { - // Re-save the file into the new {file} table. - $new_file = clone $old_file; - drupal_write_record('file', $new_file); - } - - // If the fid has changed we need to update the {upload} record to use the - // new id. - if (!empty($new_file->fid) && ($new_file->fid != $old_file->fid)) { - db_update('upload') - ->fields(array('fid' => $new_file->fid)) - ->condition('fid', $old_file->fid) - ->execute(); - } - - // Update our progress information for the batch update. - $sandbox['progress']++; - $sandbox['last_fid_processed'] = $old_file->fid; - } - - // Indicate our current progress to the batch update system. If there's no - // max value then there's nothing to update and we're finished. - $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']); -} - |