Index: modules/block/block.install =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.install,v retrieving revision 1.46 diff -u -p -r1.46 block.install --- modules/block/block.install 28 Sep 2010 03:30:37 -0000 1.46 +++ modules/block/block.install 9 Oct 2010 17:01:19 -0000 @@ -155,8 +155,8 @@ function block_schema() { 'description' => 'Block description.', ), 'format' => array( - 'type' => 'int', - 'unsigned' => TRUE, + 'type' => 'varchar', + 'length' => 255, 'not null' => FALSE, 'description' => 'The {filter_format}.format of the block body.', ), @@ -196,6 +196,11 @@ function block_update_dependencies() { $dependencies['block'][7005] = array( 'filter' => 7000, ); + // Ensure that format columns are only changed after Filter module has changed + // the primary records. + $dependencies['block'][7007] = array( + 'filter' => 7010, + ); return $dependencies; } @@ -445,6 +450,18 @@ function block_update_7006() { } /** + * Change {block_custom}.format into varchar. + */ +function block_update_7007() { + db_change_field('block_custom', 'format', 'format', array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + 'description' => 'The {filter_format}.format of the block body.', + )); +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ Index: modules/field/field.crud.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.crud.inc,v retrieving revision 1.71 diff -u -p -r1.71 field.crud.inc --- modules/field/field.crud.inc 29 Sep 2010 01:37:02 -0000 1.71 +++ modules/field/field.crud.inc 9 Oct 2010 23:36:19 -0000 @@ -465,12 +465,19 @@ function field_update_field($field) { // The serialized 'data' column contains everything from $field that does not // have its own column and is not automatically populated when the field is // read. - $data = $field; - unset($data['columns'], $data['field_name'], $data['type'], $data['locked'], $data['module'], $data['cardinality'], $data['active'], $data['deleted']); - // Additionally, do not save the 'bundles' property populated by - // field_info_field(). - unset($data['bundles']); - + $keys = array( + // Ignore {field_config} columns. + 'id', 'field_name', 'type', 'module', 'active', 'storage_type', + 'storage_module', 'storage_active', 'locked', 'cardinality', + 'translatable', 'deleted', + // Ignore the data column itself. + 'data', + // Ignore schema properties. + 'columns', 'primary key', 'unique keys', 'indexes', 'foreign keys', + // Ignore field_info_field() properties. + 'bundles', + ); + $data = array_diff_key($field, array_flip($keys)); $field['data'] = $data; // Store the field and create the id. Index: modules/field/field.install =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.install,v retrieving revision 1.22 diff -u -p -r1.22 field.install --- modules/field/field.install 29 Sep 2010 19:46:40 -0000 1.22 +++ modules/field/field.install 9 Oct 2010 23:42:45 -0000 @@ -309,11 +309,21 @@ function _update_7000_field_delete_insta /** * Utility function: fetch all the field definitions from the database. + * + * @param $conditions + * An array of conditions to limit the select query to. */ -function _update_7000_field_read_fields() { +function _update_7000_field_read_fields(array $conditions = array()) { $fields = array(); - $results = db_query('SELECT * FROM {field_config} WHERE deleted = 0', array(), array('fetch' => PDO::FETCH_ASSOC)); - foreach ($results as $record) { + $query = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC)) + ->fields('fc') + ->condition('deleted', 0); + if (!empty($conditions)) { + foreach ($conditions as $column => $value) { + $query->condition($column, $value); + } + } + foreach ($query->execute() as $record) { $field = unserialize($record['data']); $field['id'] = $record['id']; $field['field_name'] = $record['field_name']; @@ -334,6 +344,81 @@ function _update_7000_field_read_fields( } /** + * Utility function: Update a field. + * + * @param $prior_field + * A field structure containing the previous field schema definition. + * @param $field + * A field structure containing the new field schema definition. + * + * @return + * Throws a FieldException if the update cannot be performed. + * + * @see field_update_field() + */ +function _update_7000_field_update_field($prior_field, $field) { + // Use the prior field values for anything not specifically set by the new + // field to be sure that all values are set. + $field += $prior_field; + $field['settings'] += $prior_field['settings']; + + // Some updates are always disallowed. + if ($field['storage']['type'] != $prior_field['storage']['type']) { + throw new FieldException("Cannot change an existing field's storage type."); + } + + $has_data = field_has_data($field); + + // See if any module forbids the update by throwing an exception. + foreach (module_implements('field_update_forbid') as $module) { + $function = $module . '_field_update_forbid'; + $function($field, $prior_field, $has_data); + } + + // Tell the storage engine to update the field. Do this before + // saving the new definition since it still might fail. + $storage_type = field_info_storage_types($field['storage']['type']); + module_invoke($storage_type['module'], 'field_storage_update_field', $field, $prior_field, $has_data); + + // Save the new field definition. + // The serialized 'data' column contains everything from $field that does not + // have its own column and is not automatically populated when the field is + // read. + $keys = array( + // Ignore {field_config} columns. + 'id', 'field_name', 'type', 'module', 'active', 'storage_type', + 'storage_module', 'storage_active', 'locked', 'cardinality', + 'translatable', 'deleted', + // Ignore the data column itself. + 'data', + // Ignore schema properties. + 'columns', 'primary key', 'unique keys', 'indexes', 'foreign keys', + // Ignore field_info_field() properties. + 'bundles', + ); + $data = array_diff_key($field, array_flip($keys)); + $field['data'] = $data; + + // Store the field and create the id. + db_update('field_config') + ->fields(array( + 'field_name' => $field['field_name'], + 'type' => $field['type'], + 'module' => $field['module'], + 'active' => $field['active'], + 'storage_type' => $field['storage_type'], + 'storage_module' => $field['storage_module'], + 'storage_active' => $field['storage_active'], + 'locked' => $field['locked'], + 'cardinality' => $field['cardinality'], + 'translatable' => $field['translatable'], + 'data' => serialize($field['data']), + )) + ->condition('id', $field['id']) + ->execute(); +} + +/** * Utility function: write a field instance directly to the database. * * This function can be used for databases whose schema is at field module Index: modules/field/modules/field_sql_storage/field_sql_storage.module =================================================================== RCS file: /cvs/drupal/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module,v retrieving revision 1.56 diff -u -p -r1.56 field_sql_storage.module --- modules/field/modules/field_sql_storage/field_sql_storage.module 6 Oct 2010 13:57:47 -0000 1.56 +++ modules/field/modules/field_sql_storage/field_sql_storage.module 9 Oct 2010 23:52:45 -0000 @@ -240,18 +240,6 @@ function field_sql_storage_field_storage } /** - * Implements hook_field_update_forbid(). - * - * Forbid any field update that changes column definitions if there is - * any data. - */ -function field_sql_storage_field_update_forbid($field, $prior_field, $has_data) { - if ($has_data && $field['columns'] != $prior_field['columns']) { - throw new FieldUpdateForbiddenException("field_sql_storage cannot change the schema for an existing field with data."); - } -} - -/** * Implements hook_field_storage_update_field(). */ function field_sql_storage_field_storage_update_field($field, $prior_field, $has_data) { @@ -267,29 +255,61 @@ function field_sql_storage_field_storage } } else { - // There is data, so there are no column changes. Drop all the - // prior indexes and create all the new ones, except for all the - // priors that exist unchanged. - $table = _field_sql_storage_tablename($prior_field); - $revision_table = _field_sql_storage_revision_tablename($prior_field); - foreach ($prior_field['indexes'] as $name => $columns) { - if (!isset($field['indexes'][$name]) || $columns != $field['indexes'][$name]) { - $real_name = _field_sql_storage_indexname($field['field_name'], $name); - db_drop_index($table, $real_name); - db_drop_index($revision_table, $real_name); - } - } + // There is data. $table = _field_sql_storage_tablename($field); $revision_table = _field_sql_storage_revision_tablename($field); - foreach ($field['indexes'] as $name => $columns) { - if (!isset($prior_field['indexes'][$name]) || $columns != $prior_field['indexes'][$name]) { - $real_name = _field_sql_storage_indexname($field['field_name'], $name); - $real_columns = array(); - foreach ($columns as $column_name) { - $real_columns[] = _field_sql_storage_columnname($field['field_name'], $column_name); + + // Drop prior indexes, except for all unchanged. + if (isset($prior_field['indexes'])) { + foreach ($prior_field['indexes'] as $name => $columns) { + if (!isset($field['indexes'][$name]) || $columns != $field['indexes'][$name]) { + $real_name = _field_sql_storage_indexname($field['field_name'], $name); + db_drop_index($table, $real_name); + db_drop_index($revision_table, $real_name); + } + } + } + + // Perform field schema column updates, if any. + if (isset($prior_field['columns'])) { + foreach ($prior_field['columns'] as $name => $spec) { + // Remove a field column. + if (!isset($field['columns'][$name])) { + $real_name = _field_sql_storage_columnname($field['field_name'], $name); + db_drop_field($table, $real_name); + db_drop_field($revision_table, $real_name); + } + } + } + if (isset($field['columns'])) { + foreach ($field['columns'] as $name => $spec) { + // Add a field column. + if (!isset($prior_field['columns'][$name])) { + $real_name = _field_sql_storage_columnname($field['field_name'], $name); + db_add_field($table, $real_name, $spec); + db_add_field($revision_table, $real_name, $spec); + } + // Change a field column. + if ($prior_field['columns'][$name] != $spec) { + $real_name = _field_sql_storage_columnname($field['field_name'], $name); + db_change_field($table, $real_name, $real_name, $spec); + db_change_field($revision_table, $real_name, $real_name, $spec); + } + } + } + + // Create new indexes, except for all unchanged. + if (isset($field['indexes'])) { + foreach ($field['indexes'] as $name => $columns) { + if (!isset($prior_field['indexes'][$name]) || $columns != $prior_field['indexes'][$name]) { + $real_name = _field_sql_storage_indexname($field['field_name'], $name); + $real_columns = array(); + foreach ($columns as $column_name) { + $real_columns[] = _field_sql_storage_columnname($field['field_name'], $column_name); + } + db_add_index($table, $real_name, $real_columns); + db_add_index($revision_table, $real_name, $real_columns); } - db_add_index($table, $real_name, $real_columns); - db_add_index($revision_table, $real_name, $real_columns); } } } Index: modules/field/modules/field_sql_storage/field_sql_storage.test =================================================================== RCS file: /cvs/drupal/drupal/modules/field/modules/field_sql_storage/field_sql_storage.test,v retrieving revision 1.22 diff -u -p -r1.22 field_sql_storage.test --- modules/field/modules/field_sql_storage/field_sql_storage.test 29 Sep 2010 01:37:02 -0000 1.22 +++ modules/field/modules/field_sql_storage/field_sql_storage.test 9 Oct 2010 23:48:58 -0000 @@ -13,6 +13,8 @@ * Tests field storage. */ class FieldSqlStorageTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; + public static function getInfo() { return array( 'name' => 'Field SQL storage tests', @@ -299,25 +301,33 @@ class FieldSqlStorageTestCase extends Dr /** * Test trying to update a field with data. */ - function testUpdateFieldSchemaWithData() { + function testFieldSchemaUpdateWithData() { // Create a decimal 5.2 field and add some data. - $field = array('field_name' => 'decimal52', 'type' => 'number_decimal', 'settings' => array('precision' => 5, 'scale' => 2)); + $field_name = 'decimal52'; + $field = array( + 'field_name' => $field_name, + 'type' => 'number_decimal', + 'settings' => array( + 'precision' => 5, + 'scale' => 2, + )); $field = field_create_field($field); $instance = array('field_name' => 'decimal52', 'entity_type' => 'test_entity', 'bundle' => 'test_bundle'); $instance = field_create_instance($instance); $entity = field_test_create_stub_entity(0, 0, $instance['bundle']); - $entity->decimal52[LANGUAGE_NONE][0]['value'] = '1.235'; - field_attach_insert('test_entity', $entity); + $entity->decimal52[LANGUAGE_NONE][0]['value'] = '1.12345'; + field_test_entity_save($entity); - // Attempt to update the field in a way that would work without data. - $field['settings']['scale'] = 3; - try { - field_update_field($field); - $this->fail(t('Cannot update field schema with data.')); - } - catch (FieldException $e) { - $this->pass(t('Cannot update field schema with data.')); - } + $entity = field_test_entity_test_load($entity->ftid); + $this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], '1.12'); + + // Update the field schema. + $field['settings']['precision'] = 2; + $field['settings']['scale'] = 1; + field_update_field($field); + + $entity = field_test_entity_test_load($entity->ftid); + $this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], '1.1'); } /** Index: modules/field/modules/text/text.install =================================================================== RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.install,v retrieving revision 1.2 diff -u -p -r1.2 text.install --- modules/field/modules/text/text.install 29 Sep 2010 01:37:02 -0000 1.2 +++ modules/field/modules/text/text.install 9 Oct 2010 23:14:17 -0000 @@ -48,8 +48,8 @@ function text_field_schema($field) { } $columns += array( 'format' => array( - 'type' => 'int', - 'unsigned' => TRUE, + 'type' => 'varchar', + 'length' => 255, 'not null' => FALSE, ), ); @@ -66,3 +66,39 @@ function text_field_schema($field) { ), ); } + +/** + * Implements hook_update_dependencies(). + */ +function text_update_dependencies() { + // Ensure that format columns are only changed after Filter module has changed + // the primary records. + $dependencies['text'][7000] = array( + 'filter' => 7010, + ); + + return $dependencies; +} + +/** + * Change text field 'format' columns into varchar. + */ +function text_update_7000() { + $fields = _update_7000_field_read_fields(array('module' => 'text')); + foreach ($fields as $field_name => $field) { + $field_schema = text_field_schema($field); + + $prior_field_schema = $field_schema; + $prior_field_schema['columns']['format'] = array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE, + ); + + $prior_field = $prior_field_schema + $field; + $field = $field_schema + $field; + + _update_7000_field_update_field($prior_field, $field); + } +} + Index: modules/field/modules/text/text.test =================================================================== RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.test,v retrieving revision 1.29 diff -u -p -r1.29 text.test --- modules/field/modules/text/text.test 24 Sep 2010 00:37:42 -0000 1.29 +++ modules/field/modules/text/text.test 9 Oct 2010 17:01:19 -0000 @@ -198,12 +198,16 @@ class TextFieldTestCase extends DrupalWe // Create a new text format that does not escape HTML, and grant the user // access to it. $this->drupalLogin($this->admin_user); - $edit = array('name' => $this->randomName()); + $edit = array( + 'format' => drupal_strtolower($this->randomName()), + 'name' => $this->randomName(), + ); $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration')); filter_formats_reset(); $this->checkPermissions(array(), TRUE); - $format_id = db_query("SELECT format FROM {filter_format} WHERE name = :name", array(':name' => $edit['name']))->fetchField(); - $permission = filter_permission_name(filter_format_load($format_id)); + $format = filter_format_load($edit['format']); + $format_id = $format->format; + $permission = filter_permission_name($format); $rid = max(array_keys($this->web_user->roles)); user_role_grant_permissions($rid, array($permission)); $this->drupalLogin($this->web_user); @@ -360,8 +364,8 @@ class TextSummaryTestCase extends Drupal // Test text_summary() for different sizes. for ($i = 0; $i <= 37; $i++) { $this->callTextSummary($text, $expected[$i], NULL, $i); - $this->callTextSummary($text, $expected_lb[$i], 1, $i); - $this->callTextSummary($text, $expected_lb[$i], 2, $i); + $this->callTextSummary($text, $expected_lb[$i], 'plain_text', $i); + $this->callTextSummary($text, $expected_lb[$i], 'filtered_html', $i); } } @@ -386,8 +390,15 @@ class TextTranslationTestCase extends Dr function setUp() { parent::setUp('locale', 'translation'); - $this->format = 3; - $this->admin = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages', 'bypass node access', "use text format $this->format")); + $full_html_format = filter_format_load('full_html'); + $this->format = $full_html_format->format; + $this->admin = $this->drupalCreateUser(array( + 'administer languages', + 'administer content types', + 'access administration pages', + 'bypass node access', + filter_permission_name($full_html_format), + )); $this->translator = $this->drupalCreateUser(array('create article content', 'edit own article content', 'translate content')); // Enable an additional language. @@ -456,11 +467,11 @@ class TextTranslationTestCase extends Dr // Populate the body field: the first item gets the "Full HTML" input // format, the second one "Filtered HTML". - $format = $this->format; + $formats = array('full_html', 'filtered_html'); foreach ($body as $delta => $value) { $edit = array( "body[$langcode][$delta][value]" => $value, - "body[$langcode][$delta][format]" => $format--, + "body[$langcode][$delta][format]" => array_shift($formats), ); $this->drupalPost('node/1/edit', $edit, t('Save')); $this->assertText($body[$delta], t('The body field with delta @delta has been saved.', array('@delta' => $delta))); Index: modules/filter/filter.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.admin.inc,v retrieving revision 1.66 diff -u -p -r1.66 filter.admin.inc --- modules/filter/filter.admin.inc 29 Sep 2010 19:52:12 -0000 1.66 +++ modules/filter/filter.admin.inc 9 Oct 2010 23:17:15 -0000 @@ -96,7 +96,10 @@ function theme_filter_admin_overview($va function filter_admin_format_page($format = NULL) { if (!isset($format->name)) { drupal_set_title(t('Add text format')); - $format = (object) array('name' => '', 'format' => 0); + $format = (object) array( + 'format' => NULL, + 'name' => '', + ); } return drupal_get_form('filter_admin_format_form', $format); } @@ -122,6 +125,16 @@ function filter_admin_format_form($form, '#default_value' => $format->name, '#required' => TRUE, ); + $form['format'] = array( + '#type' => 'textfield', // @todo http://drupal.org/node/902644 + '#required' => TRUE, + '#default_value' => $format->format, + '#maxlength' => 255, + '#machine_name' => array( + 'exists' => 'filter_format_load', + ), + '#disabled' => !empty($format->format), + ); // Add user role access selection. $form['roles'] = array( @@ -227,9 +240,6 @@ function filter_admin_format_form($form, } } - if (!empty($format->format)) { - $form['format'] = array('#type' => 'value', '#value' => $format->format); - } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); Index: modules/filter/filter.install =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.install,v retrieving revision 1.46 diff -u -p -r1.46 filter.install --- modules/filter/filter.install 28 Sep 2010 03:30:37 -0000 1.46 +++ modules/filter/filter.install 9 Oct 2010 23:17:34 -0000 @@ -14,9 +14,9 @@ function filter_schema() { 'description' => 'Table that maps filters (HTML corrector) to text formats (Filtered HTML).', 'fields' => array( 'format' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, 'description' => 'Foreign key: The {filter_format}.format to which this filter is assigned.', ), 'module' => array( @@ -62,16 +62,17 @@ function filter_schema() { 'description' => 'Stores text formats: custom groupings of filters, such as Filtered HTML.', 'fields' => array( 'format' => array( - 'type' => 'serial', + 'type' => 'varchar', + 'length' => 255, 'not null' => TRUE, - 'description' => 'Primary Key: Unique ID for format.', + 'description' => 'Primary Key: Unique machine name of the format.', ), 'name' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', - 'description' => 'Name of the text format (Filtered HTML).', + 'description' => 'Name of the format.', 'translatable' => TRUE, ), 'cache' => array( @@ -120,6 +121,7 @@ function filter_install() { // plain text format with very basic formatting, but it can be modified by // installation profiles to have other properties. $plain_text_format = array( + 'format' => 'plain_text', 'name' => 'Plain text', 'weight' => 10, 'filters' => array( @@ -470,6 +472,28 @@ function filter_update_7009() { } /** + * Change {filter_format}.format and {filter}.format into varchar. + */ +function filter_update_7010() { + // Remove the unique index for 'name'. Text formats have sufficient uniqueness + // through machine names. + db_drop_unique_key('filter_format', 'name'); + + db_change_field('filter_format', 'format', 'format', array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'description' => 'Primary Key: Unique machine name of the format.', + )); + db_change_field('filter', 'format', 'format', array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + 'description' => 'Foreign key: The {filter_format}.format to which this filter is assigned.', + )); +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.352 diff -u -p -r1.352 filter.module --- modules/filter/filter.module 8 Oct 2010 05:07:53 -0000 1.352 +++ modules/filter/filter.module 9 Oct 2010 17:01:19 -0000 @@ -182,23 +182,31 @@ function filter_format_load($format_id) * - 'settings': (optional) An array of configured settings for the filter. * See hook_filter_info() for details. */ -function filter_format_save(&$format) { +function filter_format_save($format) { $format->name = trim($format->name); $format->cache = _filter_format_is_cacheable($format); - $format->status = 1; + if (!isset($format->status)) { + $format->status = 1; + } + if (!isset($format->weight)) { + $format->weight = 0; + } + + // Insert or update the text format. + $return = db_merge('filter_format') + ->key(array('format' => $format->format)) + ->fields(array( + 'name' => $format->name, + 'cache' => (int) $format->cache, + 'status' => (int) $format->status, + 'weight' => (int) $format->weight, + )) + ->execute(); + // Programmatic saves may not contain any filters. if (!isset($format->filters)) { $format->filters = array(); } - - // Add a new text format. - if (empty($format->format)) { - $return = drupal_write_record('filter_format', $format); - } - else { - $return = drupal_write_record('filter_format', $format, 'format'); - } - $filter_info = filter_get_filters(); foreach ($filter_info as $name => $filter) { // Add new filters without weight to the bottom. @@ -241,8 +249,8 @@ function filter_format_save(&$format) { module_invoke_all('filter_format_update', $format); // Explicitly indicate that the format was updated. We need to do this // since if the filters were updated but the format object itself was not, - // the call to drupal_write_record() above would not return an indication - // that anything had changed. + // the merge query above would not return an indication that anything had + // changed. $return = SAVED_UPDATED; // Clear the filter cache whenever a text format is updated. Index: modules/filter/filter.test =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.test,v retrieving revision 1.77 diff -u -p -r1.77 filter.test --- modules/filter/filter.test 28 Sep 2010 03:30:37 -0000 1.77 +++ modules/filter/filter.test 9 Oct 2010 17:01:19 -0000 @@ -23,6 +23,7 @@ class FilterCRUDTestCase extends DrupalW function testTextFormatCRUD() { // Add a text format with minimum data only. $format = new stdClass(); + $format->format = 'empty_format'; $format->name = 'Empty format'; filter_format_save($format); $this->verifyTextFormat($format); @@ -30,6 +31,7 @@ class FilterCRUDTestCase extends DrupalW // Add another text format specifying all possible properties. $format = new stdClass(); + $format->format = 'custom_format'; $format->name = 'Custom format'; $format->filters = array( 'filter_url' => array( @@ -184,6 +186,7 @@ class FilterAdminTestCase extends Drupal $this->drupalGet('admin/config/content/formats'); $this->clickLink('Add text format'); $edit = array( + 'format' => drupal_strtolower($this->randomName()), 'name' => $this->randomName(), ); $this->drupalPost(NULL, $edit, t('Save configuration')); @@ -268,6 +271,7 @@ class FilterAdminTestCase extends Drupal // Add format. $edit = array(); + $edit['format'] = drupal_strtolower($this->randomName()); $edit['name'] = $this->randomName(); $edit['roles[2]'] = 1; $edit['filters[' . $second_filter . '][status]'] = TRUE; @@ -424,7 +428,10 @@ class FilterFormatAccessTestCase extends $this->drupalLogin($this->filter_admin_user); $formats = array(); for ($i = 0; $i < 2; $i++) { - $edit = array('name' => $this->randomName()); + $edit = array( + 'format' => drupal_strtolower($this->randomName()), + 'name' => $this->randomName(), + ); $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration')); $this->resetFilterCaches(); $format_id = db_query("SELECT format FROM {filter_format} WHERE name = :name", array(':name' => $edit['name']))->fetchField(); @@ -656,7 +663,10 @@ class FilterDefaultFormatTestCase extend $this->drupalLogin($admin_user); $formats = array(); for ($i = 0; $i < 2; $i++) { - $edit = array('name' => $this->randomName()); + $edit = array( + 'format' => drupal_strtolower($this->randomName()), + 'name' => $this->randomName(), + ); $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration')); $this->resetFilterCaches(); $format_id = db_query("SELECT format FROM {filter_format} WHERE name = :name", array(':name' => $edit['name']))->fetchField(); @@ -1684,6 +1694,7 @@ class FilterHooksTestCase extends Drupal // Add a text format. $name = $this->randomName(); $edit = array(); + $edit['format'] = drupal_strtolower($this->randomName()); $edit['name'] = $name; $edit['roles[1]'] = 1; $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration')); Index: modules/php/php.install =================================================================== RCS file: /cvs/drupal/drupal/modules/php/php.install,v retrieving revision 1.18 diff -u -p -r1.18 php.install --- modules/php/php.install 13 Sep 2010 01:11:08 -0000 1.18 +++ modules/php/php.install 9 Oct 2010 17:01:19 -0000 @@ -17,6 +17,7 @@ function php_enable() { // subsequent clean installs. if (!$format_exists) { $php_format = array( + 'format' => 'php_code', 'name' => 'PHP code', // 'Plain text' format is installed with a weight of 10 by default. Use a // higher weight here to ensure that this format will not be the default Index: modules/search/search.test =================================================================== RCS file: /cvs/drupal/drupal/modules/search/search.test,v retrieving revision 1.76 diff -u -p -r1.76 search.test --- modules/search/search.test 5 Oct 2010 06:17:29 -0000 1.76 +++ modules/search/search.test 9 Oct 2010 17:01:19 -0000 @@ -370,7 +370,11 @@ class SearchRankingTestCase extends Drup // Create nodes for testing. foreach ($node_ranks as $node_rank) { - $settings = array('type' => 'page', 'title' => array(LANGUAGE_NONE => array(array('value' => 'Drupal rocks'))), 'body' => array(LANGUAGE_NONE => array(array('value' => "Drupal's search rocks")))); + $settings = array( + 'type' => 'page', + 'title' => 'Drupal rocks', + 'body' => array(LANGUAGE_NONE => array(array('value' => "Drupal's search rocks"))), + ); foreach (array(0, 1) as $num) { if ($num == 1) { switch ($node_rank) { @@ -444,18 +448,18 @@ class SearchRankingTestCase extends Drup shuffle($shuffled_tags); $settings = array( 'type' => 'page', - 'title' => array(LANGUAGE_NONE => array(array('value' => 'Simple node'))), + 'title' => 'Simple node', ); foreach ($shuffled_tags as $tag) { switch ($tag) { case 'a': - $settings['body'] = array(LANGUAGE_NONE => array(array('value' => l('Drupal Rocks', 'node'), 'format' => 3))); + $settings['body'] = array(LANGUAGE_NONE => array(array('value' => l('Drupal Rocks', 'node'), 'format' => 'full_html'))); break; case 'notag': $settings['body'] = array(LANGUAGE_NONE => array(array('value' => 'Drupal Rocks'))); break; default: - $settings['body'] = array(LANGUAGE_NONE => array(array('value' => "<$tag>Drupal Rocks", 'format' => 3))); + $settings['body'] = array(LANGUAGE_NONE => array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html'))); break; } $nodes[$tag] = $this->drupalCreateNode($settings); @@ -488,7 +492,7 @@ class SearchRankingTestCase extends Drup // Test tags with the same weight against the sorted tags. $unsorted_tags = array('u', 'b', 'i', 'strong', 'em'); foreach ($unsorted_tags as $tag) { - $settings['body'] = array(LANGUAGE_NONE => array(array('value' => "<$tag>Drupal Rocks", 'format' => 3))); + $settings['body'] = array(LANGUAGE_NONE => array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html'))); $node = $this->drupalCreateNode($settings); // Update the search index. @@ -523,7 +527,7 @@ class SearchRankingTestCase extends Drup // See testRankings() above - build a node that will rank high for sticky. $settings = array( 'type' => 'page', - 'title' => array(LANGUAGE_NONE => array(array('value' => 'Drupal rocks'))), + 'title' => 'Drupal rocks', 'body' => array(LANGUAGE_NONE => array(array('value' => "Drupal's search rocks"))), 'sticky' => 1, ); @@ -712,9 +716,9 @@ class SearchCommentTestCase extends Drup // Enable check_plain() for 'Filtered HTML' text format. $filtered_html_format_id = db_query_range('SELECT format FROM {filter_format} WHERE name = :name', 0, 1, array(':name' => 'Filtered HTML'))->fetchField(); $edit = array( - 'filters[filter_html_escape][status]' => $filtered_html_format_id, + 'filters[filter_html_escape][status]' => TRUE, ); - $this->drupalPost('admin/config/content/formats/1', $edit, t('Save configuration')); + $this->drupalPost('admin/config/content/formats/' . $filtered_html_format_id, $edit, t('Save configuration')); // Allow anonymous users to search content. $edit = array( DRUPAL_ANONYMOUS_RID . '[search content]' => 1, Index: modules/simpletest/tests/form_test.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/form_test.module,v retrieving revision 1.51 diff -u -p -r1.51 form_test.module --- modules/simpletest/tests/form_test.module 4 Oct 2010 18:00:46 -0000 1.51 +++ modules/simpletest/tests/form_test.module 9 Oct 2010 17:01:19 -0000 @@ -999,14 +999,14 @@ function _form_test_disabled_elements($f '#title' => 'Text format', '#disabled' => TRUE, '#default_value' => 'Text value', - '#format' => 1, + '#format' => 'plain_text', '#expected_value' => array( 'value' => 'Text value', - 'format' => 1, + 'format' => 'plain_text', ), '#test_hijack_value' => array( 'value' => 'HIJACK', - 'format' => 2, + 'format' => 'filtered_html', ), ); Index: modules/taxonomy/taxonomy.install =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.install,v retrieving revision 1.51 diff -u -p -r1.51 taxonomy.install --- modules/taxonomy/taxonomy.install 6 Oct 2010 21:53:41 -0000 1.51 +++ modules/taxonomy/taxonomy.install 9 Oct 2010 17:01:19 -0000 @@ -51,8 +51,8 @@ function taxonomy_schema() { 'translatable' => TRUE, ), 'format' => array( - 'type' => 'int', - 'unsigned' => TRUE, + 'type' => 'varchar', + 'length' => 255, 'not null' => FALSE, 'description' => 'The {filter_format}.format of the description.', ), Index: modules/user/user.install =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.install,v retrieving revision 1.67 diff -u -p -r1.67 user.install --- modules/user/user.install 5 Oct 2010 06:17:29 -0000 1.67 +++ modules/user/user.install 9 Oct 2010 17:01:19 -0000 @@ -167,8 +167,8 @@ function user_schema() { 'description' => "User's signature.", ), 'signature_format' => array( - 'type' => 'int', - 'unsigned' => TRUE, + 'type' => 'varchar', + 'length' => 255, 'not null' => FALSE, 'description' => 'The {filter_format}.format of the signature.', ), @@ -355,6 +355,11 @@ function user_update_dependencies() { $dependencies['user'][7013] = array( 'system' => 7059, ); + // Ensure that format columns are only changed after Filter module has changed + // the primary records. + $dependencies['user'][7015] = array( + 'filter' => 7010, + ); return $dependencies; } @@ -838,6 +843,18 @@ function user_update_7014() { } /** + * Change {users}.signature_format into varchar. + */ +function user_update_7015() { + db_change_field('users', 'signature_format', 'signature_format', array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + 'description' => 'The {filter_format}.format of the signature.', + )); +} + +/** * @} End of "defgroup user-updates-6.x-to-7.x" * The next series of updates should start at 8000. */ Index: profiles/standard/standard.install =================================================================== RCS file: /cvs/drupal/drupal/profiles/standard/standard.install,v retrieving revision 1.26 diff -u -p -r1.26 standard.install --- profiles/standard/standard.install 5 Oct 2010 06:17:29 -0000 1.26 +++ profiles/standard/standard.install 9 Oct 2010 17:01:19 -0000 @@ -9,6 +9,7 @@ function standard_install() { // Add text formats. $filtered_html_format = array( + 'format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, 'filters' => array( @@ -38,6 +39,7 @@ function standard_install() { filter_format_save($filtered_html_format); $full_html_format = array( + 'format' => 'full_html', 'name' => 'Full HTML', 'weight' => 1, 'filters' => array(