summaryrefslogtreecommitdiff
path: root/modules/comment/comment.install
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-09-28 03:30:37 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-09-28 03:30:37 +0000
commit0c49d5794534fe9fd609c6884bdde8849edcb0eb (patch)
tree029343c988a2dd983e96ece91b2d6adb2e126509 /modules/comment/comment.install
parent782eb4c79c883466ad3414fa981e286b782afe6c (diff)
downloadbrdo-0c49d5794534fe9fd609c6884bdde8849edcb0eb.tar.gz
brdo-0c49d5794534fe9fd609c6884bdde8849edcb0eb.tar.bz2
#358437 follow-up by David_Rothstein, sun, chx: Disallow invalid text format IDs; force 0 and non-existant formats to NULL.
Diffstat (limited to 'modules/comment/comment.install')
-rw-r--r--modules/comment/comment.install33
1 files changed, 23 insertions, 10 deletions
diff --git a/modules/comment/comment.install b/modules/comment/comment.install
index 03b21860c..6a7b03427 100644
--- a/modules/comment/comment.install
+++ b/modules/comment/comment.install
@@ -87,6 +87,12 @@ function comment_update_dependencies() {
'system' => 7021,
);
+ // Comment update 7006 needs to query the list of existing text formats and
+ // therefore must run after filter_update_7000().
+ $dependencies['comment'][7006] = array(
+ 'filter' => 7000,
+ );
+
return $dependencies;
}
@@ -300,24 +306,31 @@ function comment_update_7006(&$sandbox) {
$query->addField('c', 'comment', 'comment_body_value');
$query->addField('c', 'format', 'comment_body_format');
- $comment_body_table = 'field_data_comment_body';
-
- db_insert($comment_body_table)
+ db_insert('field_data_comment_body')
->from($query)
->execute();
- // Update the comment body format in a similar manner as is done for other
- // modules in filter_update_7005(), but we do this one here since we are
- // already migrating the data.
- db_update($comment_body_table)
- ->fields(array('comment_body_format' => variable_get('filter_default_format', 1)))
- ->condition('comment_body_format', 0)
- ->execute();
$sandbox['#finished'] = 1 - count($sandbox['types']) / $sandbox['total'];
}
// On the last pass of the update, $sandbox['types'] will be empty.
if (empty($sandbox['types'])) {
+ // Update the comment body text formats. For an explanation of these
+ // updates, see the code comments in user_update_7010().
+ db_update('field_data_comment_body')
+ ->fields(array('comment_body_format' => NULL))
+ ->condition('comment_body_value', '')
+ ->condition('comment_body_format', 0)
+ ->execute();
+ $existing_formats = db_query("SELECT format FROM {filter_format}")->fetchCol();
+ $default_format = variable_get('filter_default_format', 1);
+ db_update('field_data_comment_body')
+ ->fields(array('comment_body_format' => $default_format))
+ ->isNotNull('comment_body_format')
+ ->condition('comment_body_format', $existing_formats, 'NOT IN')
+ ->execute();
+
+ // Finally, remove the old comment data.
db_drop_field('comment', 'comment');
db_drop_field('comment', 'format');
}