Commit 39481998 authored by Dries's avatar Dries
Browse files

- Patch #1097100 by quicksketch, boombatower, claar: remove all 7xxx update...

- Patch #1097100 by quicksketch, boombatower, claar: remove all 7xxx update functions and tests (D6 to D7 upgrade path).
parent 488176bf
......@@ -230,7 +230,8 @@ function user_hash_password($password, $count_log2 = 0) {
function user_check_password($password, $account) {
if (substr($account->pass, 0, 2) == 'U$') {
// This may be an updated password from user_update_7000(). Such hashes
// have 'U' added as the first character and need an extra md5().
// have 'U' added as the first character and need an extra md5() (see the
// Drupal 7 documentation).
$stored_hash = substr($account->pass, 1);
$password = md5($password);
}
......@@ -264,7 +265,7 @@ function user_check_password($password, $account) {
* password is available. A new hash is needed when the desired iteration count
* has changed through a change in the variable password_count_log2 or
* DRUPAL_HASH_COUNT or if the user's password hash was generated in an update
* like user_update_7000().
* like user_update_7000() (see the Drupal 7 documentation).
*
* Alternative implementations of this function might use other criteria based
* on the fields in $account.
......
This diff is collapsed.
......@@ -278,31 +278,3 @@ function aggregator_schema() {
return $schema;
}
/**
* Add hash column to aggregator_feed table.
*/
function aggregator_update_7000() {
db_add_field('aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
}
/**
* Add aggregator teaser length to settings from old global default teaser length
*/
function aggregator_update_7001() {
variable_set('aggregator_teaser_length', variable_get('teaser_length'));
}
/**
* Add queued timestamp.
*/
function aggregator_update_7002() {
db_add_field('aggregator_feed', 'queued', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
));
db_add_index('aggregator_feed', 'queued', array('queued'));
}
......@@ -185,281 +185,3 @@ function block_install() {
->condition('name', 'block')
->execute();
}
/**
* Implements hook_update_dependencies().
*/
function block_update_dependencies() {
// Block update 7005 needs to query the list of existing text formats and
// therefore must run after filter_update_7000().
$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;
}
/**
* @addtogroup updates-6.x-to-7.x
* @{
*/
/**
* Set system.weight to a low value for block module.
*
* Block should go first so that other modules can alter its output
* during hook_page_alter(). Almost everything on the page is a block,
* so before block module runs, there will not be much to alter.
*/
function block_update_7000() {
db_update('system')
->fields(array('weight' => '-5'))
->condition('name', 'block')
->execute();
}
/**
* Rename {blocks} table to {block}, {blocks_roles} to {block_role} and
* {boxes} to {block_custom}.
*/
function block_update_7002() {
db_rename_table('blocks', 'block');
db_rename_table('blocks_roles', 'block_role');
db_rename_table('boxes', 'block_custom');
}
/**
* Change the weight column to normal int.
*/
function block_update_7003() {
db_drop_index('block', 'list');
db_change_field('block', 'weight', 'weight', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Block weight within region.',
), array(
'indexes' => array(
'list' => array('theme', 'status', 'region', 'weight', 'module'),
),
));
}
/**
* Add new blocks to new regions, migrate custom variables to blocks.
*/
function block_update_7004() {
// Collect a list of themes with blocks.
$themes_with_blocks = array();
$result = db_query("SELECT s.name FROM {system} s INNER JOIN {block} b ON s.name = b.theme WHERE s.type = 'theme' GROUP by s.name");
$insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($result as $theme) {
$themes_with_blocks[] = $theme->name;
// Add new system generated help block.
$insert->values(array(
'module' => 'system',
'delta' => 'help',
'theme' => $theme->name,
'status' => 1,
'weight' => 0,
'region' => 'help',
'pages' => '',
'cache' => DRUPAL_CACHE_PER_ROLE,
));
// Add new system generated main page content block.
$insert->values(array(
'module' => 'system',
'delta' => 'main',
'theme' => $theme->name,
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => DRUPAL_NO_CACHE,
));
}
$insert->execute();
// Migrate blocks from left/right regions to first/second regions.
db_update('block')
->fields(array('region' => 'sidebar_first'))
->condition('region', 'left')
->execute();
db_update('block')
->fields(array('region' => 'sidebar_second'))
->condition('region', 'right')
->execute();
// Migrate contact form information.
$default_format = variable_get('filter_default_format', 1);
if ($contact_help = variable_get('contact_form_information', '')) {
$bid = db_insert('block_custom')
->fields(array(
'body' => $contact_help,
'info' => 'Contact page help',
'format' => $default_format,
))
->execute();
$insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
foreach ($themes_with_blocks as $theme) {
// Add contact help block for themes, which had blocks.
$insert->values(array(
'module' => 'block',
'delta' => $bid,
'theme' => $theme,
'status' => 1,
'weight' => 5,
'region' => 'help',
'visibility' => BLOCK_VISIBILITY_LISTED,
'pages' => 'contact',
'cache' => DRUPAL_NO_CACHE,
));
}
drupal_set_message('The contact form information setting was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the site-wide contact page. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right.');
}
$insert->execute();
// Migrate user help setting.
if ($user_help = variable_get('user_registration_help', '')) {
$bid = db_insert('block_custom')->fields(array('body' => $user_help, 'info' => 'User registration guidelines', 'format' => $default_format))->execute();
$insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
foreach ($themes_with_blocks as $theme) {
// Add user registration help block for themes, which had blocks.
$insert->values(array(
'module' => 'block',
'delta' => $bid,
'theme' => $theme,
'status' => 1,
'weight' => 5,
'region' => 'help',
'visibility' => BLOCK_VISIBILITY_LISTED,
'pages' => 'user/register',
'cache' => DRUPAL_NO_CACHE,
));
}
drupal_set_message('The user registration guidelines were migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the user registration page. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right.');
$insert->execute();
}
// Migrate site mission setting.
if ($mission = variable_get('site_mission')) {
$bid = db_insert('block_custom')->fields(array('body' => $mission, 'info' => 'Site mission', 'format' => $default_format))->execute();
$insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
foreach ($themes_with_blocks as $theme) {
// Add mission block for themes, which had blocks.
$insert->values(array(
'module' => 'block',
'delta' => $bid,
'theme' => $theme,
'status' => 1,
'weight' => 0,
'region' => 'highlighted',
'visibility' => BLOCK_VISIBILITY_LISTED,
'pages' => '<front>',
'cache' => DRUPAL_NO_CACHE,
));
}
drupal_set_message('The site mission was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the front page in the highlighted content region. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right. If your theme does not have a highlighted content region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
$insert->execute();
// Migrate mission to RSS site description.
variable_set('feed_description', $mission);
}
// Migrate site footer message to a custom block.
if ($footer_message = variable_get('site_footer', '')) {
$bid = db_insert('block_custom')->fields(array('body' => $footer_message, 'info' => 'Footer message', 'format' => $default_format))->execute();
$insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($themes_with_blocks as $theme) {
// Add site footer block for themes, which had blocks.
// Set low weight, so the block comes early (it used to be
// before the other blocks).
$insert->values(array(
'module' => 'block',
'delta' => $bid,
'theme' => $theme,
'status' => 1,
'weight' => -10,
'region' => 'footer',
'pages' => '',
'cache' => DRUPAL_NO_CACHE,
));
}
drupal_set_message('The footer message was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to appear in the footer. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right. If your theme does not have a footer region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
$insert->execute();
}
// Remove the variables (even if they were saved empty on the admin interface),
// to avoid keeping clutter in the variables table.
variable_del('contact_form_information');
variable_del('user_registration_help');
variable_del('site_mission');
variable_del('site_footer');
// Rebuild theme data, so the new 'help' region is identified.
system_rebuild_theme_data();
}
/**
* Update the {block_custom}.format column.
*/
function block_update_7005() {
// For an explanation of these updates, see the code comments in
// user_update_7010().
db_change_field('block_custom', 'format', 'format', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'description' => 'The {filter_format}.format of the block body.',
));
db_update('block_custom')
->fields(array('format' => NULL))
->condition('body', '')
->condition('format', 0)
->execute();
$existing_formats = db_query("SELECT format FROM {filter_format}")->fetchCol();
$default_format = variable_get('filter_default_format', 1);
db_update('block_custom')
->fields(array('format' => $default_format))
->isNotNull('format')
->condition('format', $existing_formats, 'NOT IN')
->execute();
}
/**
* Recreates cache_block table.
*
* Converts fields that hold serialized variables from text to blob.
* Removes 'headers' column.
*/
function block_update_7006() {
$schema = system_schema_cache_7054();
db_drop_table('cache_block');
db_create_table('cache_block', $schema);
}
/**
* 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 "addtogroup updates-6.x-to-7.x"
*/
......@@ -78,268 +78,6 @@ function comment_modules_enabled($modules) {
}
}
/**
* Implements hook_update_dependencies().
*/
function comment_update_dependencies() {
// Comment update 7005 creates the comment body field and therefore must run
// after text module has been enabled and entities have been updated.
$dependencies['comment'][7005] = array(
'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;
}
/**
* @addtogroup updates-6.x-to-7.x
* @{
*/
/**
* Rename comment display setting variables.
*/
function comment_update_7000() {
$types = _update_7000_node_get_types();
foreach ($types as $type => $type_object) {
variable_del('comment_default_order' . $type);
// Drupal 6 had four display modes:
// - COMMENT_MODE_FLAT_COLLAPSED = 1
// - COMMENT_MODE_FLAT_EXPANDED = 2
// - COMMENT_MODE_THREADED_COLLAPSED = 3
// - COMMENT_MODE_THREADED_EXPANDED = 4
//
// Drupal 7 doesn't support collapsed/expanded modes anymore, so we
// migrate all the flat modes to COMMENT_MODE_FLAT (0) and all the threaded
// modes to COMMENT_MODE_THREADED (1).
$setting = variable_get('comment_default_mode_' . $type, 4);
if ($setting == 3 || $setting == 4) {
variable_set('comment_default_mode_' . $type, 1);
}
else {
variable_set('comment_default_mode_' . $type, 0);
}
// There were only two comment modes in the past:
// - 1 was 'required' previously, convert into DRUPAL_REQUIRED (2).
// - 0 was 'optional' previously, convert into DRUPAL_OPTIONAL (1).
$preview = variable_get('comment_preview_' . $type, 1) ? 2 : 1;
variable_set('comment_preview_' . $type, $preview);
}
}
/**
* Change comment status from published being 0 to being 1
*/
function comment_update_7001() {
// Choose a temporary status value different from the existing status values.
$tmp_status = db_query('SELECT MAX(status) FROM {comments}')->fetchField() + 1;
$changes = array(
0 => $tmp_status,
1 => 0,
$tmp_status => 1,
);
foreach ($changes as $old => $new) {
db_update('comments')
->fields(array('status' => $new))
->condition('status', $old)
->execute();
}
}
/**
* Rename {comments} table to {comment} and upgrade it.
*/
function comment_update_7002() {
db_rename_table('comments', 'comment');
// Add user-related indexes.
db_add_index('comment', 'comment_uid', array('uid'));
db_add_index('node_comment_statistics', 'last_comment_uid', array('last_comment_uid'));
// Create a language column.
db_add_field('comment', 'language', array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
));
db_add_index('comment', 'comment_nid_language', array('nid', 'language'));
}
/**
* Split {comment}.timestamp into 'created' and 'changed', improve indexing on {comment}.
*/
function comment_update_7003() {
// Drop the old indexes.
db_drop_index('comment', 'status');
db_drop_index('comment', 'pid');
// Create a created column.
db_add_field('comment', 'created', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
));
// Rename the timestamp column to changed.
db_change_field('comment', 'timestamp', 'changed', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
));
// Migrate the data.
// @todo db_update() should support this.
db_query('UPDATE {comment} SET created = changed');
// Recreate the indexes.
// The 'comment_num_new' index is optimized for comment_num_new()
// and comment_new_page_count().
db_add_index('comment', 'comment_num_new', array('nid', 'status', 'created', 'cid', 'thread'));
db_add_index('comment', 'comment_pid_status', array('pid', 'status'));
}
/**
* Upgrade the {node_comment_statistics} table.
*/
function comment_update_7004() {
db_add_field('node_comment_statistics', 'cid', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The {comment}.cid of the last comment.',
));
db_add_index('node_comment_statistics', 'cid', array('cid'));
// Add an index on the comment_count.
db_add_index('node_comment_statistics', 'comment_count', array('comment_count'));
}
/**
* Create the comment_body field.
*/
function comment_update_7005() {
// Create comment body field.
$field = array(
'field_name' => 'comment_body',
'type' => 'text_long',
'module' => 'text',
'entity_types' => array(
'comment',
),
'settings' => array(),
'cardinality' => 1,
);
_update_7000_field_create_field($field);
// Add the field to comments for all existing bundles.
$generic_instance = array(
'entity_type' => 'comment',
'label' => t('Comment'),
'settings' => array(
'text_processing' => 1,
),
'required' => TRUE,
'display' => array(
'default' => array(
'label' => 'hidden',
'type' => 'text_default',
'weight' => 0,
'settings' => array(),
'module' => 'text',
),
),
'widget' => array(
'type' => 'text_textarea',
'settings' => array(
'rows' => 5,
),
'weight' => 0,
'module' => 'text',
),
'description' => '',
);
$types = _update_7000_node_get_types();
foreach ($types as $type => $type_object) {
$instance = $generic_instance;
$instance['bundle'] = 'comment_node_' . $type;
_update_7000_field_create_instance($field, $instance);
}
}
/**
* Migrate data from the comment field to field storage.
*/
function comment_update_7006(&$sandbox) {
// This is a multipass update. First set up some comment variables.
if (empty($sandbox['total'])) {
$comments = (bool) db_query_range('SELECT 1 FROM {comment}', 0, 1)->fetchField();
$sandbox['types'] = array();
if ($comments) {
$sandbox['types'] = array_keys(_update_7000_node_get_types());
}
$sandbox['total'] = count($sandbox['types']);
}
if (!empty($sandbox['types'])) {
$type = array_shift($sandbox['types']);
$query = db_select('comment', 'c');
$query->innerJoin('node', 'n', 'c.nid = n.nid AND n.type = :type', array(':type' => $type));
$query->addField('c', 'cid', 'entity_id');
$query->addExpression("'comment_node_$type'", 'bundle');
$query->addExpression("'comment'", 'entity_type');
$query->addExpression('0', 'deleted');
$query->addExpression("'" . LANGUAGE_NONE . "'", 'language');
$query->addExpression('0', 'delta');
$query->addField('c', 'comment', 'comment_body_value');
$query->addField('c', 'format', 'comment_body_format');
db_insert('field_data_comment_body')
->from($query)
->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');
}
}
/**
* @} End of "addtogroup updates-6.x-to-7.x"
*/
/**
* Implements hook_schema().
*/
......
......@@ -87,63 +87,3 @@ function contact_uninstall() {
variable_del('contact_threshold_limit');
variable_del('contact_threshold_window');
}
/**