diff options
Diffstat (limited to 'modules/user')
-rw-r--r-- | modules/user/user.install | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/modules/user/user.install b/modules/user/user.install index 2eeb31764..00afd2dc0 100644 --- a/modules/user/user.install +++ b/modules/user/user.install @@ -168,9 +168,8 @@ function user_schema() { ), 'signature_format' => array( 'type' => 'int', - 'size' => 'small', - 'not null' => TRUE, - 'default' => 0, + 'unsigned' => TRUE, + 'not null' => FALSE, 'description' => 'The {filter_format}.format of the signature.', ), 'created' => array( @@ -346,8 +345,9 @@ function user_update_dependencies() { $dependencies['system'][7000] = array( 'user' => 7008, ); - // user_update_7006 relies on filter_update_7002. - // TODO: move user_update_7006 down below in the upgrade process. + // Both user_update_7006() and user_update_7010() need to query the list of + // existing text formats and therefore must run after filter_update_7003(). + // @todo: move user_update_7006 down below in the upgrade process. $dependencies['user'][7006] = array( 'filter' => 7003, ); @@ -633,17 +633,51 @@ function user_update_7009() { * Update the {user}.signature_format column. */ function user_update_7010() { - // It was previously possible for a value of "0" to be stored in database - // tables to indicate that a particular piece of text should be filtered - // using the default text format. + // Update the database column to allow NULL values. + db_change_field('users', 'signature_format', 'signature_format', array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE, + 'description' => 'The {filter_format}.format of the signature.', + )); + + // Replace the signature format with NULL if the signature is empty and does + // not already have a stored text format. + // + // In Drupal 6, "0" (the former FILTER_FORMAT_DEFAULT constant) could be used + // to indicate this situation, but in Drupal 7, only NULL is supported. This + // update therefore preserves the ability of user accounts which were never + // given a signature (for example, if the site did not have user signatures + // enabled, or if the user never edited their account information) to not + // have a particular text format assumed for them the first time the + // signature is edited. + db_update('users') + ->fields(array('signature_format' => NULL)) + ->condition('signature', '') + ->condition('signature_format', 0) + ->execute(); + + // There are a number of situations in which a Drupal 6 site could store + // content with a nonexistent text format. This includes text formats that + // had later been deleted, or non-empty content stored with a value of "0" + // (the former FILTER_FORMAT_DEFAULT constant). Drupal 6 would filter this + // content using whatever the site-wide default text format was at the moment + // the text was being displayed. + // + // In Drupal 7, this behavior is no longer supported, and all content must be + // stored with an explicit text format (or it will not be displayed when it + // is filtered). Therefore, to preserve the behavior of the site after the + // upgrade, we must replace all instances described above with the current + // value of the (old) site-wide default format at the moment of the upgrade. + $existing_formats = db_query("SELECT format FROM {filter_format}")->fetchCol(); $default_format = variable_get('filter_default_format', 1); db_update('users') ->fields(array('signature_format' => $default_format)) - ->condition('signature_format', 0) + ->isNotNull('signature_format') + ->condition('signature_format', $existing_formats, 'NOT IN') ->execute(); } - /** * Updates email templates to use new tokens. * |