Commit 39481998 authored by Dries's avatar Dries

- 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'));
}
This diff is collapsed.
......@@ -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');
}
/**
* @addtogroup updates-6.x-to-7.x
* @{
*/
/**
* Rename the threshold limit variable.
*/
function contact_update_7000() {
variable_set('contact_threshold_limit', variable_get('contact_hourly_threshold', 5));
variable_del('contact_hourly_threshold');
}
/**
* Rename the administer contact forms permission.
*/
function contact_update_7001() {
db_update('role_permission')
->fields(array('permission' => 'administer contact forms'))
->condition('permission', 'administer site-wide contact form')
->execute();
}
/**
* Enable the 'access user contact forms' for registered users by default.
*/
function contact_update_7002() {
// Do not use user_role_grant_permission() since it relies on
// hook_permission(), which will not run for contact module if it is
// disabled.
db_merge('role_permission')
->key(array(
'rid' => DRUPAL_AUTHENTICATED_RID,
'permission' => 'access user contact forms',
'module' => 'contact',
))
->execute();
}
/**
* Change the weight column to normal int.
*/
function contact_update_7003() {
db_drop_index('contact', 'list');
db_change_field('contact', 'weight', 'weight', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => "The category's weight.",
), array(
'indexes' => array(
'list' => array('weight', 'category'),
),
));
}
/**
* @} End of "addtogroup updates-6.x-to-7.x"
*/
......@@ -97,46 +97,3 @@ function dblog_schema() {
function dblog_uninstall() {
variable_del('dblog_row_limit');
}
/**
* @addtogroup updates-6.x-to-7.x
* @{
*/
/**
* Update the {watchdog} table.
*/
function dblog_update_7001() {
// Allow NULL values for links.
db_change_field('watchdog', 'link', 'link', array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
'description' => 'Link to view the result of the event.',
));
// Add an index on uid.
db_add_index('watchdog', 'uid', array('uid'));
// Allow longer type values.
db_change_field('watchdog', 'type', 'type', array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'Type of log message, for example "user" or "page not found."',
));
// Convert the variables field (that stores serialized variables) from text to blob.
db_change_field('watchdog', 'variables', 'variables', array(
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
));
}
/**
* @} End of "addtogroup updates-6.x-to-7.x"
*/
......@@ -170,12 +170,9 @@ function field_schema() {
/**
* Utility function: create a field by writing directly to the database.
*
* This function can be used for databases whose schema is at field module
* version 7000 or higher.
*
* @ingroup update-api-6.x-to-7.x
* @ingroup update-api-7.x-to-8.x
*/
function _update_7000_field_create_field(&$field) {
function _update_8000_field_create_field(&$field) {
// Merge in default values.`
$field += array(
'entity_types' => array(),
......@@ -246,17 +243,14 @@ function _update_7000_field_create_field(&$field) {
* To protect user data, this function can only be used to delete fields once
* all information it stored is gone. Delete all data from the
* field_data_$field_name table before calling by either manually issuing
* delete queries against it or using _update_7000_field_delete_instance().
*
* This function can be used for databases whose schema is at field module
* version 7000 or higher.
* delete queries against it or using _update_8000_field_delete_instance().
*
* @param $field_name
* The field name to delete.
*
* @ingroup update-api-6.x-to-7.x
* @ingroup update-api-7.x-to-8.x
*/
function _update_7000_field_delete_field($field_name) {
function _update_8000_field_delete_field($field_name) {
$table_name = 'field_data_' . $field_name;
if (db_select($table_name)->range(0, 1)->countQuery()->execute()->fetchField()) {
$t = get_t();
......@@ -283,11 +277,9 @@ function _update_7000_field_delete_field($field_name) {
*
* BEWARE: this function deletes user data from the field storage tables.
*
* This function is valid for a database schema version 7000.
*
* @ingroup update-api-6.x-to-7.x
* @ingroup update-api-7.x-to-8.x
*/
function _update_7000_field_delete_instance($field_name, $entity_type, $bundle) {
function _update_8000_field_delete_instance($field_name, $entity_type, $bundle) {
// Delete field instance configuration data.
db_delete('field_config_instance')
->condition('field_name', $field_name)
......@@ -323,8 +315,9 @@ function _update_7000_field_delete_instance($field_name, $entity_type, $bundle)
* @return
* An array of fields matching $conditions, keyed by the property specified
* by the $key parameter.
* @ingroup update-api-7.x-to-8.x
*/
function _update_7000_field_read_fields(array $conditions = array(), $key = 'id') {
function _update_8000_field_read_fields(array $conditions = array(), $key = 'id') {
$fields = array();
$query = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC))
->fields('fc');
......@@ -354,12 +347,9 @@ function _update_7000_field_read_fields(array $conditions = array(), $key = 'id'
/**
* Utility function: write a field instance directly to the database.
*
* This function can be used for databases whose schema is at field module
* version 7000 or higher.
*
* @ingroup update-api-6.x-to-7.x
* @ingroup update-api-7.x-to-8.x
*/
function _update_7000_field_create_instance($field, &$instance) {
function _update_8000_field_create_instance($field, &$instance) {
// Merge in defaults.
$instance += array(
'field_id' => $field['id'],
......@@ -385,55 +375,3 @@ function _update_7000_field_create_instance($field, &$instance) {
->fields($record)
->execute();
}
/**
* @addtogroup updates-6.x-to-7.x
* @{
*/
/**
* Field update version placeholder.
*/
function field_update_7000() {
// Some update helper functions (such as _update_7000_field_create_field())
// modify the database directly. They can be used safely only if the database
// schema matches the field module schema established for Drupal 7.0 (i.e.
// version 7000). This function exists solely to set the schema version to
// 7000, so that update functions calling those helpers can do so safely
// by declaring a dependency on field_update_7000().
}
/**
* Fix fields definitions created during the d6 to d7 upgrade path.
*/
function field_update_7001() {
$fields = _update_7000_field_read_fields();
foreach ($fields as $field) {
// _update_7000_field_create_field() was broken in d7 RC2, and the fields
// created during a d6 to d7 upgrade do not correcly store the 'index'
// entry. See http://drupal.org/node/996160.
module_load_install($field['module']);
$schema = (array) module_invoke($field['module'], 'field_schema', $field);
$schema += array('indexes' => array());
// 'indexes' can be both hardcoded in the field type, and specified in the
// incoming $field definition.
$field['indexes'] += $schema['indexes'];
// Place the updated entries in the existing serialized 'data' column.
$data = db_query("SELECT data FROM {field_config} WHERE id = :id", array(':id' => $field['id']))->fetchField();
$data = unserialize($data);
$data['columns'] = $field['columns'];
$data['indexes'] = $field['indexes'];
// Save the new data.
$query = db_update('field_config')
->condition('id', $field['id'])
->fields(array('data' => serialize($data)))
->execute();
}
}
/**
* @} End of "addtogroup updates-6.x-to-7.x"
*/
......@@ -27,12 +27,9 @@ function field_sql_storage_schema() {
/**
* Utility function: write field data directly to SQL storage.
*
* This function can be used for databases whose schema is at field module
* version 7000 or higher.
*
* @ingroup update-api-6.x-to-7.x
* @ingroup update-api-7.x-to-8.x
*/
function _update_7000_field_sql_storage_write($entity_type, $bundle, $entity_id, $revision_id, $field_name, $data) {
function _update_8000_field_sql_storage_write($entity_type, $bundle, $entity_id, $revision_id, $field_name, $data) {
$table_name = "field_data_{$field_name}";
$revision_name = "field_revision_{$field_name}";
......@@ -80,136 +77,3 @@ function _update_7000_field_sql_storage_write($entity_type, $bundle, $entity_id,
$revision_query->execute();
}
}
/**
* @addtogroup updates-6.x-to-7.x
* @{
*/
/**
* Field SQL storage update version placeholder.
*/
function field_sql_storage_update_7000() {
// Some update helper functions (such as
// _update_7000_field_sql_storage_write()) modify the database directly. They
// can be used safely only if the database schema matches the field module
// schema established for Drupal 7.0 (i.e. version 7000). This function exists
// solely to set the schema version to 7000, so that update functions calling
// those helpers can do so safely by declaring a dependency on
// field_sql_storage_update_7000().
}
/**
* Remove the field_config_entity_type table and store 'entity_type' strings.
*/
function field_sql_storage_update_7001(&$sandbox) {
if (!isset($sandbox['progress'])) {
// Collect current etids.
$sandbox['etids'] = db_query('SELECT etid, type FROM {field_config_entity_type}')->fetchAllKeyed();
// Collect affected tables: field data, field revision data, 'deleted'
// tables.
$sandbox['tables'] = array();
$results = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC))
->fields('fc')
->condition('storage_module', 'field_sql_storage')
->execute();
foreach ($results as $field) {
if ($field['deleted']) {
$sandbox['tables']["field_deleted_data_{$field['id']}"] = 'data';
$sandbox['tables']["field_deleted_revision_{$field['id']}"] = 'revision';
}
else {
$sandbox['tables']["field_data_{$field['field_name']}"] = 'data';
$sandbox['tables']["field_revision_{$field['field_name']}"] = 'revision';
}
}
reset($sandbox['tables']);
$sandbox['total'] = count($sandbox['tables']);
$sandbox['progress'] = 0;
}
if ($sandbox['tables']) {
// Grab the next table to process.
$table = key($sandbox['tables']);
$type = array_shift($sandbox['tables']);
if (db_table_exists($table)) {
// Add the 'entity_type' column.
if (!db_field_exists($table, 'entity_type')) {
$column = array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'The entity type this data is attached to.',
);
db_add_field($table, 'entity_type', $column);
// Populate the 'entity_type' column based on the 'etid' column.
foreach ($sandbox['etids'] as $etid => $entity_type) {
db_update($table)
->fields(array('entity_type' => $entity_type))
->condition('etid', $etid)
->execute();
}
// Index the new column.
db_add_index($table, 'entity_type', array('entity_type'));
}
// Use the 'entity_type' column in the primary key.
db_drop_primary_key($table);
$primary_keys = array(
'data' => array('entity_type', 'entity_id', 'deleted', 'delta', 'language'),
'revision' => array('entity_type', 'entity_id', 'revision_id', 'deleted', 'delta', 'language'),
);
db_add_primary_key($table, $primary_keys[$type]);
// Drop the 'etid' column.
if (db_field_exists($table, 'etid')) {
db_drop_field($table, 'etid');
}
}
// Report progress.
$sandbox['progress']++;
$sandbox['#finished'] = min(0.99, $sandbox['progress'] / $sandbox['total']);
}
else {
// No more tables left: drop the field_config_entity_type table.
db_drop_table('field_config_entity_type');
// Drop the previous 'field_sql_storage_ENTITYTYPE_etid' system variables.
foreach ($sandbox['etids'] as $etid => $entity_type) {
variable_del('field_sql_storage_' . $entity_type . '_etid');
}
// We're done.
$sandbox['#finished'] = 1;
}
}
/**