diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-04-10 17:30:15 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-04-10 17:30:15 +0000 |
commit | bdb7e56143d52bb8528042591f0e8df9afde45db (patch) | |
tree | 6801086da136619cdecfe34a94d482118f5fe4e7 /modules | |
parent | e892ed5c317f7d37da09a2ad3a0e113703437b10 (diff) | |
download | brdo-bdb7e56143d52bb8528042591f0e8df9afde45db.tar.gz brdo-bdb7e56143d52bb8528042591f0e8df9afde45db.tar.bz2 |
- Patch #741578 by nikgregory, andypost, Berdir, noahb: 'File' is a reserved word that should not be used.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/simpletest/tests/file.test | 26 | ||||
-rw-r--r-- | modules/system/system.api.php | 2 | ||||
-rw-r--r-- | modules/system/system.install | 23 | ||||
-rw-r--r-- | modules/system/system.module | 4 | ||||
-rw-r--r-- | modules/system/system.test | 6 | ||||
-rw-r--r-- | modules/user/user.install | 11 |
6 files changed, 40 insertions, 32 deletions
diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test index cf7c8f1ca..abd1c2cbf 100644 --- a/modules/simpletest/tests/file.test +++ b/modules/simpletest/tests/file.test @@ -194,7 +194,7 @@ class FileTestCase extends DrupalWebTestCase { $file->status = 0; // Write the record directly rather than calling file_save() so we don't // invoke the hooks. - $this->assertNotIdentical(drupal_write_record('file', $file), FALSE, t('The file was added to the database.'), 'Create test file'); + $this->assertNotIdentical(drupal_write_record('file_managed', $file), FALSE, t('The file was added to the database.'), 'Create test file'); return $file; } @@ -289,21 +289,21 @@ class FileSpaceUsedTest extends FileTestCase { // Create records for a couple of users with different sizes. $file = array('uid' => 2, 'uri' => 'public://example1.txt', 'filesize' => 50, 'status' => FILE_STATUS_PERMANENT); - drupal_write_record('file', $file); + drupal_write_record('file_managed', $file); $file = array('uid' => 2, 'uri' => 'public://example2.txt', 'filesize' => 20, 'status' => FILE_STATUS_PERMANENT); - drupal_write_record('file', $file); + drupal_write_record('file_managed', $file); $file = array('uid' => 3, 'uri' => 'public://example3.txt', 'filesize' => 100, 'status' => FILE_STATUS_PERMANENT); - drupal_write_record('file', $file); + drupal_write_record('file_managed', $file); $file = array('uid' => 3, 'uri' => 'public://example4.txt', 'filesize' => 200, 'status' => FILE_STATUS_PERMANENT); - drupal_write_record('file', $file); + drupal_write_record('file_managed', $file); // Now create some with other statuses. These values were chosen arbitrarily // for the sole purpose of testing that bitwise operators were used // correctly on the field. $file = array('uid' => 2, 'uri' => 'public://example5.txt', 'filesize' => 1, 'status' => 2 | 8); - drupal_write_record('file', $file); + drupal_write_record('file_managed', $file); $file = array('uid' => 3, 'uri' => 'public://example6.txt', 'filesize' => 3, 'status' => 2 | 4); - drupal_write_record('file', $file); + drupal_write_record('file_managed', $file); } /** @@ -560,7 +560,7 @@ class FileSaveUploadTest extends FileHookTestCase { $this->image = current($this->drupalGetTestFiles('image')); $this->assertTrue(is_file($this->image->uri), t("The file we're going to upload exists.")); - $this->maxFidBefore = db_query('SELECT MAX(fid) AS fid FROM {file}')->fetchField(); + $this->maxFidBefore = db_query('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField(); // Upload with replace to gurantee there's something there. $edit = array( @@ -581,7 +581,7 @@ class FileSaveUploadTest extends FileHookTestCase { * Test the file_save_upload() function. */ function testNormal() { - $max_fid_after = db_query('SELECT MAX(fid) AS fid FROM {file}')->fetchField(); + $max_fid_after = db_query('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField(); $this->assertTrue($max_fid_after > $this->maxFidBefore, t('A new file was created.')); $file1 = file_load($max_fid_after); $this->assertTrue($file1, t('Loaded the file.')); @@ -592,13 +592,13 @@ class FileSaveUploadTest extends FileHookTestCase { file_test_reset(); // Upload a second file. - $max_fid_before = db_query('SELECT MAX(fid) AS fid FROM {file}')->fetchField(); + $max_fid_before = db_query('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField(); $image2 = current($this->drupalGetTestFiles('image')); $edit = array('files[file_test_upload]' => drupal_realpath($image2->uri)); $this->drupalPost('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, t('Received a 200 response for posted test file.')); $this->assertRaw(t('You WIN!')); - $max_fid_after = db_query('SELECT MAX(fid) AS fid FROM {file}')->fetchField(); + $max_fid_after = db_query('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField(); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('validate', 'insert')); @@ -1680,7 +1680,7 @@ class FileSaveTest extends FileHookTestCase { $this->assertNotNull($saved_file, t("Saving the file should give us back a file object."), 'File'); $this->assertTrue($saved_file->fid > 0, t("A new file ID is set when saving a new file to the database."), 'File'); - $loaded_file = db_query('SELECT * FROM {file} f WHERE f.fid = :fid', array(':fid' => $saved_file->fid))->fetch(PDO::FETCH_OBJ); + $loaded_file = db_query('SELECT * FROM {file_managed} f WHERE f.fid = :fid', array(':fid' => $saved_file->fid))->fetch(PDO::FETCH_OBJ); $this->assertNotNull($loaded_file, t("Record exists in the database.")); $this->assertEqual($loaded_file->status, $file->status, t("Status was saved correctly.")); $this->assertEqual($saved_file->filesize, filesize($file->uri), t("File size was set correctly."), 'File'); @@ -1697,7 +1697,7 @@ class FileSaveTest extends FileHookTestCase { $this->assertEqual($resaved_file->fid, $saved_file->fid, t("The file ID of an existing file is not changed when updating the database."), 'File'); $this->assertTrue($resaved_file->timestamp >= $saved_file->timestamp, t("Timestamp didn't go backwards."), 'File'); - $loaded_file = db_query('SELECT * FROM {file} f WHERE f.fid = :fid', array(':fid' => $saved_file->fid))->fetch(PDO::FETCH_OBJ); + $loaded_file = db_query('SELECT * FROM {file_managed} f WHERE f.fid = :fid', array(':fid' => $saved_file->fid))->fetch(PDO::FETCH_OBJ); $this->assertNotNull($loaded_file, t("Record still exists in the database."), 'File'); $this->assertEqual($loaded_file->status, $saved_file->status, t("Status was saved correctly.")); } diff --git a/modules/system/system.api.php b/modules/system/system.api.php index b188e871b..fff543ad4 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -1783,7 +1783,7 @@ function hook_file_download($uri) { if (!file_prepare_directory($uri)) { $uri = FALSE; } - $result = db_query("SELECT f.* FROM {file} f INNER JOIN {upload} u ON f.fid = u.fid WHERE uri = :uri", array('uri' => $uri)); + $result = db_query("SELECT f.* FROM {file_managed} f INNER JOIN {upload} u ON f.fid = u.fid WHERE uri = :uri", array('uri' => $uri)); foreach ($result as $file) { if (!user_access('view uploaded files')) { return -1; diff --git a/modules/system/system.install b/modules/system/system.install index 48db779e9..a442b2f6a 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -692,7 +692,7 @@ function system_schema() { 'primary key' => array('type', 'language'), ); - $schema['file'] = array( + $schema['file_managed'] = array( 'description' => 'Stores information for uploaded files.', 'fields' => array( 'fid' => array( @@ -983,10 +983,10 @@ function system_schema() { 'not null' => TRUE, 'default' => 0, ), - 'file' => array( + 'include_file' => array( 'description' => 'The file to include for this element, usually the page callback function lives in this file.', 'type' => 'text', - 'size' => 'medium' + 'size' => 'medium', ), ), 'indexes' => array( @@ -2094,7 +2094,7 @@ function system_update_7033() { } /** - * Migrate the file_downloads setting and create the new {file} table. + * Migrate the file_downloads setting and create the new {file_managed} table. */ function system_update_7034() { $files_directory = variable_get('file_directory_path', NULL); @@ -2112,7 +2112,7 @@ function system_update_7034() { } variable_del('file_downloads'); - $schema['file'] = array( + $schema['file_managed'] = array( 'description' => 'Stores information for uploaded files.', 'fields' => array( 'fid' => array( @@ -2181,11 +2181,11 @@ function system_update_7034() { 'primary key' => array('fid'), ); - db_create_table('file', $schema['file']); + db_create_table('file_managed', $schema['file_managed']); } /** - * Migrate upload module files to the new {file} table. + * Migrate upload module files to the new {file_managed} table. */ function system_update_7035() { if (!db_table_exists('upload')) { @@ -2205,7 +2205,7 @@ function system_update_7035() { foreach ($result as $file) { $file['uri'] = $scheme . str_replace($basename, '', $file['uri']); $file['uri'] = file_stream_wrapper_uri_normalize($file['uri']); - db_insert('file')->fields($file)->execute(); + db_insert('file_managed')->fields($file)->execute(); $fids[] = $file['fid']; } // TODO: delete the found fids from {files}? @@ -2391,6 +2391,13 @@ function system_update_7051() { } /** + * Rename file to include_file in {menu_router} table. + */ +function system_update_7052() { + db_change_field('menu_router', 'file', 'include_file', array('type' => 'text', 'size' => 'medium')); +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ diff --git a/modules/system/system.module b/modules/system/system.module index f2f06bfe7..6badde7c2 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -260,7 +260,7 @@ function system_entity_info() { return array( 'file' => array( 'label' => t('File'), - 'base table' => 'file', + 'base table' => 'file_managed', 'entity keys' => array( 'id' => 'fid', ), @@ -2782,7 +2782,7 @@ function system_cron() { // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE. // Use separate placeholders for the status to avoid a bug in some versions // of PHP. See http://drupal.org/node/352956. - $result = db_query('SELECT fid FROM {file} WHERE status & :permanent1 <> :permanent2 AND timestamp < :timestamp', array( + $result = db_query('SELECT fid FROM {file_managed} WHERE status & :permanent1 <> :permanent2 AND timestamp < :timestamp', array( ':permanent1' => FILE_STATUS_PERMANENT, ':permanent2' => FILE_STATUS_PERMANENT, ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE diff --git a/modules/system/system.test b/modules/system/system.test index a18112230..dd7b44699 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -469,7 +469,7 @@ class CronRunTestCase extends DrupalWebTestCase { function testTempFileCleanup() { // Temporary file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE. $temp_old = file_save_data(''); - db_update('file') + db_update('file_managed') ->fields(array( 'status' => 0, 'timestamp' => 1, @@ -480,7 +480,7 @@ class CronRunTestCase extends DrupalWebTestCase { // Temporary file that is less than DRUPAL_MAXIMUM_TEMP_FILE_AGE. $temp_new = file_save_data(''); - db_update('file') + db_update('file_managed') ->fields(array('status' => 0)) ->condition('fid', $temp_new->fid) ->execute(); @@ -488,7 +488,7 @@ class CronRunTestCase extends DrupalWebTestCase { // Permanent file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE. $perm_old = file_save_data(''); - db_update('file') + db_update('file_managed') ->fields(array('timestamp' => 1)) ->condition('fid', $temp_old->fid) ->execute(); diff --git a/modules/user/user.install b/modules/user/user.install index 69f80af6a..6af67b9b1 100644 --- a/modules/user/user.install +++ b/modules/user/user.install @@ -201,7 +201,7 @@ function user_schema() { 'type' => 'int', 'not null' => TRUE, 'default' => 0, - 'description' => "Foreign key: {file}.fid of user's picture.", + 'description' => "Foreign key: {file_managed}.fid of user's picture.", ), 'init' => array( 'type' => 'varchar', @@ -473,7 +473,8 @@ function user_update_7003() { } /** - * Add the user's pictures to the {file} table and make them managed files. + * Add the user's pictures to the {file_managed} table and make them managed + * files. */ function user_update_7004(&$sandbox) { @@ -481,7 +482,7 @@ function user_update_7004(&$sandbox) { 'type' => 'int', 'not null' => TRUE, 'default' => 0, - 'description' => t("Foreign key: {file}.fid of user's picture."), + 'description' => t("Foreign key: {file_managed}.fid of user's picture."), ); if (!isset($sandbox['progress'])) { @@ -498,8 +499,8 @@ function user_update_7004(&$sandbox) { $sandbox['max'] = db_query("SELECT COUNT(*) FROM {users} WHERE picture <> ''")->fetchField(); } - // As a batch operation move the photos into the {file} table and update the - // {users} records. + // As a batch operation move the photos into the {file_managed} table and + // update the {users} records. $limit = 500; $result = db_query_range("SELECT uid, picture FROM {users} WHERE picture <> '' AND uid > :uid ORDER BY uid", 0, $limit, array(':uid' => $sandbox['last_user_processed'])); foreach ($result as $user) { |