summaryrefslogtreecommitdiff
path: root/modules/node/node.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/node/node.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/node/node.install')
-rw-r--r--modules/node/node.install25
1 files changed, 20 insertions, 5 deletions
diff --git a/modules/node/node.install b/modules/node/node.install
index 14f1b9de8..f63caa1e7 100644
--- a/modules/node/node.install
+++ b/modules/node/node.install
@@ -411,6 +411,9 @@ function node_update_dependencies() {
// the Field module has been enabled, but before upgrading field data.
$dependencies['node'][7006] = array(
'system' => 7049,
+ // It must also run after filter_update_7000() because it needs to query
+ // the list of existing text formats.
+ 'filter' => 7000,
);
$dependencies['system'][7050] = array(
'node' => 7006,
@@ -567,6 +570,9 @@ function node_update_7006(&$sandbox) {
);
}
+ // Used below when updating the stored text format of each node body.
+ $sandbox['existing_text_formats'] = db_query("SELECT format FROM {filter_format}")->fetchCol();
+
// Initialize state for future calls.
$sandbox['last'] = 0;
$sandbox['count'] = 0;
@@ -625,11 +631,20 @@ function node_update_7006(&$sandbox) {
$revision->body = substr($revision->body, strlen($break));
}
$node->body[$langcode][0]['value'] = $revision->body;
- // Explicitly store the current default text format if the revision
- // did not have its own text format. Similar conversions for other
- // core modules are performed in filter_update_7005(), but we do this
- // one here since we are already migrating the data.
- $node->body[$langcode][0]['format'] = !empty($revision->format) ? $revision->format : variable_get('filter_default_format', 1);
+ // Update the revision's text format for the changes to the Drupal 7
+ // filter system. This uses the same kind of logic that occurs, for
+ // example, in user_update_7010(), but we do this here rather than
+ // via a separate set of database queries, since we are already
+ // migrating the data.
+ if (empty($revision->body) && empty($revision->format)) {
+ $node->body[$langcode][0]['format'] = NULL;
+ }
+ elseif (!in_array($revision->format, $sandbox['existing_text_formats'])) {
+ $node->body[$langcode][0]['format'] = variable_get('filter_default_format', 1);
+ }
+ else {
+ $node->body[$langcode][0]['format'] = $revision->format;
+ }
// This is a core update and no contrib modules are enabled yet, so
// we can assume default field storage for a faster update.
field_sql_storage_field_storage_write('node', $node, FIELD_STORAGE_INSERT, array($body_field_id));