#596614 by asimmonds: Rename node_update_7006() context parameter to sandbox, for consistency.
parent
a649700010
commit
83cc0c4d88
|
@ -496,14 +496,14 @@ function node_update_7005() {
|
||||||
/**
|
/**
|
||||||
* Convert body and teaser from node properties to fields, and migrate status/comment/promote and sticky columns to the {node_revision} table.
|
* Convert body and teaser from node properties to fields, and migrate status/comment/promote and sticky columns to the {node_revision} table.
|
||||||
*/
|
*/
|
||||||
function node_update_7006(&$context) {
|
function node_update_7006(&$sandbox) {
|
||||||
$context['#finished'] = 0;
|
$sandbox['#finished'] = 0;
|
||||||
|
|
||||||
// Get node type info for every invocation.
|
// Get node type info for every invocation.
|
||||||
drupal_static_reset('_node_types_build');
|
drupal_static_reset('_node_types_build');
|
||||||
$node_types = node_type_get_types();
|
$node_types = node_type_get_types();
|
||||||
|
|
||||||
if (!isset($context['total'])) {
|
if (!isset($sandbox['total'])) {
|
||||||
// Initial invocation.
|
// Initial invocation.
|
||||||
|
|
||||||
// Re-save node types to create body field instances.
|
// Re-save node types to create body field instances.
|
||||||
|
@ -514,12 +514,12 @@ function node_update_7006(&$context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize state for future calls.
|
// Initialize state for future calls.
|
||||||
$context['last'] = 0;
|
$sandbox['last'] = 0;
|
||||||
$context['count'] = 0;
|
$sandbox['count'] = 0;
|
||||||
|
|
||||||
$query = db_select('node', 'n');
|
$query = db_select('node', 'n');
|
||||||
$query->join('node_revision', 'nr', 'n.vid = nr.vid');
|
$query->join('node_revision', 'nr', 'n.vid = nr.vid');
|
||||||
$context['total'] = $query->countQuery()->execute()->fetchField();
|
$sandbox['total'] = $query->countQuery()->execute()->fetchField();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Subsequent invocations.
|
// Subsequent invocations.
|
||||||
|
@ -529,7 +529,7 @@ function node_update_7006(&$context) {
|
||||||
$body_field_id = $body_field['id'];
|
$body_field_id = $body_field['id'];
|
||||||
|
|
||||||
$found = FALSE;
|
$found = FALSE;
|
||||||
if ($context['total']) {
|
if ($sandbox['total']) {
|
||||||
// Operate on every revision of every node (whee!), in batches.
|
// Operate on every revision of every node (whee!), in batches.
|
||||||
$batch_size = 200;
|
$batch_size = 200;
|
||||||
$query = db_select('node_revision', 'nr');
|
$query = db_select('node_revision', 'nr');
|
||||||
|
@ -537,7 +537,7 @@ function node_update_7006(&$context) {
|
||||||
$query
|
$query
|
||||||
->fields('nr', array('nid', 'vid', 'body', 'teaser', 'format'))
|
->fields('nr', array('nid', 'vid', 'body', 'teaser', 'format'))
|
||||||
->fields('n', array('type', 'status', 'comment', 'promote', 'sticky', 'language'))
|
->fields('n', array('type', 'status', 'comment', 'promote', 'sticky', 'language'))
|
||||||
->condition('nr.vid', $context['last'], '>')
|
->condition('nr.vid', $sandbox['last'], '>')
|
||||||
->orderBy('nr.vid', 'ASC')
|
->orderBy('nr.vid', 'ASC')
|
||||||
->range(0, $batch_size);
|
->range(0, $batch_size);
|
||||||
$revisions = $query->execute();
|
$revisions = $query->execute();
|
||||||
|
@ -592,11 +592,11 @@ function node_update_7006(&$context) {
|
||||||
->condition('vid', $revision->vid)
|
->condition('vid', $revision->vid)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$context['last'] = $revision->vid;
|
$sandbox['last'] = $revision->vid;
|
||||||
$context['count'] += 1;
|
$sandbox['count'] += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$context['#finished'] = min(0.99, $context['count'] / $context['total']);
|
$sandbox['#finished'] = min(0.99, $sandbox['count'] / $sandbox['total']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$found) {
|
if (!$found) {
|
||||||
|
@ -608,8 +608,8 @@ function node_update_7006(&$context) {
|
||||||
db_drop_field('node_revision', 'format');
|
db_drop_field('node_revision', 'format');
|
||||||
|
|
||||||
// We're done.
|
// We're done.
|
||||||
$context['#finished'] = 1;
|
$sandbox['#finished'] = 1;
|
||||||
return t("!number node body and teaser properties migrated to the 'body' field.", array('!number' => $context['total']));
|
return t("!number node body and teaser properties migrated to the 'body' field.", array('!number' => $sandbox['total']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue