diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-09-04 15:40:52 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-09-04 15:40:52 +0000 |
commit | 9502260ecf33a4b345794eea2d0b6e6dff5dbd74 (patch) | |
tree | 26612164dfc6fef6089a6774df81e6dc3157887d /modules | |
parent | 47326c49cbac1765a804c7c2166244148dc52401 (diff) | |
download | brdo-9502260ecf33a4b345794eea2d0b6e6dff5dbd74.tar.gz brdo-9502260ecf33a4b345794eea2d0b6e6dff5dbd74.tar.bz2 |
- Patch #902264 by Damien Tournoud: move hook_field_schema() to .install files so we can get the upgrade path to work.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/field/field.api.php | 3 | ||||
-rw-r--r-- | modules/field/field.crud.inc | 3 | ||||
-rw-r--r-- | modules/field/modules/list/list.install | 46 | ||||
-rw-r--r-- | modules/field/modules/list/list.module | 39 | ||||
-rw-r--r-- | modules/field/modules/number/number.install | 46 | ||||
-rw-r--r-- | modules/field/modules/number/number.module | 39 | ||||
-rw-r--r-- | modules/field/modules/text/text.install | 60 | ||||
-rw-r--r-- | modules/field/modules/text/text.module | 53 | ||||
-rw-r--r-- | modules/field/tests/field_test.field.inc | 36 | ||||
-rw-r--r-- | modules/field/tests/field_test.install | 36 | ||||
-rw-r--r-- | modules/file/file.field.inc | 32 | ||||
-rw-r--r-- | modules/file/file.install | 32 | ||||
-rw-r--r-- | modules/image/image.field.inc | 31 | ||||
-rw-r--r-- | modules/image/image.install | 31 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.install | 18 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 18 |
16 files changed, 275 insertions, 248 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php index a3d8bdbf4..9b2d3bb4f 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -211,6 +211,9 @@ function hook_field_info_alter(&$info) { /** * Define the Field API schema for a field structure. * + * This hook MUST be defined in .install for it to be detected during + * installation and upgrade. + * * @param $field * A field structure. * diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc index e7fa00146..96e44bf0e 100644 --- a/modules/field/field.crud.inc +++ b/modules/field/field.crud.inc @@ -317,6 +317,7 @@ function field_create_field($field) { $field['storage']['module'] = $storage_type['module']; $field['storage']['active'] = 1; // Collect storage information. + module_load_install($field['module']); $schema = (array) module_invoke($field['module'], 'field_schema', $field); $schema += array('columns' => array(), 'indexes' => array()); // 'columns' are hardcoded in the field type. @@ -426,6 +427,7 @@ function field_update_field($field) { // Collect the new storage information, since what is in // $prior_field may no longer be right. + module_load_install($field['module']); $schema = (array) module_invoke($field['module'], 'field_schema', $field); $schema += array('columns' => array(), 'indexes' => array()); // 'columns' are hardcoded in the field type. @@ -552,6 +554,7 @@ function field_read_fields($params = array(), $include_additional = array()) { module_invoke_all('field_read_field', $field); // Populate storage information. + module_load_install($field['module']); $schema = (array) module_invoke($field['module'], 'field_schema', $field); $schema += array('columns' => array(), 'indexes' => array()); $field['columns'] = $schema['columns']; diff --git a/modules/field/modules/list/list.install b/modules/field/modules/list/list.install new file mode 100644 index 000000000..38bab8e7d --- /dev/null +++ b/modules/field/modules/list/list.install @@ -0,0 +1,46 @@ +<?php +// $Id$ + +/** + * @file + * Install, update and uninstall functions for the list module. + */ + +/** + * Implements hook_field_schema(). + */ +function list_field_schema($field) { + switch ($field['type']) { + case 'list_text': + $columns = array( + 'value' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ); + break; + case 'list_number': + $columns = array( + 'value' => array( + 'type' => 'float', + 'not null' => FALSE, + ), + ); + break; + default: + $columns = array( + 'value' => array( + 'type' => 'int', + 'not null' => FALSE, + ), + ); + break; + } + return array( + 'columns' => $columns, + 'indexes' => array( + 'value' => array('value'), + ), + ); +}
\ No newline at end of file diff --git a/modules/field/modules/list/list.module b/modules/field/modules/list/list.module index 8aa3489a2..bbf6bd9ff 100644 --- a/modules/field/modules/list/list.module +++ b/modules/field/modules/list/list.module @@ -56,45 +56,6 @@ function list_field_info() { } /** - * Implements hook_field_schema(). - */ -function list_field_schema($field) { - switch ($field['type']) { - case 'list_text': - $columns = array( - 'value' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - ), - ); - break; - case 'list_number': - $columns = array( - 'value' => array( - 'type' => 'float', - 'not null' => FALSE, - ), - ); - break; - default: - $columns = array( - 'value' => array( - 'type' => 'int', - 'not null' => FALSE, - ), - ); - break; - } - return array( - 'columns' => $columns, - 'indexes' => array( - 'value' => array('value'), - ), - ); -} - -/** * Implements hook_field_settings_form(). * * @todo: If $has_data, add a form validate function to verify that the diff --git a/modules/field/modules/number/number.install b/modules/field/modules/number/number.install new file mode 100644 index 000000000..d5e6b1cf2 --- /dev/null +++ b/modules/field/modules/number/number.install @@ -0,0 +1,46 @@ +<?php +// $Id$ + +/** + * @file + * Install, update and uninstall functions for the number module. + */ + +/** + * Implements hook_field_schema(). + */ +function number_field_schema($field) { + switch ($field['type']) { + case 'number_integer' : + $columns = array( + 'value' => array( + 'type' => 'int', + 'not null' => FALSE + ), + ); + break; + + case 'number_float' : + $columns = array( + 'value' => array( + 'type' => 'float', + 'not null' => FALSE + ), + ); + break; + + case 'number_decimal' : + $columns = array( + 'value' => array( + 'type' => 'numeric', + 'precision' => $field['settings']['precision'], + 'scale' => $field['settings']['scale'], + 'not null' => FALSE + ), + ); + break; + } + return array( + 'columns' => $columns, + ); +} diff --git a/modules/field/modules/number/number.module b/modules/field/modules/number/number.module index d9386eda7..cfc1b6d62 100644 --- a/modules/field/modules/number/number.module +++ b/modules/field/modules/number/number.module @@ -51,45 +51,6 @@ function number_field_info() { } /** - * Implements hook_field_schema(). - */ -function number_field_schema($field) { - switch ($field['type']) { - case 'number_integer' : - $columns = array( - 'value' => array( - 'type' => 'int', - 'not null' => FALSE - ), - ); - break; - - case 'number_float' : - $columns = array( - 'value' => array( - 'type' => 'float', - 'not null' => FALSE - ), - ); - break; - - case 'number_decimal' : - $columns = array( - 'value' => array( - 'type' => 'numeric', - 'precision' => $field['settings']['precision'], - 'scale' => $field['settings']['scale'], - 'not null' => FALSE - ), - ); - break; - } - return array( - 'columns' => $columns, - ); -} - -/** * Implements hook_field_settings_form(). */ function number_field_settings_form($field, $instance, $has_data) { diff --git a/modules/field/modules/text/text.install b/modules/field/modules/text/text.install new file mode 100644 index 000000000..c2c5b2ec7 --- /dev/null +++ b/modules/field/modules/text/text.install @@ -0,0 +1,60 @@ +<?php +// $Id$ + +/** + * @file + * Install, update and uninstall functions for the text module. + */ + +/** + * Implements hook_field_schema(). + */ +function text_field_schema($field) { + switch ($field['type']) { + case 'text': + $columns = array( + 'value' => array( + 'type' => 'varchar', + 'length' => $field['settings']['max_length'], + 'not null' => FALSE, + ), + ); + break; + case 'text_long': + $columns = array( + 'value' => array( + 'type' => 'text', + 'size' => 'big', + 'not null' => FALSE, + ), + ); + break; + case 'text_with_summary': + $columns = array( + 'value' => array( + 'type' => 'text', + 'size' => 'big', + 'not null' => FALSE, + ), + 'summary' => array( + 'type' => 'text', + 'size' => 'big', + 'not null' => FALSE, + ), + ); + break; + } + $columns += array( + 'format' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE, + ), + ); + return array( + 'columns' => $columns, + 'indexes' => array( + 'format' => array('format'), + ), + ); +} diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module index 600081c1b..45ace5ee2 100644 --- a/modules/field/modules/text/text.module +++ b/modules/field/modules/text/text.module @@ -58,59 +58,6 @@ function text_field_info() { } /** - * Implements hook_field_schema(). - */ -function text_field_schema($field) { - switch ($field['type']) { - case 'text': - $columns = array( - 'value' => array( - 'type' => 'varchar', - 'length' => $field['settings']['max_length'], - 'not null' => FALSE, - ), - ); - break; - case 'text_long': - $columns = array( - 'value' => array( - 'type' => 'text', - 'size' => 'big', - 'not null' => FALSE, - ), - ); - break; - case 'text_with_summary': - $columns = array( - 'value' => array( - 'type' => 'text', - 'size' => 'big', - 'not null' => FALSE, - ), - 'summary' => array( - 'type' => 'text', - 'size' => 'big', - 'not null' => FALSE, - ), - ); - break; - } - $columns += array( - 'format' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => FALSE, - ), - ); - return array( - 'columns' => $columns, - 'indexes' => array( - 'format' => array('format'), - ), - ); -} - -/** * Implements hook_field_settings_form(). */ function text_field_settings_form($field, $instance, $has_data) { diff --git a/modules/field/tests/field_test.field.inc b/modules/field/tests/field_test.field.inc index 6bb8dd87b..603eadd6a 100644 --- a/modules/field/tests/field_test.field.inc +++ b/modules/field/tests/field_test.field.inc @@ -47,42 +47,6 @@ function field_test_field_info() { } /** - * Implements hook_field_schema(). - */ -function field_test_field_schema($field) { - if ($field['type'] == 'test_field') { - return array( - 'columns' => array( - 'value' => array( - 'type' => 'int', - 'size' => 'medium', - 'not null' => FALSE, - ), - ), - 'indexes' => array( - 'value' => array('value'), - ), - ); - } - else { - return array( - 'columns' => array( - 'shape' => array( - 'type' => 'varchar', - 'length' => 32, - 'not null' => FALSE, - ), - 'color' => array( - 'type' => 'varchar', - 'length' => 32, - 'not null' => FALSE, - ), - ), - ); - } -} - -/** * Implements hook_field_update_forbid(). */ function field_test_field_update_forbid($field, $prior_field, $has_data) { diff --git a/modules/field/tests/field_test.install b/modules/field/tests/field_test.install index d16d79ee8..d4937b620 100644 --- a/modules/field/tests/field_test.install +++ b/modules/field/tests/field_test.install @@ -106,3 +106,39 @@ function field_test_schema() { return $schema; } + +/** + * Implements hook_field_schema(). + */ +function field_test_field_schema($field) { + if ($field['type'] == 'test_field') { + return array( + 'columns' => array( + 'value' => array( + 'type' => 'int', + 'size' => 'medium', + 'not null' => FALSE, + ), + ), + 'indexes' => array( + 'value' => array('value'), + ), + ); + } + else { + return array( + 'columns' => array( + 'shape' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + 'color' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + ), + ); + } +} diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc index 38a24bde3..5ac4cfed3 100644 --- a/modules/file/file.field.inc +++ b/modules/file/file.field.inc @@ -32,38 +32,6 @@ function file_field_info() { } /** - * Implements hook_field_schema(). - */ -function file_field_schema($field) { - return array( - 'columns' => array( - 'fid' => array( - 'description' => 'The {files}.fid being referenced in this field.', - 'type' => 'int', - 'not null' => FALSE, - 'unsigned' => TRUE, - ), - 'display' => array( - 'description' => 'Flag to control whether this file should be displayed when viewing content.', - 'type' => 'int', - 'size' => 'tiny', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 1, - ), - 'description' => array( - 'description' => 'A description of the file.', - 'type' => 'text', - 'not null' => FALSE, - ), - ), - 'indexes' => array( - 'fid' => array('fid'), - ), - ); -} - -/** * Implements hook_field_settings_form(). */ function file_field_settings_form($field, $instance, $has_data) { diff --git a/modules/file/file.install b/modules/file/file.install index c92068e98..fdf908805 100644 --- a/modules/file/file.install +++ b/modules/file/file.install @@ -7,6 +7,38 @@ */ /** + * Implements hook_field_schema(). + */ +function file_field_schema($field) { + return array( + 'columns' => array( + 'fid' => array( + 'description' => 'The {files}.fid being referenced in this field.', + 'type' => 'int', + 'not null' => FALSE, + 'unsigned' => TRUE, + ), + 'display' => array( + 'description' => 'Flag to control whether this file should be displayed when viewing content.', + 'type' => 'int', + 'size' => 'tiny', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 1, + ), + 'description' => array( + 'description' => 'A description of the file.', + 'type' => 'text', + 'not null' => FALSE, + ), + ), + 'indexes' => array( + 'fid' => array('fid'), + ), + ); +} + +/** * Implements hook_requirements(). * * Display information about getting upload progress bars working. diff --git a/modules/image/image.field.inc b/modules/image/image.field.inc index d8a1788ca..106e68e26 100644 --- a/modules/image/image.field.inc +++ b/modules/image/image.field.inc @@ -34,37 +34,6 @@ function image_field_info() { } /** - * Implements hook_field_schema(). - */ -function image_field_schema($field) { - return array( - 'columns' => array( - 'fid' => array( - 'description' => 'The {files}.fid being referenced in this field.', - 'type' => 'int', - 'not null' => FALSE, - 'unsigned' => TRUE, - ), - 'alt' => array( - 'description' => "Alternative image text, for the image's 'alt' attribute.", - 'type' => 'varchar', - 'length' => 128, - 'not null' => FALSE, - ), - 'title' => array( - 'description' => "Image title text, for the image's 'title' attribute.", - 'type' => 'varchar', - 'length' => 128, - 'not null' => FALSE, - ), - ), - 'indexes' => array( - 'fid' => array('fid'), - ), - ); -} - -/** * Implements hook_field_settings_form(). */ function image_field_settings_form($field, $instance) { diff --git a/modules/image/image.install b/modules/image/image.install index 40c0e9ddf..3ebf6eef5 100644 --- a/modules/image/image.install +++ b/modules/image/image.install @@ -108,6 +108,37 @@ function image_schema() { } /** + * Implements hook_field_schema(). + */ +function image_field_schema($field) { + return array( + 'columns' => array( + 'fid' => array( + 'description' => 'The {files}.fid being referenced in this field.', + 'type' => 'int', + 'not null' => FALSE, + 'unsigned' => TRUE, + ), + 'alt' => array( + 'description' => "Alternative image text, for the image's 'alt' attribute.", + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'title' => array( + 'description' => "Image title text, for the image's 'title' attribute.", + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + ), + 'indexes' => array( + 'fid' => array('fid'), + ), + ); +} + +/** * Install the schema for users upgrading from the contributed module. */ function image_update_7000() { diff --git a/modules/taxonomy/taxonomy.install b/modules/taxonomy/taxonomy.install index cc2512206..86171b77d 100644 --- a/modules/taxonomy/taxonomy.install +++ b/modules/taxonomy/taxonomy.install @@ -222,6 +222,24 @@ function taxonomy_schema() { } /** + * Implements hook_field_schema(). + */ +function taxonomy_field_schema($field) { + return array( + 'columns' => array( + 'tid' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE, + ), + ), + 'indexes' => array( + 'tid' => array('tid'), + ), + ); +} + +/** * Implements hook_update_dependencies(). */ function taxonomy_update_dependencies() { diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index cb1f25592..45ae7c091 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -1118,24 +1118,6 @@ function taxonomy_options_list($field) { } /** - * Implements hook_field_schema(). - */ -function taxonomy_field_schema($field) { - return array( - 'columns' => array( - 'tid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => FALSE, - ), - ), - 'indexes' => array( - 'tid' => array('tid'), - ), - ); -} - -/** * Implements hook_field_validate(). * * Taxonomy field settings allow for either a single vocabulary ID, multiple |