From 9fb0fc069192b306c3eff0408c2a9c5a9e449fc9 Mon Sep 17 00:00:00 2001 From: Nathan Haug Date: Fri, 18 Mar 2011 00:12:14 -0700 Subject: [PATCH 1/3] drupal_core_remove_7x_updates --- includes/password.inc | 5 +- includes/update.inc | 708 +----------- modules/aggregator/aggregator.install | 28 - modules/block/block.install | 278 ----- modules/comment/comment.install | 442 ------- modules/contact/contact.install | 60 - modules/dblog/dblog.install | 43 - modules/field/field.install | 84 +-- .../field_sql_storage/field_sql_storage.install | 140 +--- modules/field/modules/list/list.install | 83 -- modules/field/modules/text/text.install | 41 - modules/filter/filter.install | 344 ------ modules/forum/forum.install | 96 -- modules/image/image.install | 138 --- modules/locale/locale.install | 341 ------ modules/node/node.install | 386 +------ modules/poll/poll.install | 49 - modules/profile/profile.install | 20 - modules/search/search.install | 27 - modules/simpletest/tests/update.test | 30 +- modules/simpletest/tests/update_test_1.install | 20 +- modules/simpletest/tests/update_test_2.install | 32 +- modules/simpletest/tests/update_test_3.install | 8 +- modules/statistics/statistics.install | 22 - modules/system/system.api.php | 16 +- modules/system/system.install | 1270 +------------------- modules/taxonomy/taxonomy.install | 578 --------- modules/tracker/tracker.install | 107 -- modules/trigger/trigger.install | 17 - modules/update/update.install | 31 - modules/user/user.install | 521 -------- update.php | 12 +- 32 files changed, 109 insertions(+), 5868 deletions(-) diff --git includes/password.inc includes/password.inc index 93d34f8..13659f8 100644 --- includes/password.inc +++ includes/password.inc @@ -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. diff --git includes/update.inc includes/update.inc index 1eb7a1d..f5a4275 100644 --- includes/update.inc +++ includes/update.inc @@ -68,45 +68,17 @@ function update_check_incompatibility($name, $type = 'module') { } /** - * Performs extra steps required to bootstrap when using a Drupal 6 database. + * Performs extra steps required to bootstrap when using a Drupal 7 database. * - * Users who still have a Drupal 6 database (and are in the process of - * updating to Drupal 7) need extra help before a full bootstrap can be + * Users who still have a Drupal 7 database (and are in the process of + * updating to Drupal 8) need extra help before a full bootstrap can be * achieved. This function does the necessary preliminary work that allows * the bootstrap to be successful. * * No access check has been performed when this function is called, so no * irreversible changes to the database are made here. */ -function update_prepare_d7_bootstrap() { - // Allow the bootstrap to proceed even if a Drupal 6 settings.php file is - // still being used. - include_once DRUPAL_ROOT . '/includes/install.inc'; - drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); - global $databases, $db_url, $db_prefix, $update_rewrite_settings; - if (empty($databases) && !empty($db_url)) { - $databases = update_parse_db_url($db_url, $db_prefix); - // Record the fact that the settings.php file will need to be rewritten. - $update_rewrite_settings = TRUE; - $settings_file = conf_path() . '/settings.php'; - $writable = drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_WRITABLE); - $requirements = array( - 'settings file' => array( - 'title' => 'Settings file', - 'value' => $writable ? 'The settings file is writable.' : 'The settings file is not writable.', - 'severity' => $writable ? REQUIREMENT_OK : REQUIREMENT_ERROR, - 'description' => $writable ? '' : 'Drupal requires write permissions to ' . $settings_file . ' during the update process. If you are unsure how to grant file permissions, consult the online handbook.', - ), - ); - update_extra_requirements($requirements); - } - - // The new {blocked_ips} table is used in Drupal 7 to store a list of - // banned IP addresses. If this table doesn't exist then we are still - // running on a Drupal 6 database, so we suppress the unavoidable errors - // that occur by creating a static list. - $GLOBALS['conf']['blocked_ips'] = array(); - +function update_prepare_d8_bootstrap() { // Check that PDO is available and that the correct PDO database driver is // loaded. Bootstrapping to DRUPAL_BOOTSTRAP_DATABASE will result in a fatal // error otherwise. @@ -144,14 +116,14 @@ function update_prepare_d7_bootstrap() { // to happen AFTER the database bootstraps because of // drupal_get_installed_schema_version(). $system_schema = drupal_get_installed_schema_version('system'); - if ($system_schema < 7000) { - $has_required_schema = $system_schema >= REQUIRED_D6_SCHEMA_VERSION; + if ($system_schema < 8000) { + $has_required_schema = $system_schema >= REQUIRED_D7_SCHEMA_VERSION; $requirements = array( - 'drupal 6 version' => array( - 'title' => 'Drupal 6 version', - 'value' => $has_required_schema ? 'You are running a current version of Drupal 6.' : 'You are not running a current version of Drupal 6', + 'drupal 7 version' => array( + 'title' => 'Drupal 7 version', + 'value' => $has_required_schema ? 'You are running a current version of Drupal 7.' : 'You are not running a current version of Drupal 7', 'severity' => $has_required_schema ? REQUIREMENT_OK : REQUIREMENT_ERROR, - 'description' => $has_required_schema ? '' : 'Please update your Drupal 6 installation to the most recent version before attempting to upgrade to Drupal 7', + 'description' => $has_required_schema ? '' : 'Please update your Drupal 7 installation to the most recent version before attempting to upgrade to Drupal 8', ), ); @@ -169,602 +141,37 @@ function update_prepare_d7_bootstrap() { } update_extra_requirements($requirements); - - // Allow a D6 session to work, since the upgrade has not been performed yet. - $d6_session_name = update_get_d6_session_name(); - if (!empty($_COOKIE[$d6_session_name])) { - // Set the current sid to the one found in the D6 cookie. - $sid = $_COOKIE[$d6_session_name]; - $_COOKIE[session_name()] = $sid; - session_id($sid); - } - } - - // Create the registry tables. - if (!db_table_exists('registry')) { - $schema['registry'] = array( - 'fields' => array( - 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), - 'type' => array('type' => 'varchar', 'length' => 9, 'not null' => TRUE, 'default' => ''), - 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), - 'module' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), - 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), - ), - 'primary key' => array('name', 'type'), - 'indexes' => array( - 'hook' => array('type', 'weight', 'module'), - ), - ); - db_create_table('registry', $schema['registry']); - } - if (!db_table_exists('registry_file')) { - $schema['registry_file'] = array( - 'fields' => array( - 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE), - 'hash' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE), - ), - 'primary key' => array('filename'), - ); - db_create_table('registry_file', $schema['registry_file']); - } - - // Older versions of Drupal 6 do not include the semaphore table, which is - // required to bootstrap, so we add it now so that we can bootstrap and - // provide a reasonable error message. - if (!db_table_exists('semaphore')) { - $semaphore = array( - 'description' => 'Table for holding semaphores, locks, flags, etc. that cannot be stored as Drupal variables since they must not be cached.', - 'fields' => array( - 'name' => array( - 'description' => 'Primary Key: Unique name.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '' - ), - 'value' => array( - 'description' => 'A value for the semaphore.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '' - ), - 'expire' => array( - 'description' => 'A Unix timestamp with microseconds indicating when the semaphore should expire.', - 'type' => 'float', - 'size' => 'big', - 'not null' => TRUE - ), - ), - 'indexes' => array( - 'value' => array('value'), - 'expire' => array('expire'), - ), - 'primary key' => array('name'), - ); - db_create_table('semaphore', $semaphore); - } - - // The new cache_bootstrap bin is required to bootstrap to - // DRUPAL_BOOTSTRAP_SESSION, so create it here rather than in - // update_fix_d7_requirements(). - if (!db_table_exists('cache_bootstrap')) { - $cache_bootstrap = array( - 'description' => 'Cache table for data required to bootstrap Drupal, may be routed to a shared memory cache.', - 'fields' => array( - 'cid' => array( - 'description' => 'Primary Key: Unique cache ID.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'data' => array( - 'description' => 'A collection of data to cache.', - 'type' => 'blob', - 'not null' => FALSE, - 'size' => 'big', - ), - 'expire' => array( - 'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'created' => array( - 'description' => 'A Unix timestamp indicating when the cache entry was created.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'serialized' => array( - 'description' => 'A flag to indicate whether content is serialized (1) or not (0).', - 'type' => 'int', - 'size' => 'small', - 'not null' => TRUE, - 'default' => 0, - ), - ), - 'indexes' => array( - 'expire' => array('expire'), - ), - 'primary key' => array('cid'), - ); - db_create_table('cache_bootstrap', $cache_bootstrap); - } - - // Set a valid timezone for 6 -> 7 upgrade process. - drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES); - $timezone_offset = variable_get('date_default_timezone', 0); - if (is_numeric($timezone_offset)) { - // Save the original offset. - variable_set('date_temporary_timezone', $timezone_offset); - // Set the timezone for this request only. - $GLOBALS['conf']['date_default_timezone'] = 'UTC'; - } -} - -/** - * A helper function that modules can use to assist with the transformation - * from numeric block deltas to string block deltas during the 6.x -> 7.x - * upgrade. - * - * @todo This function should be removed in 8.x. - * - * @param $sandbox - * An array holding data for the batch process. - * @param $renamed_deltas - * An associative array. Keys are module names, values an associative array - * mapping the old block deltas to the new block deltas for the module. - * Example: - * @code - * $renamed_deltas = array( - * 'mymodule' => - * array( - * 0 => 'mymodule-block-1', - * 1 => 'mymodule-block-2', - * ), - * ); - * @endcode - * @param $moved_deltas - * An associative array. Keys are source module names, values an associative - * array mapping the (possibly renamed) block name to the new module name. - * Example: - * @code - * $moved_deltas = array( - * 'user' => - * array( - * 'navigation' => 'system', - * ), - * ); - * @endcode - */ -function update_fix_d7_block_deltas(&$sandbox, $renamed_deltas, $moved_deltas) { - // Loop through each block and make changes to the block tables. - // Only run this the first time through the batch update. - if (!isset($sandbox['progress'])) { - // Determine whether to use the old or new block table names. - $block_tables = db_table_exists('blocks') ? array('blocks', 'blocks_roles') : array('block', 'block_role'); - foreach ($block_tables as $table) { - foreach ($renamed_deltas as $module => $deltas) { - foreach ($deltas as $old_delta => $new_delta) { - // Only do the update if the old block actually exists. - $block_exists = db_query("SELECT COUNT(*) FROM {" . $table . "} WHERE module = :module AND delta = :delta", array( - ':module' => $module, - ':delta' => $old_delta, - )) - ->fetchField(); - if ($block_exists) { - db_update($table) - ->fields(array('delta' => $new_delta)) - ->condition('module', $module) - ->condition('delta', $old_delta) - ->execute(); - } - } - } - foreach ($moved_deltas as $old_module => $deltas) { - foreach ($deltas as $delta => $new_module) { - // Only do the update if the old block actually exists. - $block_exists = db_query("SELECT COUNT(*) FROM {" . $table . "} WHERE module = :module AND delta = :delta", array( - ':module' => $old_module, - ':delta' => $delta, - )) - ->fetchField(); - if ($block_exists) { - db_update($table) - ->fields(array('module' => $new_module)) - ->condition('module', $old_module) - ->condition('delta', $delta) - ->execute(); - } - } - } - } - - // Initialize batch update information. - $sandbox['progress'] = 0; - $sandbox['last_user_processed'] = -1; - $sandbox['max'] = db_query("SELECT COUNT(*) FROM {users} WHERE data IS NOT NULL")->fetchField(); - } - // Now do the batch update of the user-specific block visibility settings. - $limit = 100; - $result = db_select('users', 'u') - ->fields('u', array('uid', 'data')) - ->condition('uid', $sandbox['last_user_processed'], '>') - ->orderBy('uid', 'ASC') - ->where('data IS NOT NULL') - ->range(0, $limit) - ->execute(); - foreach ($result as $row) { - $data = unserialize($row->data); - $user_needs_update = FALSE; - foreach ($renamed_deltas as $module => $deltas) { - foreach ($deltas as $old_delta => $new_delta) { - if (isset($data['block'][$module][$old_delta])) { - // Transfer the old block visibility settings to the newly-renamed - // block, and mark this user for a database update. - $data['block'][$module][$new_delta] = $data['block'][$module][$old_delta]; - unset($data['block'][$module][$old_delta]); - $user_needs_update = TRUE; - } - } - } - foreach ($moved_deltas as $old_module => $deltas) { - foreach ($deltas as $delta => $new_module) { - if (isset($data['block'][$old_module][$delta])) { - // Transfer the old block visibility settings to the moved - // block, and mark this user for a database update. - $data['block'][$new_module][$delta] = $data['block'][$old_module][$delta]; - unset($data['block'][$old_module][$delta]); - $user_needs_update = TRUE; - } - } - } - // Update the current user. - if ($user_needs_update) { - db_update('users') - ->fields(array('data' => serialize($data))) - ->condition('uid', $row->uid) - ->execute(); - } - // Update our progress information for the batch update. - $sandbox['progress']++; - $sandbox['last_user_processed'] = $row->uid; - } - // Indicate our current progress to the batch update system. - if ($sandbox['progress'] < $sandbox['max']) { - $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; } } /** - * Perform Drupal 6.x to 7.x updates that are required for update.php + * Perform Drupal 7.x to 8.x updates that are required for update.php * to function properly. * - * This function runs when update.php is run the first time for 7.x, + * This function runs when update.php is run the first time for 8.x, * even before updates are selected or performed. It is important * that if updates are not ultimately performed that no changes are * made which make it impossible to continue using the prior version. */ -function update_fix_d7_requirements() { +function update_fix_d8_requirements() { global $conf; - // Rewrite the settings.php file if necessary, see - // update_prepare_d7_bootstrap(). - global $update_rewrite_settings, $db_url, $db_prefix; - if (!empty($update_rewrite_settings)) { - $databases = update_parse_db_url($db_url, $db_prefix); - $salt = drupal_hash_base64(drupal_random_bytes(55)); - file_put_contents(conf_path() . '/settings.php', "\n" . '$databases = ' . var_export($databases, TRUE) . ";\n\$drupal_hash_salt = '$salt';", FILE_APPEND); + if (drupal_get_installed_schema_version('system') < 8000 && !variable_get('update_d8_requirements', FALSE)) { + // @todo: Make critical, first-run changes to the database here. + variable_set('update_d8_requirements', TRUE); } - if (drupal_get_installed_schema_version('system') < 7000 && !variable_get('update_d7_requirements', FALSE)) { - // Change 6.x system table field values to 7.x equivalent. - // Change field values. - db_change_field('system', 'schema_version', 'schema_version', array( - 'type' => 'int', - 'size' => 'small', - 'not null' => TRUE, - 'default' => -1) - ); - db_change_field('system', 'status', 'status', array( - 'type' => 'int', 'not null' => TRUE, 'default' => 0)); - db_change_field('system', 'weight', 'weight', array( - 'type' => 'int', 'not null' => TRUE, 'default' => 0)); - db_change_field('system', 'bootstrap', 'bootstrap', array( - 'type' => 'int', 'not null' => TRUE, 'default' => 0)); - // Drop and recreate 6.x indexes. - db_drop_index('system', 'bootstrap'); - db_add_index('system', 'bootstrap', array( - 'status', 'bootstrap', array('type', 12), 'weight', 'name')); - db_drop_index('system' ,'modules'); - db_add_index('system', 'modules', array(array( - 'type', 12), 'status', 'weight', 'name')); - - db_drop_index('system', 'type_name'); - db_add_index('system', 'type_name', array(array('type', 12), 'name')); - // Add 7.x indexes. - db_add_index('system', 'system_list', array('weight', 'name')); - - // Add the cache_path table. - if (db_table_exists('cache_path')) { - db_drop_table('cache_path'); - } - require_once('./modules/system/system.install'); - $schema['cache_path'] = system_schema_cache_7054(); - $schema['cache_path']['description'] = 'Cache table used for path alias lookups.'; - db_create_table('cache_path', $schema['cache_path']); - - // system_update_7042() renames columns, but these are needed to bootstrap. - // Add empty columns for now. - db_add_field('url_alias', 'source', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')); - db_add_field('url_alias', 'alias', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')); - - // Add new columns to {menu_router}. - db_add_field('menu_router', 'delivery_callback', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')); - db_add_field('menu_router', 'context', array( - 'description' => 'Only for local tasks (tabs) - the context of a local task to control its placement.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - )); - db_drop_index('menu_router', 'tab_parent'); - db_add_index('menu_router', 'tab_parent', array(array('tab_parent', 64), 'weight', 'title')); - db_add_field('menu_router', 'theme_callback', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')); - db_add_field('menu_router', 'theme_arguments', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')); - - // Add the role_permission table. - $schema['role_permission'] = array( - 'fields' => array( - 'rid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'permission' => array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - ), - ), - 'primary key' => array('rid', 'permission'), - 'indexes' => array( - 'permission' => array('permission'), - ), - ); - db_create_table('role_permission', $schema['role_permission']); - - // Drops and recreates semaphore value index. - db_drop_index('semaphore', 'value'); - db_add_index('semaphore', 'value', array('value')); - - $schema['date_format_type'] = array( - 'description' => 'Stores configured date format types.', - 'fields' => array( - 'type' => array( - 'description' => 'The date format type, e.g. medium.', - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - ), - 'title' => array( - 'description' => 'The human readable name of the format type.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - ), - 'locked' => array( - 'description' => 'Whether or not this is a system provided format.', - 'type' => 'int', - 'size' => 'tiny', - 'default' => 0, - 'not null' => TRUE, - ), - ), - 'primary key' => array('type'), - ); - - $schema['date_formats'] = array( - 'description' => 'Stores configured date formats.', - 'fields' => array( - 'dfid' => array( - 'description' => 'The date format identifier.', - 'type' => 'serial', - 'not null' => TRUE, - 'unsigned' => TRUE, - ), - 'format' => array( - 'description' => 'The date format string.', - 'type' => 'varchar', - 'length' => 100, - 'not null' => TRUE, - ), - 'type' => array( - 'description' => 'The date format type, e.g. medium.', - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - ), - 'locked' => array( - 'description' => 'Whether or not this format can be modified.', - 'type' => 'int', - 'size' => 'tiny', - 'default' => 0, - 'not null' => TRUE, - ), - ), - 'primary key' => array('dfid'), - 'unique keys' => array('formats' => array('format', 'type')), - ); - - $schema['date_format_locale'] = array( - 'description' => 'Stores configured date formats for each locale.', - 'fields' => array( - 'format' => array( - 'description' => 'The date format string.', - 'type' => 'varchar', - 'length' => 100, - 'not null' => TRUE, - ), - 'type' => array( - 'description' => 'The date format type, e.g. medium.', - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - ), - 'language' => array( - 'description' => 'A {languages}.language for this format to be used with.', - 'type' => 'varchar', - 'length' => 12, - 'not null' => TRUE, - ), - ), - 'primary key' => array('type', 'language'), - ); - - db_create_table('date_format_type', $schema['date_format_type']); - // Sites that have the Drupal 6 Date module installed already have the - // following tables. - if (db_table_exists('date_formats')) { - db_rename_table('date_formats', 'd6_date_formats'); - } - db_create_table('date_formats', $schema['date_formats']); - if (db_table_exists('date_format_locale')) { - db_rename_table('date_format_locale', 'd6_date_format_locale'); - } - db_create_table('date_format_locale', $schema['date_format_locale']); - - // Add the queue table. - $schema['queue'] = array( - 'description' => 'Stores items in queues.', - 'fields' => array( - 'item_id' => array( - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'description' => 'Primary Key: Unique item ID.', - ), - 'name' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - 'description' => 'The queue name.', - ), - 'data' => array( - 'type' => 'blob', - 'not null' => FALSE, - 'size' => 'big', - 'serialize' => TRUE, - 'description' => 'The arbitrary data for the item.', - ), - 'expire' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Timestamp when the claim lease expires on the item.', - ), - 'created' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Timestamp when the item was created.', - ), - ), - 'primary key' => array('item_id'), - 'indexes' => array( - 'name_created' => array('name', 'created'), - 'expire' => array('expire'), - ), - ); - // Check for queue table that may remain from D5 or D6, if found - //drop it. - if (db_table_exists('queue')) { - db_drop_table('queue'); - } - - db_create_table('queue', $schema['queue']); - - // Create the sequences table. - $schema['sequences'] = array( - 'description' => 'Stores IDs.', - 'fields' => array( - 'value' => array( - 'description' => 'The value of the sequence.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - ), - 'primary key' => array('value'), - ); - // Check for sequences table that may remain from D5 or D6, if found - //drop it. - if (db_table_exists('sequences')) { - db_drop_table('sequences'); - } - db_create_table('sequences', $schema['sequences']); - // Initialize the table with the maximum current increment of the tables - // that will rely on it for their ids. - $max_aid = db_query('SELECT MAX(aid) FROM {actions_aid}')->fetchField(); - $max_uid = db_query('SELECT MAX(uid) FROM {users}')->fetchField(); - $max_batch_id = db_query('SELECT MAX(bid) FROM {batch}')->fetchField(); - db_insert('sequences')->fields(array('value' => max($max_aid, $max_uid, $max_batch_id)))->execute(); - - // Add column for locale context. - if (db_table_exists('locales_source')) { - db_add_field('locales_source', 'context', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => 'The context this string applies to.')); - } - - // Rename 'site_offline_message' variable to 'maintenance_mode_message' - // and 'site_offline' variable to 'maintenance_mode'. - // Old variable is removed in update for system.module, see - // system_update_7036(). - if ($message = variable_get('site_offline_message', NULL)) { - variable_set('maintenance_mode_message', $message); - } - // Old variable is removed in update for system.module, see - // system_update_7069(). - $site_offline = variable_get('site_offline', -1); - if ($site_offline != -1) { - variable_set('maintenance_mode', $site_offline); - } - - // Add ssid column and index. - db_add_field('sessions', 'ssid', array('description' => "Secure session ID. The value is generated by Drupal's session handlers.", 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '')); - db_add_index('sessions', 'ssid', array('ssid')); - // Drop existing primary key. - db_drop_primary_key('sessions'); - // Add new primary key. - db_add_primary_key('sessions', array('sid', 'ssid')); - - // Allow longer javascript file names. - if (db_table_exists('languages')) { - db_change_field('languages', 'javascript', 'javascript', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '')); - } - - // Rename action description to label. - db_change_field('actions', 'description', 'label', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '0')); - - variable_set('update_d7_requirements', TRUE); - } - - update_fix_d7_install_profile(); + update_fix_d8_install_profile(); } /** * Register the currently installed profile in the system table. * - * Install profiles are now treated as modules by Drupal, and have an upgrade - * path based on their schema version in the system table. - * * The install profile will be set to schema_version 0, as it has already been * installed. Any other hook_update_N functions provided by the install profile * will be run by update.php. */ -function update_fix_d7_install_profile() { +function update_fix_d8_install_profile() { $profile = drupal_get_profile(); $results = db_select('system', 's') @@ -821,67 +228,6 @@ function update_fix_d7_install_profile() { } /** - * Parse pre-Drupal 7 database connection URLs and return D7 compatible array. - * - * @return - * Drupal 7 DBTNG compatible array of database connection information. - */ -function update_parse_db_url($db_url, $db_prefix) { - $databases = array(); - if (!is_array($db_url)) { - $db_url = array('default' => $db_url); - } - foreach ($db_url as $database => $url) { - $url = parse_url($url); - $databases[$database]['default'] = array( - // MySQLi uses the mysql driver. - 'driver' => $url['scheme'] == 'mysqli' ? 'mysql' : $url['scheme'], - // Remove the leading slash to get the database name. - 'database' => substr(urldecode($url['path']), 1), - 'username' => urldecode($url['user']), - 'password' => isset($url['pass']) ? urldecode($url['pass']) : '', - 'host' => urldecode($url['host']), - 'port' => isset($url['port']) ? urldecode($url['port']) : '', - ); - if (isset($db_prefix)) { - $databases[$database]['default']['prefix'] = $db_prefix; - } - } - return $databases; -} - -/** - * Constructs a session name compatible with a D6 environment. - * - * @return - * D6-compatible session name string. - * - * @see drupal_settings_initialize() - */ -function update_get_d6_session_name() { - global $base_url, $cookie_domain; - $cookie_secure = ini_get('session.cookie_secure'); - - // If a custom cookie domain is set in settings.php, that variable forms - // the basis of the session name. Re-compute the D7 hashing method to find - // out if $cookie_domain was used as the session name. - if (($cookie_secure ? 'SSESS' : 'SESS') . substr(hash('sha256', $cookie_domain), 0, 32) == session_name()) { - $session_name = $cookie_domain; - } - else { - // Otherwise use $base_url as session name, without the protocol - // to use the same session identifiers across http and https. - list( , $session_name) = explode('://', $base_url, 2); - } - - if ($cookie_secure) { - $session_name .= 'SSL'; - } - - return 'SESS' . md5($session_name); -} - -/** * Perform one update and store the results for display on finished page. * * If an update function completes successfully, it should return a message @@ -1272,10 +618,10 @@ function update_get_update_function_list($starting_updates) { * requirement that the first update function needs to run before the second. * For example, consider this graph: * - * system_update_7000 ---> system_update_7001 ---> system_update_7002 + * system_update_8000 ---> system_update_8001 ---> system_update_8002 * - * Visually, this indicates that system_update_7000() must run before - * system_update_7001(), which in turn must run before system_update_7002(). + * Visually, this indicates that system_update_8000() must run before + * system_update_8001(), which in turn must run before system_update_8002(). * * The function takes into account standard dependencies within each module, as * shown above (i.e., the fact that each module's updates must run in numerical @@ -1422,15 +768,15 @@ function update_retrieve_dependencies() { // implementation of hook_update_dependencies() required this // ordering: // - // system_update_7001 ---> user_update_7000 + // system_update_8001 ---> user_update_8000 // // but another module's implementation of the hook required this // one: // - // system_update_7002 ---> user_update_7000 + // system_update_8002 ---> user_update_8000 // - // we record the second one, since system_update_7001() is always - // guaranteed to run before system_update_7002() anyway (within + // we record the second one, since system_update_8001() is always + // guaranteed to run before system_update_8002() anyway (within // an individual module, updates are always run in numerical // order). if (!isset($return[$module][$update][$module_dependency]) || $update_dependency > $return[$module][$update][$module_dependency]) { @@ -1447,7 +793,7 @@ function update_retrieve_dependencies() { } /** - * @defgroup update-api-6.x-to-7.x Update versions of API functions + * @defgroup update-api-7.x-to-8.x Update versions of API functions * @{ * Functions similar to normal API function but not firing hooks. * @@ -1457,5 +803,5 @@ function update_retrieve_dependencies() { */ /** - * @} End of "defgroup update-api-6.x-to-7.x" + * @} End of "defgroup update-api-7.x-to-8.x" */ diff --git modules/aggregator/aggregator.install modules/aggregator/aggregator.install index f19d7de..eecd14f 100644 --- modules/aggregator/aggregator.install +++ modules/aggregator/aggregator.install @@ -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')); -} - diff --git modules/block/block.install modules/block/block.install index f6dfb35..deed13a 100644 --- modules/block/block.install +++ modules/block/block.install @@ -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 custom block 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 custom block 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' => '', - 'cache' => DRUPAL_NO_CACHE, - )); - } - drupal_set_message('The site mission was migrated to a custom block 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 relocate the block.'); - $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 custom block 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 relocate the block.'); - $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" - */ diff --git modules/comment/comment.install modules/comment/comment.install index aac9575..da70150 100644 --- modules/comment/comment.install +++ modules/comment/comment.install @@ -77,445 +77,3 @@ 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(). - */ -function comment_schema() { - $schema['comment'] = array( - 'description' => 'Stores comments and associated data.', - 'fields' => array( - 'cid' => array( - 'type' => 'serial', - 'not null' => TRUE, - 'description' => 'Primary Key: Unique comment ID.', - ), - 'pid' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The {comment}.cid to which this comment is a reply. If set to 0, this comment is not a reply to an existing comment.', - ), - 'nid' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The {node}.nid to which this comment is a reply.', - ), - 'uid' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The {users}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.', - ), - 'subject' => array( - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - 'default' => '', - 'description' => 'The comment title.', - ), - 'hostname' => array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - 'description' => "The author's host name.", - ), - 'created' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The time that the comment was created, as a Unix timestamp.', - ), - 'changed' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The time that the comment was last edited, as a Unix timestamp.', - ), - 'status' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 1, - 'size' => 'tiny', - 'description' => 'The published status of a comment. (0 = Not Published, 1 = Published)', - ), - 'thread' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'description' => "The vancode representation of the comment's place in a thread.", - ), - 'name' => array( - 'type' => 'varchar', - 'length' => 60, - 'not null' => FALSE, - 'description' => "The comment author's name. Uses {users}.name if the user is logged in, otherwise uses the value typed into the comment form.", - ), - 'mail' => array( - 'type' => 'varchar', - 'length' => 64, - 'not null' => FALSE, - 'description' => "The comment author's e-mail address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on.", - ), - 'homepage' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - 'description' => "The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on.", - ), - 'language' => array( - 'description' => 'The {languages}.language of this comment.', - 'type' => 'varchar', - 'length' => 12, - 'not null' => TRUE, - 'default' => '', - ), - ), - 'indexes' => array( - 'comment_status_pid' => array('pid', 'status'), - 'comment_num_new' => array('nid', 'status', 'created', 'cid', 'thread'), - 'comment_uid' => array('uid'), - 'comment_nid_language' => array('nid', 'language'), - ), - 'primary key' => array('cid'), - 'foreign keys' => array( - 'comment_node' => array( - 'table' => 'node', - 'columns' => array('nid' => 'nid'), - ), - 'comment_author' => array( - 'table' => 'users', - 'columns' => array('uid' => 'uid'), - ), - ), - ); - - $schema['node_comment_statistics'] = array( - 'description' => 'Maintains statistics of node and comments posts to show "new" and "updated" flags.', - 'fields' => array( - 'nid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The {node}.nid for which the statistics are compiled.', - ), - 'cid' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The {comment}.cid of the last comment.', - ), - 'last_comment_timestamp' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.timestamp.', - ), - 'last_comment_name' => array( - 'type' => 'varchar', - 'length' => 60, - 'not null' => FALSE, - 'description' => 'The name of the latest author to post a comment on this node, from {comment}.name.', - ), - 'last_comment_uid' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The user ID of the latest author to post a comment on this node, from {comment}.uid.', - ), - 'comment_count' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The total number of comments on this node.', - ), - ), - 'primary key' => array('nid'), - 'indexes' => array( - 'node_comment_timestamp' => array('last_comment_timestamp'), - 'comment_count' => array('comment_count'), - 'last_comment_uid' => array('last_comment_uid'), - ), - 'foreign keys' => array( - 'statistics_node' => array( - 'table' => 'node', - 'columns' => array('nid' => 'nid'), - ), - 'last_comment_author' => array( - 'table' => 'users', - 'columns' => array( - 'last_comment_uid' => 'uid', - ), - ), - ), - ); - - return $schema; -} diff --git modules/contact/contact.install modules/contact/contact.install index 6e8ec70..7ddea45 100644 --- modules/contact/contact.install +++ modules/contact/contact.install @@ -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" - */ diff --git modules/dblog/dblog.install modules/dblog/dblog.install index 759c7bc..23f85ba 100644 --- modules/dblog/dblog.install +++ modules/dblog/dblog.install @@ -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" - */ diff --git modules/field/field.install modules/field/field.install index d56eb90..2d7d28f 100644 --- modules/field/field.install +++ modules/field/field.install @@ -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" - */ diff --git modules/field/modules/field_sql_storage/field_sql_storage.install modules/field/modules/field_sql_storage/field_sql_storage.install index 647296e..930686d 100644 --- modules/field/modules/field_sql_storage/field_sql_storage.install +++ modules/field/modules/field_sql_storage/field_sql_storage.install @@ -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; - } -} - -/** - * Fix primary keys in field revision data tables. - */ -function field_sql_storage_update_7002() { - $results = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC)) - ->fields('fc') - ->condition('storage_module', 'field_sql_storage') - ->execute(); - foreach ($results as $field) { - // Revision tables of deleted fields do not need to be fixed, since no new - // data is written to them. - if (!$field['deleted']) { - $table = "field_revision_{$field['field_name']}"; - db_drop_primary_key($table); - db_add_primary_key($table, array('entity_type', 'entity_id', 'revision_id', 'deleted', 'delta', 'language')); - } - } -} - -/** - * @} End of "addtogroup updates-6.x-to-7.x" - */ diff --git modules/field/modules/list/list.install modules/field/modules/list/list.install index 91c7649..c86a219 100644 --- modules/field/modules/list/list.install +++ modules/field/modules/list/list.install @@ -44,86 +44,3 @@ function list_field_schema($field) { ), ); } - -/** - * Rename the list field types and change 'allowed_values' format. - */ -function list_update_7001() { - $fields = _update_7000_field_read_fields(array('module' => 'list')); - foreach ($fields as $field) { - $update = array(); - - // Translate the old string format into the new array format. - $allowed_values = $field['settings']['allowed_values']; - if (is_string($allowed_values)) { - $position_keys = ($field['type'] == 'list'); - $allowed_values = _list_update_7001_extract_allowed_values($allowed_values, $position_keys); - - // Additionally, float keys need to be disambiguated ('.5' is '0.5'). - if ($field['type'] == 'list_number' && !empty($allowed_values)) { - $keys = array_map(create_function('$a', 'return (string) (float) $a;'), array_keys($allowed_values)); - $allowed_values = array_combine($keys, array_values($allowed_values)); - } - - // Place the new setting 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['settings']['allowed_values'] = $allowed_values; - $update['data'] = serialize($data); - } - - // Rename field types. - $types = array('list' => 'list_integer', 'list_number' => 'list_float'); - if (isset($types[$field['type']])) { - $update['type'] = $types[$field['type']]; - } - - // Save the new data. - if ($update) { - $query = db_update('field_config') - ->condition('id', $field['id']) - ->fields($update) - ->execute(); - } - } -} - -/** - * Helper function for list_update_7001: extract allowed values from a string. - * - * This reproduces the parsing logic in use before D7 RC2. - */ -function _list_update_7001_extract_allowed_values($string, $position_keys) { - $values = array(); - - $list = explode("\n", $string); - $list = array_map('trim', $list); - $list = array_filter($list, 'strlen'); - - foreach ($list as $key => $value) { - // Check for a manually specified key. - if (strpos($value, '|') !== FALSE) { - list($key, $value) = explode('|', $value); - } - // Otherwise see if we need to use the value as the key. The "list" type - // will automatically convert non-keyed lines to integers. - elseif (!$position_keys) { - $key = $value; - } - $values[$key] = (isset($value) && $value !== '') ? $value : $key; - } - - return $values; -} - -/** - * Re-apply list_update_7001() for deleted fields. - */ -function list_update_7002() { - // See http://drupal.org/node/1022924: list_update_7001() intitally - // overlooked deleted fields, which then caused fatal errors when the fields - // were being purged. - // list_update_7001() has the required checks to ensure it is reentrant, so - // it can simply be executed once more.. - list_update_7001(); -} \ No newline at end of file diff --git modules/field/modules/text/text.install modules/field/modules/text/text.install index b9bd25f..1b8d00b 100644 --- modules/field/modules/text/text.install +++ modules/field/modules/text/text.install @@ -65,44 +65,3 @@ function text_field_schema($field) { ), ); } - -/** - * Implements hook_update_dependencies(). - */ -function text_update_dependencies() { - // Ensure that format columns are only changed after Filter module has changed - // the primary records. - $dependencies['text'][7000] = array( - 'filter' => 7010, - ); - - return $dependencies; -} - -/** - * Change text field 'format' columns into varchar. - */ -function text_update_7000() { - $spec = array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - ); - $fields = _update_7000_field_read_fields(array( - 'module' => 'text', - 'storage_type' => 'field_sql_storage', - )); - foreach ($fields as $field) { - if ($field['deleted']) { - $table = "field_deleted_data_{$field['id']}"; - $revision_table = "field_deleted_revision_{$field['id']}"; - } - else { - $table = "field_data_{$field['field_name']}"; - $revision_table = "field_revision_{$field['field_name']}"; - } - $column = $field['field_name'] . '_' . 'format'; - db_change_field($table, $column, $column, $spec); - db_change_field($revision_table, $column, $column, $spec); - } -} diff --git modules/filter/filter.install modules/filter/filter.install index 84512cd..da9ecb8 100644 --- modules/filter/filter.install +++ modules/filter/filter.install @@ -147,347 +147,3 @@ function filter_install() { // Set the fallback format to plain text. variable_set('filter_fallback_format', $plain_text_format->format); } - -/** - * Implements hook_update_dependencies(). - */ -function filter_update_dependencies() { - // Filter update 7007 migrates permissions and therefore needs to run after - // the {role} table is properly set up. - $dependencies['filter'][7005] = array( - 'user' => 7007, - ); - - return $dependencies; -} -/** - * @addtogroup updates-6.x-to-7.x - * @{ - */ - -/** - * Upgrade the {filter_formats} table and rename it to {filter_format}. - */ -function filter_update_7000() { - db_rename_table('filter_formats', 'filter_format'); - - // Add the new {filter_format}.status and {filter_format}.weight column. - db_add_field('filter_format', 'status', array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 1, - 'size' => 'tiny', - 'description' => 'The status of the text format. (1 = enabled, 0 = disabled)', - )); - db_add_field('filter_format', 'weight', array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Weight of text format to use when listing.', - ), array( - 'indexes' => array( - 'status_weight' => array('status', 'weight'), - ), - )); -} - -/** - * Break out "escape HTML filter" option to its own filter. - */ -function filter_update_7001() { - $result = db_query("SELECT format FROM {filter_format}")->fetchCol(); - $insert = db_insert('filters')->fields(array('format', 'module', 'delta', 'weight')); - - foreach ($result as $format_id) { - // Deprecated constants FILTER_HTML_STRIP = 1 and FILTER_HTML_ESCAPE = 2. - if (variable_get('filter_html_' . $format_id, 1) == 2) { - $insert->values(array( - 'format' => $format_id, - 'module' => 'filter', - 'delta' => 4, - 'weight' => 0, - )); - } - variable_del('filter_html_' . $format_id); - } - - $insert->execute(); -} - -/** - * Upgrade the {filter} table for core filters. - */ -function filter_update_7003() { - // Duplicates the {filters} table since core cannot take care of the potential - // contributed module filters. - db_rename_table('filters', 'd6_upgrade_filter'); - // Creates the Drupal 7 filter table. - $filter_table = array( - 'description' => 'Table that maps filters (HTML corrector) to text formats (Filtered HTML).', - 'fields' => array( - 'format' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Foreign key: The {filter_format}.format to which this filter is assigned.', - ), - 'module' => array( - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - 'default' => '', - 'description' => 'The origin module of the filter.', - ), - 'name' => array( - 'type' => 'varchar', - 'length' => 32, - 'not null' => TRUE, - 'default' => '', - 'description' => 'Name of the filter being referenced.', - ), - 'weight' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Weight of filter within format.', - ), - 'status' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Filter enabled status. (1 = enabled, 0 = disabled)', - ), - 'settings' => array( - 'type' => 'blob', - 'not null' => FALSE, - 'size' => 'big', - 'serialize' => TRUE, - 'description' => 'A serialized array of name value pairs that store the filter settings for the specific format.', - ), - ), - 'primary key' => array('format', 'name'), - 'indexes' => array( - 'list' => array('weight', 'module', 'name'), - ), - ); - db_create_table('filter', $filter_table); - - // Get an array of the renamed filter deltas, organized by module. - $renamed_deltas = array( - 'filter' => array( - '0' => 'filter_html', - '1' => 'filter_autop', - '2' => 'filter_url', - '3' => 'filter_htmlcorrector', - '4' => 'filter_html_escape', - ), - 'php' => array( - '0' => 'php_code', - ), - ); - - // Loop through each filter and make changes to the core filter table by - // each record from the old to the new table. - foreach ($renamed_deltas as $module => $deltas) { - foreach ($deltas as $old_delta => $new_name) { - $query = db_select('d6_upgrade_filter') - ->fields('d6_upgrade_filter', array('format', 'weight')) - ->condition('module', $module) - ->condition('delta', $old_delta) - ->distinct(); - - foreach ($query->execute() as $record) { - // Port the filter settings. - $settings = array(); - if ($new_name == 'filter_html') { - if ($setting = variable_get("allowed_html_{$record->format}", NULL)) { - $settings['allowed_html'] = $setting; - variable_del("allowed_html_{$record->format}"); - } - if ($setting = variable_get("filter_html_help_{$record->format}", NULL)) { - $settings['filter_html_help'] = $setting; - variable_del("filter_html_help_{$record->format}"); - } - if ($setting = variable_get("filter_html_nofollow_{$record->format}", NULL)) { - $settings['filter_html_nofollow'] = $setting; - variable_del("filter_html_nofollow_{$record->format}"); - } - } - elseif ($new_name == 'filter_url') { - if ($setting = variable_get("filter_url_length_{$record->format}", NULL)) { - $settings['filter_url_length'] = $setting; - variable_del("filter_url_length_{$record->format}"); - } - } - - db_insert('filter') - ->fields(array( - 'format' => $record->format, - 'module' => $module, - 'name' => $new_name, - 'weight' => $record->weight, - 'settings' => serialize($settings), - 'status' => 1, - )) - ->execute(); - } - db_delete('d6_upgrade_filter') - ->condition('module', $module) - ->condition('delta', $old_delta) - ->execute(); - } - } -} - -/** - * Integrate text formats with the user permissions system. - * - * This function converts text format role assignments to use the new text - * format permissions introduced in Drupal 7, creates a fallback (plain text) - * format that is available to all users, and explicitly sets the text format - * in cases that used to rely on a single site-wide default. - */ -function filter_update_7005() { - // Move role data from the filter system to the user permission system. - $all_roles = array_keys(user_roles()); - $default_format = variable_get('filter_default_format', 1); - $result = db_query("SELECT * FROM {filter_format}"); - foreach ($result as $format) { - // We need to assign the default format to all roles (regardless of what - // was stored in the database) to preserve the behavior of the site at the - // moment of the upgrade. - $format_roles = ($format->format == $default_format ? $all_roles : explode(',', $format->roles)); - foreach ($format_roles as $format_role) { - if (in_array($format_role, $all_roles)) { - _update_7000_user_role_grant_permissions($format_role, array('use text format ' . $format->format), 'filter'); - } - } - } - - // Drop the roles field from the {filter_format} table. - db_drop_field('filter_format', 'roles'); - - // Add a fallback text format which outputs plain text and appears last on - // the list for all users. Generate a unique name for it, starting with - // "Plain text". - $start_name = 'Plain text'; - $format_name = $start_name; - while ($format = db_query('SELECT format FROM {filter_format} WHERE name = :name', array(':name' => $format_name))->fetchField()) { - $id = empty($id) ? 2 : $id + 1; - $format_name = $start_name . ' ' . $id; - } - - // Insert the filter format. - $format_id = db_insert('filter_format') - ->fields(array( - 'name' => $format_name, - 'cache' => 1, - 'weight' => 1, - 'status' => 1, - )) - ->execute(); - - // This format should output plain text, so we escape all HTML and apply the - // line break and URL filters only. - db_insert('filter') - ->fields(array( - 'format', - 'name', - 'weight', - 'status', - 'module', - 'settings', - )) - ->values(array( - 'format' => $format_id, - 'name' => 'filter_html_escape', - 'weight' => 0, - 'status' => 1, - 'module' => 'filter', - 'settings' => serialize(array()), - )) - ->values(array( - 'format' => $format_id, - 'name' => 'filter_url', - 'weight' => 1, - 'status' => 1, - 'module' => 'filter', - 'settings' => serialize(array()), - )) - ->values(array( - 'format' => $format_id, - 'name' => 'filter_autop', - 'weight' => 2, - 'status' => 1, - 'module' => 'filter', - 'settings' => serialize(array()), - )) - ->execute(); - - variable_set('filter_fallback_format', $format_id); - drupal_set_message('A new Plain text format has been created which will be available to all users. You can configure this text format on the text format configuration page.'); - - // Move the former site-wide default text format to the top of the list, so - // that it continues to be the default text format for all users. - db_update('filter_format') - ->fields(array('weight' => -1)) - ->condition('format', $default_format) - ->execute(); - - // We do not delete the 'filter_default_format' variable, since other modules - // need it in their update functions; for an example, see user_update_7010(). - // @todo This variable can be deleted in Drupal 8. -} - -/** - * Grant usage of all text formats to user roles having the 'administer filters' permission. - */ -function filter_update_7008() { - // Build the list of permissions to grant. - $permissions = array(); - foreach (db_query('SELECT format FROM {filter_format}')->fetchCol() as $format_id) { - if ($format_id != variable_get('filter_fallback_format')) { - $permissions[] = 'use text format ' . $format_id; - } - } - // Grant text format permissions to all roles that can 'administer filters'. - // Albeit anonymous users *should not* have the permission, we cannot presume - // that they do not or must not. - if ($roles = user_roles(FALSE, 'administer filters')) { - foreach ($roles as $rid => $name) { - _update_7000_user_role_grant_permissions($rid, $permissions, 'filter'); - } - } -} - -/** - * Converts fields that store serialized variables from text to blob. - */ -function filter_update_7009() { - $schema = system_schema_cache_7054(); - db_drop_table('cache_filter'); - db_create_table('cache_filter', $schema); -} - -/** - * Change {filter_format}.format and {filter}.format into varchar. - */ -function filter_update_7010() { - db_change_field('filter_format', 'format', 'format', array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'description' => 'Primary Key: Unique machine name of the format.', - )); - db_change_field('filter', 'format', 'format', array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'description' => 'Foreign key: The {filter_format}.format to which this filter is assigned.', - )); -} - -/** - * @} End of "addtogroup updates-6.x-to-7.x" - */ diff --git modules/forum/forum.install modules/forum/forum.install index fe30995..8e41be7 100644 --- modules/forum/forum.install +++ modules/forum/forum.install @@ -234,99 +234,3 @@ function forum_schema() { return $schema; } - -/** - * Add new index to forum table. - */ -function forum_update_7000() { - db_drop_index('forum', 'nid'); - db_add_index('forum', 'forum_topic', array('nid', 'tid')); -} - -/** - * Create new {forum_index} table. - */ -function forum_update_7001() { - $forum_index = array( - 'description' => 'Maintains denormalized information about node/term relationships.', - 'fields' => array( - 'nid' => array( - 'description' => 'The {node}.nid this record tracks.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'title' => array( - 'description' => 'The title of this node, always treated as non-markup plain text.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'tid' => array( - 'description' => 'The term ID.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'sticky' => array( - 'description' => 'Boolean indicating whether the node is sticky.', - 'type' => 'int', - 'not null' => FALSE, - 'default' => 0, - 'size' => 'tiny', - ), - 'created' => array( - 'description' => 'The Unix timestamp when the node was created.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default'=> 0, - ), - 'last_comment_timestamp' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.timestamp.', - ), - 'comment_count' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The total number of comments on this node.', - ), - ), - 'indexes' => array( - 'forum_topics' => array('tid', 'sticky', 'last_comment_timestamp'), - ), - 'foreign keys' => array( - 'tracked_node' => array( - 'table' => 'node', - 'columns' => array('nid' => 'nid'), - ), - 'term' => array( - 'table' => 'taxonomy_term_data', - 'columns' => array( - 'tid' => 'tid', - ), - ), - ), - ); - db_create_table('forum_index', $forum_index); - - $select = db_select('node', 'n'); - $forum_alias = $select->join('forum', 'f', 'n.vid = f.vid'); - $ncs_alias = $select->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid'); - $select - ->fields('n', array('nid', 'title', 'sticky', 'created')) - ->fields($forum_alias, array('tid')) - ->fields($ncs_alias, array('last_comment_timestamp', 'comment_count')); - - db_insert('forum_index') - ->fields(array('nid', 'title', 'sticky', 'created', 'tid', 'last_comment_timestamp', 'comment_count')) - ->from($select) - ->execute(); -} diff --git modules/image/image.install modules/image/image.install index fbd20de..fe69561 100644 --- modules/image/image.install +++ modules/image/image.install @@ -142,141 +142,3 @@ function image_field_schema($field) { ), ); } - -/** - * Install the schema for users upgrading from the contributed module. - */ -function image_update_7000() { - if (!db_table_exists('image_styles')) { - $schema = array(); - - $schema['cache_image'] = system_schema_cache_7054(); - $schema['cache_image']['description'] = 'Cache table used to store information about image manipulations that are in-progress.'; - - $schema['image_styles'] = array( - 'description' => 'Stores configuration options for image styles.', - 'fields' => array( - 'isid' => array( - 'description' => 'The primary identifier for an image style.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'name' => array( - 'description' => 'The style name.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - ), - ), - 'primary key' => array('isid'), - 'unique keys' => array( - 'name' => array('name'), - ), - ); - - $schema['image_effects'] = array( - 'description' => 'Stores configuration options for image effects.', - 'fields' => array( - 'ieid' => array( - 'description' => 'The primary identifier for an image effect.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'isid' => array( - 'description' => 'The {image_styles}.isid for an image style.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'weight' => array( - 'description' => 'The weight of the effect in the style.', - 'type' => 'int', - 'unsigned' => FALSE, - 'not null' => TRUE, - 'default' => 0, - ), - 'name' => array( - 'description' => 'The unique name of the effect to be executed.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - ), - 'data' => array( - 'description' => 'The configuration data for the effect.', - 'type' => 'blob', - 'not null' => TRUE, - 'size' => 'big', - 'serialize' => TRUE, - ), - ), - 'primary key' => array('ieid'), - 'indexes' => array( - 'isid' => array('isid'), - 'weight' => array('weight'), - ), - 'foreign keys' => array( - 'image_style' => array( - 'table' => 'image_styles', - 'columns' => array('isid' => 'isid'), - ), - ), - ); - - db_create_table('cache_image', $schema['cache_image']); - db_create_table('image_styles', $schema['image_styles']); - db_create_table('image_effects', $schema['image_effects']); - } -} - -/** - * Rename possibly misnamed {image_effect} table to {image_effects}. - */ -function image_update_7001() { - // Due to a bug in earlier versions of image_update_7000() it is possible - // to end up with an {image_effect} table where there should be an - // {image_effects} table. - if (!db_table_exists('image_effects') && db_table_exists('image_effect')) { - db_rename_table('image_effect', 'image_effects'); - } -} - -/** - * Implements hook_requirements() to check the PHP GD Library. - * - * @param $phase - */ -function image_requirements($phase) { - $requirements = array(); - - if ($phase == 'runtime') { - // Check for the PHP GD library. - if (function_exists('imagegd2')) { - $info = gd_info(); - $requirements['image_gd'] = array( - 'value' => $info['GD Version'], - ); - - // Check for filter and rotate support. - if (function_exists('imagefilter') && function_exists('imagerotate')) { - $requirements['image_gd']['severity'] = REQUIREMENT_OK; - } - else { - $requirements['image_gd']['severity'] = REQUIREMENT_ERROR; - $requirements['image_gd']['description'] = t('The GD Library for PHP is enabled, but was compiled without support for functions used by the rotate and desaturate effects. It was probably compiled using the official GD libraries from http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See the PHP manual.'); - } - } - else { - $requirements['image_gd'] = array( - 'value' => t('Not installed'), - 'severity' => REQUIREMENT_ERROR, - 'description' => t('The GD library for PHP is missing or outdated. Check the PHP image documentation for information on how to correct this.', array('@url' => 'http://www.php.net/manual/book.image.php')), - ); - } - $requirements['image_gd']['title'] = t('GD library rotate and desaturate effects'); - } - - return $requirements; -} diff --git modules/locale/locale.install modules/locale/locale.install index 2abbc53..122b78a 100644 --- modules/locale/locale.install +++ modules/locale/locale.install @@ -25,344 +25,3 @@ function locale_install() { )) ->execute(); } - -/** - * @addtogroup updates-6.x-to-7.x - * @{ - */ - -/** - * Add context field index and allow longer location. - */ -function locale_update_7000() { - db_drop_index('locales_source', 'source'); - db_add_index('locales_source', 'source_context', array(array('source', 30), 'context')); - - // Also drop the 'textgroup_location' index added by the i18nstrings module - // of the i18n project, which prevents the below schema update from running. - if (db_index_exists('locales_source', 'textgroup_location')) { - db_drop_index('locales_source', 'textgroup_location'); - } - - db_change_field('locales_source', 'location', 'location', array( - 'type' => 'text', - 'not null' => FALSE, - 'size' => 'big', - 'description' => 'Drupal path in case of online discovered translations or file path in case of imported strings.', - )); -} - -/** - * Upgrade language negotiation settings. - */ -function locale_update_7001() { - require_once DRUPAL_ROOT . '/includes/language.inc'; - require_once DRUPAL_ROOT . '/includes/locale.inc'; - require_once DRUPAL_ROOT . '/modules/locale/locale.module'; - - switch (variable_get('language_negotiation', 0)) { - // LANGUAGE_NEGOTIATION_NONE. - case 0: - $negotiation = array(); - break; - - // LANGUAGE_NEGOTIATION_PATH_DEFAULT. - case 1: - $negotiation = array(LOCALE_LANGUAGE_NEGOTIATION_URL); - // In Drupal 6 path prefixes are shown for the default language only when - // language negotiation is set to LANGUAGE_NEGOTIATION_PATH, while in - // Drupal 7 path prefixes are always shown if not empty. Hence we need to - // ensure that the default language has an empty prefix to avoid breaking - // the site URLs with a prefix that previously was missing. - $default = language_default(); - $default->prefix = ''; - variable_set('language_default', $default); - db_update('languages') - ->fields(array('prefix' => $default->prefix)) - ->condition('language', $default->language) - ->execute(); - break; - - // LANGUAGE_NEGOTIATION_PATH. - case 2: - $negotiation = array(LOCALE_LANGUAGE_NEGOTIATION_URL, LOCALE_LANGUAGE_NEGOTIATION_USER, LOCALE_LANGUAGE_NEGOTIATION_BROWSER); - break; - - // LANGUAGE_NEGOTIATION_DOMAIN. - case 3: - variable_set('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN); - $negotiation = array(LOCALE_LANGUAGE_NEGOTIATION_URL); - break; - } - - // Save the new language negotiation options. - language_negotiation_set(LANGUAGE_TYPE_INTERFACE, array_flip($negotiation)); - language_negotiation_set(LANGUAGE_TYPE_CONTENT, array(LOCALE_LANGUAGE_NEGOTIATION_INTERFACE => 0)); - language_negotiation_set(LANGUAGE_TYPE_URL, array(LOCALE_LANGUAGE_NEGOTIATION_URL => 0)); - - // Save admininstration UI settings. - $type = LANGUAGE_TYPE_INTERFACE; - $provider_weights = array_flip(array_keys(locale_language_negotiation_info())); - variable_set("locale_language_providers_weight_$type", $provider_weights); - - // Unset the old language negotiation system variable. - variable_del('language_negotiation'); - - return array(); -} - -/** - * Updates URL language negotiation by adding the URL fallback detection method. - */ -function locale_update_7002() { - // language.inc may not have been included during bootstrap if there is not - // more than one language currently enabled. - require_once DRUPAL_ROOT . '/includes/language.inc'; - $language_types_info = language_types_info(); - $info = $language_types_info[LANGUAGE_TYPE_URL]; - if (isset($info['fixed'])) { - language_negotiation_set(LANGUAGE_TYPE_URL, array_flip($info['fixed'])); - } -} - -/** - * @} End of "addtogroup updates-6.x-to-7.x" - */ - -/** - * Implements hook_uninstall(). - */ -function locale_uninstall() { - // Delete all JavaScript translation files. - $locale_js_directory = 'public://' . variable_get('locale_js_directory', 'languages'); - - if (is_dir($locale_js_directory)) { - $files = db_query('SELECT language, javascript FROM {languages}'); - foreach ($files as $file) { - if (!empty($file->javascript)) { - file_unmanaged_delete($locale_js_directory . '/' . $file->language . '_' . $file->javascript . '.js'); - } - } - // Delete the JavaScript translations directory if empty. - if (!file_scan_directory($locale_js_directory, '/.*/')) { - drupal_rmdir($locale_js_directory); - } - } - - // Clear variables. - variable_del('language_default'); - variable_del('language_count'); - variable_del('language_types'); - variable_del('locale_language_negotiation_url_part'); - variable_del('locale_language_negotiation_session_param'); - variable_del('language_content_type_default'); - variable_del('language_content_type_negotiation'); - variable_del('locale_cache_strings'); - variable_del('locale_js_directory'); - variable_del('javascript_parsed'); - variable_del('locale_field_language_fallback'); - variable_del('locale_cache_length'); - - foreach (language_types() as $type) { - variable_del("language_negotiation_$type"); - variable_del("locale_language_providers_weight_$type"); - } - - foreach (node_type_get_types() as $type => $content_type) { - $setting = variable_del("language_content_type_$type"); - } - - // Switch back to English: with a $language->language value different from 'en' - // successive calls of t() might result in calling locale(), which in turn might - // try to query the unexisting {locales_source} and {locales_target} tables. - drupal_language_initialize(); - -} - -/** - * Implements hook_schema(). - */ -function locale_schema() { - $schema['languages'] = array( - 'description' => 'List of all available languages in the system.', - 'fields' => array( - 'language' => array( - 'type' => 'varchar', - 'length' => 12, - 'not null' => TRUE, - 'default' => '', - 'description' => "Language code, e.g. 'de' or 'en-US'.", - ), - 'name' => array( - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - 'default' => '', - 'description' => 'Language name in English.', - ), - 'native' => array( - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - 'default' => '', - 'description' => 'Native language name.', - ), - 'direction' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Direction of language (Left-to-Right = 0, Right-to-Left = 1).', - ), - 'enabled' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Enabled flag (1 = Enabled, 0 = Disabled).', - ), - 'plurals' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Number of plural indexes in this language.', - ), - 'formula' => array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - 'description' => 'Plural formula in PHP code to evaluate to get plural indexes.', - ), - 'domain' => array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - 'description' => 'Domain to use for this language.', - ), - 'prefix' => array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - 'description' => 'Path prefix to use for this language.', - ), - 'weight' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Weight, used in lists of languages.', - ), - 'javascript' => array( - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - 'default' => '', - 'description' => 'Location of JavaScript translation file.', - ), - ), - 'primary key' => array('language'), - 'indexes' => array( - 'list' => array('weight', 'name'), - ), - ); - - $schema['locales_source'] = array( - 'description' => 'List of English source strings.', - 'fields' => array( - 'lid' => array( - 'type' => 'serial', - 'not null' => TRUE, - 'description' => 'Unique identifier of this string.', - ), - 'location' => array( - 'type' => 'text', - 'not null' => FALSE, - 'size' => 'big', - 'description' => 'Drupal path in case of online discovered translations or file path in case of imported strings.', - ), - 'textgroup' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => 'default', - 'description' => 'A module defined group of translations, see hook_locale().', - ), - 'source' => array( - 'type' => 'text', - 'mysql_type' => 'blob', - 'not null' => TRUE, - 'description' => 'The original string in English.', - ), - 'context' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - 'description' => 'The context this string applies to.', - ), - 'version' => array( - 'type' => 'varchar', - 'length' => 20, - 'not null' => TRUE, - 'default' => 'none', - 'description' => 'Version of Drupal, where the string was last used (for locales optimization).', - ), - ), - 'primary key' => array('lid'), - 'indexes' => array( - 'source_context' => array(array('source', 30), 'context'), - ), - ); - - $schema['locales_target'] = array( - 'description' => 'Stores translated versions of strings.', - 'fields' => array( - 'lid' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Source string ID. References {locales_source}.lid.', - ), - 'translation' => array( - 'type' => 'text', - 'mysql_type' => 'blob', - 'not null' => TRUE, - 'description' => 'Translation string value in this language.', - ), - 'language' => array( - 'type' => 'varchar', - 'length' => 12, - 'not null' => TRUE, - 'default' => '', - 'description' => 'Language code. References {languages}.language.', - ), - 'plid' => array( - 'type' => 'int', - 'not null' => TRUE, // This should be NULL for no referenced string, not zero. - 'default' => 0, - 'description' => 'Parent lid (lid of the previous string in the plural chain) in case of plural strings. References {locales_source}.lid.', - ), - 'plural' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Plural index number in case of plural strings.', - ), - ), - 'primary key' => array('language', 'lid', 'plural'), - 'foreign keys' => array( - 'locales_source' => array( - 'table' => 'locales_source', - 'columns' => array('lid' => 'lid'), - ), - ), - 'indexes' => array( - 'lid' => array('lid'), - 'plid' => array('plid'), - 'plural' => array('plural'), - ), - ); - - return $schema; -} - diff --git modules/node/node.install modules/node/node.install index 44c2350..5ede117 100644 --- modules/node/node.install +++ modules/node/node.install @@ -416,392 +416,10 @@ function node_install() { } /** - * Implements hook_update_dependencies(). - */ -function node_update_dependencies() { - // Node update 7006 migrates node data to fields and therefore must run after - // 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, - ); - return $dependencies; -} - -/** * Utility function: fetch the node types directly from the database. * - * 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_node_get_types() { +function _update_8000_node_get_types() { return db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ); } - -/** - * @addtogroup updates-6.x-to-7.x - * @{ - */ - -/** - * Upgrade the node type table and fix node type 'module' attribute to avoid name-space conflicts. - */ -function node_update_7000() { - // Rename the module column to base. - db_change_field('node_type', 'module', 'base', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE)); - - db_add_field('node_type', 'module', array( - 'description' => 'The module defining this node type.', - 'type' => 'varchar', - 'default' => '', - 'length' => 255, - 'not null' => TRUE, - )); - - db_add_field('node_type', 'disabled', array( - 'description' => 'A boolean indicating whether the node type is disabled.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'size' => 'tiny' - )); - - $modules = db_select('system', 's') - ->fields('s', array('name')) - ->condition('type', 'module'); - db_update('node_type') - ->expression('module', 'base') - ->condition('base', $modules, 'IN') - ->execute(); - - db_update('node_type') - ->fields(array('base' => 'node_content')) - ->condition('base', 'node') - ->execute(); -} - -/** - * Rename {node_revisions} table to {node_revision}. - */ -function node_update_7001() { - db_rename_table('node_revisions', 'node_revision'); -} - -/** - * Extend the node_promote_status index to include all fields required for the node page query. - */ -function node_update_7002() { - db_drop_index('node', 'node_promote_status'); - db_add_index('node', 'node_frontpage', array('promote', 'status', 'sticky', 'created')); -} - -/** - * Remove the node_counter if the statistics module is uninstalled. - */ -function node_update_7003() { - if (drupal_get_installed_schema_version('statistics') == SCHEMA_UNINSTALLED) { - db_drop_table('node_counter'); - } -} - -/** - * Extend the existing default preview and teaser settings to all node types. - */ -function node_update_7004() { - // Get original settings and all types. - $original_length = variable_get('teaser_length', 600); - $original_preview = variable_get('node_preview', 0); - - // Map old preview setting to new values order. - $original_preview ? $original_preview = 2 : $original_preview = 1; - node_type_cache_reset(); - - // Apply original settings to all types. - foreach (_update_7000_node_get_types() as $type => $type_object) { - variable_set('teaser_length_' . $type, $original_length); - variable_set('node_preview_' . $type, $original_preview); - } - // Delete old variable but leave 'teaser_length' for aggregator module upgrade. - variable_del('node_preview'); -} - -/** - * Add status/comment/promote and sticky columns to the {node_revision} table. - */ -function node_update_7005() { - foreach (array('status', 'comment', 'promote', 'sticky') as $column) { - db_add_field('node_revision', $column, array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - )); - } -} - -/** - * 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(&$sandbox) { - $sandbox['#finished'] = 0; - - // Get node type info for every invocation. - node_type_cache_reset(); - - if (!isset($sandbox['total'])) { - // Initial invocation. - - // First, create the body field. - $body_field = array( - 'field_name' => 'body', - 'type' => 'text_with_summary', - 'module' => 'text', - 'cardinality' => 1, - 'entity_types' => array('node'), - 'translatable' => TRUE, - ); - _update_7000_field_create_field($body_field); - - $default_trim_length = variable_get('teaser_length', 600); - - // Get node type info, specifically the body field settings. - $node_types = _update_7000_node_get_types(); - - // Create default settings for orphan nodes. - $extra_types = db_query('SELECT DISTINCT type FROM {node} WHERE type NOT IN (:types)', array(':types' => array_keys($node_types)))->fetchCol(); - foreach ($extra_types as $type) { - $type_object = new stdClass; - $type_object->type = $type; - // Always create a body. Querying node_revisions for a non-empty body - // would skip creating body fields for types that have a body but - // the nodes of that type so far had empty bodies. - $type_object->has_body = 1; - $type_object->body_label = 'Body'; - $node_types[$type_object->type] = $type_object; - } - - // Add body field instances for existing node types. - foreach ($node_types as $node_type) { - if ($node_type->has_body) { - $trim_length = variable_get('teaser_length_' . $node_type->type, $default_trim_length); - - $instance = array( - 'entity_type' => 'node', - 'bundle' => $node_type->type, - 'label' => $node_type->body_label, - 'widget' => array( - 'type' => 'text_textarea_with_summary', - 'settings' => array( - 'rows' => 20, - 'summary_rows' => 5, - ), - 'weight' => -4, - 'module' => 'text', - ), - 'settings' => array('display_summary' => TRUE), - 'display' => array( - 'default' => array( - 'label' => 'hidden', - 'type' => 'text_default', - ), - 'teaser' => array( - 'label' => 'hidden', - 'type' => 'text_summary_or_trimmed', - 'trim_length' => $trim_length, - ), - ), - ); - _update_7000_field_create_instance($body_field, $instance); - variable_del('teaser_length_' . $node_type->type); - } - // Leave 'teaser_length' variable for aggregator module upgrade. - - $sandbox['node_types_info'][$node_type->type] = array( - 'has_body' => $node_type->has_body, - ); - } - - // 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; - - $query = db_select('node', 'n'); - $query->join('node_revision', 'nr', 'n.nid = nr.nid'); - $sandbox['total'] = $query->countQuery()->execute()->fetchField(); - - $sandbox['body_field_id'] = $body_field['id']; - } - else { - // Subsequent invocations. - - $found = FALSE; - if ($sandbox['total']) { - // Operate on every revision of every node (whee!), in batches. - $batch_size = 200; - $query = db_select('node_revision', 'nr'); - $query->innerJoin('node', 'n', 'n.nid = nr.nid'); - $query - ->fields('nr', array('nid', 'vid', 'body', 'teaser', 'format')) - ->fields('n', array('type', 'status', 'comment', 'promote', 'sticky', 'language')) - ->condition('nr.vid', $sandbox['last'], '>') - ->orderBy('nr.vid', 'ASC') - ->range(0, $batch_size); - $revisions = $query->execute(); - - // Load each revision of each node, set up 'body' - // appropriately, and save the node's field data. Note that - // node_load() will not return the body or teaser values from - // {node_revision} because those columns have been removed from the - // schema structure in memory (but not yet from the database), - // so we get the values from the explicit query of the table - // instead. - foreach ($revisions as $revision) { - $found = TRUE; - - if ($sandbox['node_types_info'][$revision->type]['has_body']) { - $node = (object) array( - 'nid' => $revision->nid, - 'vid' => $revision->vid, - 'type' => $revision->type, - ); - // After node_update_7009() we will always have LANGUAGE_NONE as - // language neutral language code, but here we still have empty - // strings. - $langcode = empty($revision->language) ? LANGUAGE_NONE : $revision->language; - if (!empty($revision->teaser) && $revision->teaser != text_summary($revision->body)) { - $node->body[$langcode][0]['summary'] = $revision->teaser; - } - // Do this after text_summary() above. - $break = ''; - if (substr($revision->body, 0, strlen($break)) == $break) { - $revision->body = substr($revision->body, strlen($break)); - } - $node->body[$langcode][0]['value'] = $revision->body; - // 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. - _update_7000_field_sql_storage_write('node', $node->type, $node->nid, $node->vid, 'body', $node->body); - } - - // Migrate the status columns to the {node_revision} table. - db_update('node_revision') - ->fields(array( - 'status' => $revision->status, - 'comment' => $revision->comment, - 'promote' => $revision->promote, - 'sticky' => $revision->sticky, - )) - ->condition('vid', $revision->vid) - ->execute(); - - $sandbox['last'] = $revision->vid; - $sandbox['count'] += 1; - } - - $sandbox['#finished'] = min(0.99, $sandbox['count'] / $sandbox['total']); - } - - if (!$found) { - // All nodes are processed. - - // Remove the now-obsolete body info from node_revision. - db_drop_field('node_revision', 'body'); - db_drop_field('node_revision', 'teaser'); - db_drop_field('node_revision', 'format'); - - // Remove node_type properties related to the former 'body'. - db_drop_field('node_type', 'has_body'); - db_drop_field('node_type', 'body_label'); - - // We're done. - $sandbox['#finished'] = 1; - } - } -} - -/** - * Remove column min_word_count. - */ -function node_update_7007() { - db_drop_field('node_type', 'min_word_count'); -} - -/** - * Split the 'administer nodes' permission from 'access content overview'. - */ -function node_update_7008() { - $roles = user_roles(FALSE, 'administer nodes'); - foreach ($roles as $rid => $role) { - _update_7000_user_role_grant_permissions($rid, array('access content overview'), 'node'); - } -} - -/** - * Convert node languages from the empty string to LANGUAGE_NONE. - */ -function node_update_7009() { - db_update('node') - ->fields(array('language' => LANGUAGE_NONE)) - ->condition('language', '') - ->execute(); -} - -/** - * Add the {block_node_type} table. - */ -function node_update_7010() { - $schema['block_node_type'] = array( - 'description' => 'Sets up display criteria for blocks based on content types', - 'fields' => array( - 'module' => array( - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - 'description' => "The block's origin module, from {block}.module.", - ), - 'delta' => array( - 'type' => 'varchar', - 'length' => 32, - 'not null' => TRUE, - 'description' => "The block's unique delta within module, from {block}.delta.", - ), - 'type' => array( - 'type' => 'varchar', - 'length' => 32, - 'not null' => TRUE, - 'description' => "The machine-readable name of this type from {node_type}.type.", - ), - ), - 'primary key' => array('module', 'delta', 'type'), - 'indexes' => array( - 'type' => array('type'), - ), - ); - - db_create_table('block_node_type', $schema['block_node_type']); -} - -/** - * @} End of "addtogroup updates-6.x-to-7.x" - */ diff --git modules/poll/poll.install modules/poll/poll.install index d74ff98..c848445 100644 --- modules/poll/poll.install +++ modules/poll/poll.install @@ -147,52 +147,3 @@ function poll_schema() { return $schema; } - -/** - * Use the poll_choice primary key to record votes in poll_votes rather than - * the choice order. Rename chorder to weight. - * - * Rename {poll_choices} table to {poll_choice} and {poll_votes} to {poll_vote}. - */ -function poll_update_7001() { - // Add chid column and convert existing votes. - db_add_field('poll_votes', 'chid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); - db_add_index('poll_votes', 'chid', array('chid')); - db_update('poll_votes') - ->expression('chid', Database::getConnection()->prefixTables('COALESCE((SELECT chid FROM {poll_choices} c WHERE {poll_votes}.chorder = c.chorder AND {poll_votes}.nid = c.nid), 0)')) - ->execute(); - // Delete invalid votes. - db_delete('poll_votes')->condition('chid', 0)->execute(); - // Remove old chorder column. - db_drop_field('poll_votes', 'chorder'); - - // Change the chorder column to weight in poll_choices. - db_change_field('poll_choices', 'chorder', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')); - - db_rename_table('poll_votes', 'poll_vote'); - db_rename_table('poll_choices', 'poll_choice'); -} - -/** - * Add timestamp field to {poll_vote}. - */ -function poll_update_7002() { - $field = array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ); - db_add_field('poll_vote', 'timestamp', $field); -} - -/** - * Change the weight column to normal int. - */ -function poll_update_7003() { - db_change_field('poll_choice', 'weight', 'weight', array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The sort order of this choice among all choices for the same node.', - )); -} diff --git modules/profile/profile.install modules/profile/profile.install index 5e4a17c..c5747cf 100644 --- modules/profile/profile.install +++ modules/profile/profile.install @@ -150,23 +150,3 @@ function profile_schema() { return $schema; } - -/** - * Rename {profile_fields} table to {profile_field} and {profile_values} to {profile_value}. - */ -function profile_update_7001() { - db_rename_table('profile_fields', 'profile_field'); - db_rename_table('profile_values', 'profile_value'); -} - -/** - * Change the weight column to normal int. - */ -function profile_update_7002() { - db_change_field('profile_field', 'weight', 'weight', array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Weight of field in relation to other profile fields.', - )); -} diff --git modules/search/search.install modules/search/search.install index f0113b3..c450f05 100644 --- modules/search/search.install +++ modules/search/search.install @@ -153,30 +153,3 @@ function search_schema() { return $schema; } - -/** - * Replace unique keys in 'search_dataset' and 'search_index' by primary keys. - */ -function search_update_7000() { - db_drop_unique_key('search_dataset', 'sid_type'); - $dataset_type_spec = array( - 'type' => 'varchar', - 'length' => 16, - 'not null' => TRUE, - 'description' => 'Type of item, e.g. node.', - ); - db_change_field('search_dataset', 'type', 'type', $dataset_type_spec); - db_add_primary_key('search_dataset', array('sid', 'type')); - - db_drop_index('search_index', 'word'); - db_drop_unique_key('search_index', 'word_sid_type'); - $index_type_spec = array( - 'type' => 'varchar', - 'length' => 16, - 'not null' => TRUE, - 'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.', - ); - db_change_field('search_index', 'type', 'type', $index_type_spec); - db_add_primary_key('search_index', array('word', 'sid', 'type')); -} - diff --git modules/simpletest/tests/update.test modules/simpletest/tests/update.test index 966efff..2f55dc5 100644 --- modules/simpletest/tests/update.test +++ modules/simpletest/tests/update.test @@ -27,12 +27,12 @@ class UpdateDependencyOrderingTestCase extends DrupalWebTestCase { */ function testUpdateOrderingSingleModule() { $starting_updates = array( - 'update_test_1' => 7000, + 'update_test_1' => 8000, ); $expected_updates = array( - 'update_test_1_update_7000', - 'update_test_1_update_7001', - 'update_test_1_update_7002', + 'update_test_1_update_8000', + 'update_test_1_update_8001', + 'update_test_1_update_8002', ); $actual_updates = array_keys(update_resolve_dependencies($starting_updates)); $this->assertEqual($expected_updates, $actual_updates, t('Updates within a single module run in the correct order.')); @@ -43,14 +43,14 @@ class UpdateDependencyOrderingTestCase extends DrupalWebTestCase { */ function testUpdateOrderingModuleInterdependency() { $starting_updates = array( - 'update_test_2' => 7000, - 'update_test_3' => 7000, + 'update_test_2' => 8000, + 'update_test_3' => 8000, ); $update_order = array_keys(update_resolve_dependencies($starting_updates)); // Make sure that each dependency is satisfied. - $first_dependency_satisfied = array_search('update_test_2_update_7000', $update_order) < array_search('update_test_3_update_7000', $update_order); + $first_dependency_satisfied = array_search('update_test_2_update_8000', $update_order) < array_search('update_test_3_update_8000', $update_order); $this->assertTrue($first_dependency_satisfied, t('The dependency of the second module on the first module is respected by the update function order.')); - $second_dependency_satisfied = array_search('update_test_3_update_7000', $update_order) < array_search('update_test_2_update_7001', $update_order); + $second_dependency_satisfied = array_search('update_test_3_update_8000', $update_order) < array_search('update_test_2_update_8001', $update_order); $this->assertTrue($second_dependency_satisfied, t('The dependency of the first module on the second module is respected by the update function order.')); } } @@ -76,12 +76,12 @@ class UpdateDependencyMissingTestCase extends DrupalWebTestCase { function testMissingUpdate() { $starting_updates = array( - 'update_test_2' => 7000, + 'update_test_2' => 8000, ); $update_graph = update_resolve_dependencies($starting_updates); - $this->assertTrue($update_graph['update_test_2_update_7000']['allowed'], t("The module's first update function is allowed to run, since it does not have any missing dependencies.")); - $this->assertFalse($update_graph['update_test_2_update_7001']['allowed'], t("The module's second update function is not allowed to run, since it has a direct dependency on a missing update.")); - $this->assertFalse($update_graph['update_test_2_update_7002']['allowed'], t("The module's third update function is not allowed to run, since it has an indirect dependency on a missing update.")); + $this->assertTrue($update_graph['update_test_2_update_8000']['allowed'], t("The module's first update function is allowed to run, since it does not have any missing dependencies.")); + $this->assertFalse($update_graph['update_test_2_update_8001']['allowed'], t("The module's second update function is not allowed to run, since it has a direct dependency on a missing update.")); + $this->assertFalse($update_graph['update_test_2_update_8002']['allowed'], t("The module's third update function is not allowed to run, since it has an indirect dependency on a missing update.")); } } @@ -107,9 +107,9 @@ class UpdateDependencyHookInvocationTestCase extends DrupalWebTestCase { */ function testHookUpdateDependencies() { $update_dependencies = update_retrieve_dependencies(); - $this->assertTrue($update_dependencies['system'][7000]['update_test_1'] == 7000, t('An update function that has a dependency on two separate modules has the first dependency recorded correctly.')); - $this->assertTrue($update_dependencies['system'][7000]['update_test_2'] == 7001, t('An update function that has a dependency on two separate modules has the second dependency recorded correctly.')); - $this->assertTrue($update_dependencies['system'][7001]['update_test_1'] == 7002, t('An update function that depends on more than one update from the same module only has the dependency on the higher-numbered update function recorded.')); + $this->assertTrue($update_dependencies['system'][8000]['update_test_1'] == 8000, t('An update function that has a dependency on two separate modules has the first dependency recorded correctly.')); + $this->assertTrue($update_dependencies['system'][8000]['update_test_2'] == 8001, t('An update function that has a dependency on two separate modules has the second dependency recorded correctly.')); + $this->assertTrue($update_dependencies['system'][8001]['update_test_1'] == 8002, t('An update function that depends on more than one update from the same module only has the dependency on the higher-numbered update function recorded.')); } } diff --git modules/simpletest/tests/update_test_1.install modules/simpletest/tests/update_test_1.install index f4a86c7..22398a3 100644 --- modules/simpletest/tests/update_test_1.install +++ modules/simpletest/tests/update_test_1.install @@ -17,37 +17,37 @@ function update_test_1_update_dependencies() { // the correct array structure. Therefore, we use updates from System module // (which have already run), so that they will not get in the way of other // tests. - $dependencies['system'][7000] = array( + $dependencies['system'][8000] = array( // Compare to update_test_2_update_dependencies(), where the same System // module update function is forced to depend on an update function from a // different module. This allows us to test that both dependencies are // correctly recorded. - 'update_test_1' => 7000, + 'update_test_1' => 8000, ); - $dependencies['system'][7001] = array( + $dependencies['system'][8001] = array( // Compare to update_test_2_update_dependencies(), where the same System // module update function is forced to depend on a different update // function within the same module. This allows us to test that only the // dependency on the higher-numbered update function is recorded. - 'update_test_1' => 7002, + 'update_test_1' => 8002, ); return $dependencies; } /** - * Dummy update_test_1 update 7000. + * Dummy update_test_1 update 8000. */ -function update_test_1_update_7000() { +function update_test_1_update_8000() { } /** - * Dummy update_test_1 update 7001. + * Dummy update_test_1 update 8001. */ -function update_test_1_update_7001() { +function update_test_1_update_8001() { } /** - * Dummy update_test_1 update 7002. + * Dummy update_test_1 update 8002. */ -function update_test_1_update_7002() { +function update_test_1_update_8002() { } diff --git modules/simpletest/tests/update_test_2.install modules/simpletest/tests/update_test_2.install index 9c076ff..c73271a 100644 --- modules/simpletest/tests/update_test_2.install +++ modules/simpletest/tests/update_test_2.install @@ -14,40 +14,40 @@ function update_test_2_update_dependencies() { // Combined with update_test_3_update_dependencies(), we are declaring here // that these two modules run updates in the following order: - // 1. update_test_2_update_7000() - // 2. update_test_3_update_7000() - // 3. update_test_2_update_7001() - // 4. update_test_2_update_7002() - $dependencies['update_test_2'][7001] = array( - 'update_test_3' => 7000, + // 1. update_test_2_update_8000() + // 2. update_test_3_update_8000() + // 3. update_test_2_update_8001() + // 4. update_test_2_update_8002() + $dependencies['update_test_2'][8001] = array( + 'update_test_3' => 8000, ); // These are coordinated with the corresponding dependencies declared in // update_test_1_update_dependencies(). - $dependencies['system'][7000] = array( - 'update_test_2' => 7001, + $dependencies['system'][8000] = array( + 'update_test_2' => 8001, ); - $dependencies['system'][7001] = array( - 'update_test_1' => 7001, + $dependencies['system'][8001] = array( + 'update_test_1' => 8001, ); return $dependencies; } /** - * Dummy update_test_2 update 7000. + * Dummy update_test_2 update 8000. */ -function update_test_2_update_7000() { +function update_test_2_update_8000() { } /** - * Dummy update_test_2 update 7001. + * Dummy update_test_2 update 8001. */ -function update_test_2_update_7001() { +function update_test_2_update_8001() { } /** - * Dummy update_test_2 update 7002. + * Dummy update_test_2 update 8002. */ -function update_test_2_update_7002() { +function update_test_2_update_8002() { } diff --git modules/simpletest/tests/update_test_3.install modules/simpletest/tests/update_test_3.install index c3f6b75..96830c8 100644 --- modules/simpletest/tests/update_test_3.install +++ modules/simpletest/tests/update_test_3.install @@ -11,14 +11,14 @@ * @see update_test_2_update_dependencies() */ function update_test_3_update_dependencies() { - $dependencies['update_test_3'][7000] = array( - 'update_test_2' => 7000, + $dependencies['update_test_3'][8000] = array( + 'update_test_2' => 8000, ); return $dependencies; } /** - * Dummy update_test_3 update 7000. + * Dummy update_test_3 update 8000. */ -function update_test_3_update_7000() { +function update_test_3_update_8000() { } diff --git modules/statistics/statistics.install modules/statistics/statistics.install index d5855a7..a5dc7f8 100644 --- modules/statistics/statistics.install +++ modules/statistics/statistics.install @@ -134,25 +134,3 @@ function statistics_schema() { return $schema; } - -/** - * @addtogroup updates-6.x-to-7.x - * @{ - */ - -/** - * Update the {accesslog}.sid column to match the length of {sessions}.sid - */ -function statistics_update_7000() { - db_change_field('accesslog', 'sid', 'sid', array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - 'description' => 'Browser session ID of user that visited page.', - )); -} - -/** - * @} End of "addtogroup updates-6.x-to-7.x" - */ diff --git modules/system/system.api.php modules/system/system.api.php index 5481e81..48b26d6 100644 --- modules/system/system.api.php +++ modules/system/system.api.php @@ -3196,21 +3196,21 @@ function hook_update_N(&$sandbox) { * @see hook_update_N() */ function hook_update_dependencies() { - // Indicate that the mymodule_update_7000() function provided by this module - // must run after the another_module_update_7002() function provided by the + // Indicate that the mymodule_update_8000() function provided by this module + // must run after the another_module_update_8002() function provided by the // 'another_module' module. - $dependencies['mymodule'][7000] = array( - 'another_module' => 7002, + $dependencies['mymodule'][8000] = array( + 'another_module' => 8002, ); - // Indicate that the mymodule_update_7001() function provided by this module - // must run before the yet_another_module_update_7004() function provided by + // Indicate that the mymodule_update_8001() function provided by this module + // must run before the yet_another_module_update_8004() function provided by // the 'yet_another_module' module. (Note that declaring dependencies in this // direction should be done only in rare situations, since it can lead to the // following problem: If a site has already run the yet_another_module // module's database updates before it updates its codebase to pick up the // newest mymodule code, then the dependency declared here will be ignored.) - $dependencies['yet_another_module'][7004] = array( - 'mymodule' => 7001, + $dependencies['yet_another_module'][8004] = array( + 'mymodule' => 8001, ); return $dependencies; } diff --git modules/system/system.install modules/system/system.install index af02edc..d47cbc1 100644 --- modules/system/system.install +++ modules/system/system.install @@ -1701,1277 +1701,23 @@ function system_schema_cache_7054() { // Updates for core. function system_update_last_removed() { - return 6055; + return 7069; } /** - * Implements hook_update_dependencies(). - */ -function system_update_dependencies() { - // Update 7053 adds new blocks, so make sure the block tables are updated. - $dependencies['system'][7053] = array( - 'block' => 7002, - ); - - return $dependencies; -} - -/** - * @defgroup updates-6.x-to-7.x Updates from 6.x to 7.x + * @defgroup updates-7.x-to-8.x Updates from 7.x to 8.x * @{ - * Update functions from 6.x to 7.x. - */ - -/** - * Rename blog and forum permissions to be consistent with other content types. - */ -function system_update_7000() { - $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid"); - foreach ($result as $role) { - $renamed_permission = preg_replace('/(?<=^|,\ )create\ blog\ entries(?=,|$)/', 'create blog content', $role->perm); - $renamed_permission = preg_replace('/(?<=^|,\ )edit\ own\ blog\ entries(?=,|$)/', 'edit own blog content', $role->perm); - $renamed_permission = preg_replace('/(?<=^|,\ )edit\ any\ blog\ entry(?=,|$)/', 'edit any blog content', $role->perm); - $renamed_permission = preg_replace('/(?<=^|,\ )delete\ own\ blog\ entries(?=,|$)/', 'delete own blog content', $role->perm); - $renamed_permission = preg_replace('/(?<=^|,\ )delete\ any\ blog\ entry(?=,|$)/', 'delete any blog content', $role->perm); - - $renamed_permission = preg_replace('/(?<=^|,\ )create\ forum\ topics(?=,|$)/', 'create forum content', $role->perm); - $renamed_permission = preg_replace('/(?<=^|,\ )delete\ any\ forum\ topic(?=,|$)/', 'delete any forum content', $role->perm); - $renamed_permission = preg_replace('/(?<=^|,\ )delete\ own\ forum\ topics(?=,|$)/', 'delete own forum content', $role->perm); - $renamed_permission = preg_replace('/(?<=^|,\ )edit\ any\ forum\ topic(?=,|$)/', 'edit any forum content', $role->perm); - $renamed_permission = preg_replace('/(?<=^|,\ )edit\ own\ forum\ topics(?=,|$)/', 'edit own forum content', $role->perm); - - if ($renamed_permission != $role->perm) { - db_update('permission') - ->fields(array('perm' => $renamed_permission)) - ->condition('rid', $role->rid) - ->execute(); - } - } -} - -/** - * Generate a cron key and save it in the variables table. + * Update functions from 7.x to 8.x. */ -function system_update_7001() { - variable_set('cron_key', drupal_hash_base64(drupal_random_bytes(55))); -} /** - * Add a table to store blocked IP addresses. - */ -function system_update_7002() { - $schema['blocked_ips'] = array( - 'description' => 'Stores blocked IP addresses.', - 'fields' => array( - 'iid' => array( - 'description' => 'Primary Key: unique ID for IP addresses.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'ip' => array( - 'description' => 'IP address', - 'type' => 'varchar', - 'length' => 32, - 'not null' => TRUE, - 'default' => '', - ), - ), - 'indexes' => array( - 'blocked_ip' => array('ip'), - ), - 'primary key' => array('iid'), - ); - - db_create_table('blocked_ips', $schema['blocked_ips']); -} - -/** - * Update {blocked_ips} with valid IP addresses from {access}. - */ -function system_update_7003() { - $messages = array(); - $type = 'host'; - $result = db_query("SELECT mask FROM {access} WHERE status = :status AND type = :type", array( - ':status' => 0, - ':type' => $type, - )); - foreach ($result as $blocked) { - if (filter_var($blocked->mask, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) !== FALSE) { - db_insert('blocked_ips') - ->fields(array('ip' => $blocked->mask)) - ->execute(); - } - else { - $invalid_host = check_plain($blocked->mask); - $messages[] = t('The host !host is no longer blocked because it is not a valid IP address.', array('!host' => $invalid_host )); - } - } - if (isset($invalid_host)) { - drupal_set_message('Drupal no longer supports wildcard IP address blocking. Visitors whose IP addresses match ranges you have previously set using access rules will no longer be blocked from your site when you put the site online. See the IP address and referrer blocking Handbook page for alternative methods.', 'warning'); - } - // Make sure not to block any IP addresses that were specifically allowed by access rules. - if (!empty($result)) { - $result = db_query("SELECT mask FROM {access} WHERE status = :status AND type = :type", array( - ':status' => 1, - ':type' => $type, - )); - $or = db_condition('or'); - foreach ($result as $allowed) { - $or->condition('ip', $allowed->mask, 'LIKE'); - } - if (count($or)) { - db_delete('blocked_ips') - ->condition($or) - ->execute(); - } - } -} - -/** - * Remove hardcoded numeric deltas from all blocks in core. - */ -function system_update_7004(&$sandbox) { - // Get an array of the renamed block deltas, organized by module. - $renamed_deltas = array( - 'blog' => array('0' => 'recent'), - 'book' => array('0' => 'navigation'), - 'comment' => array('0' => 'recent'), - 'forum' => array( - '0' => 'active', - '1' => 'new', - ), - 'locale' => array('0' => LANGUAGE_TYPE_INTERFACE), - 'node' => array('0' => 'syndicate'), - 'poll' => array('0' => 'recent'), - 'profile' => array('0' => 'author-information'), - 'search' => array('0' => 'form'), - 'statistics' => array('0' => 'popular'), - 'system' => array('0' => 'powered-by'), - 'user' => array( - '0' => 'login', - '1' => 'navigation', - '2' => 'new', - '3' => 'online', - ), - ); - - $moved_deltas = array( - 'user' => array('navigation' => 'system'), - ); - - // Only run this the first time through the batch update. - if (!isset($sandbox['progress'])) { - // Rename forum module's block variables. - $forum_block_num_0 = variable_get('forum_block_num_0'); - if (isset($forum_block_num_0)) { - variable_set('forum_block_num_active', $forum_block_num_0); - variable_del('forum_block_num_0'); - } - $forum_block_num_1 = variable_get('forum_block_num_1'); - if (isset($forum_block_num_1)) { - variable_set('forum_block_num_new', $forum_block_num_1); - variable_del('forum_block_num_1'); - } - } - - update_fix_d7_block_deltas($sandbox, $renamed_deltas, $moved_deltas); - -} - -/** - * Remove throttle columns and variables. - */ -function system_update_7005() { - db_drop_field('blocks', 'throttle'); - db_drop_field('system', 'throttle'); - variable_del('throttle_user'); - variable_del('throttle_anonymous'); - variable_del('throttle_level'); - variable_del('throttle_probability_limiter'); -} - -/** - * Convert to new method of storing permissions. - * - * This update is in system.install rather than user.install so that - * all modules can use the updated permission scheme during their updates. - */ -function system_update_7007() { - // Copy the permissions from the old {permission} table to the new {role_permission} table. - $messages = array(); - $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid ASC"); - $query = db_insert('role_permission')->fields(array('rid', 'permission')); - foreach ($result as $role) { - foreach (explode(', ', $role->perm) as $perm) { - $query->values(array( - 'rid' => $role->rid, - 'permission' => $perm, - )); - } - $messages[] = t('Inserted into {role_permission} the permissions for role ID !id', array('!id' => $role->rid)); - } - $query->execute(); - db_drop_table('permission'); - - return implode(', ', $messages); -} - -/** - * Rename the variable for primary links. - */ -function system_update_7009() { - $current_primary = variable_get('menu_primary_links_source'); - if (isset($current_primary)) { - variable_set('menu_main_links_source', $current_primary); - variable_del('menu_primary_links_source'); - } -} - -/** - * Split the 'bypass node access' permission from 'administer nodes'. - */ -function system_update_7011() { - // Get existing roles that can 'administer nodes'. - $rids = array(); - $rids = db_query("SELECT rid FROM {role_permission} WHERE permission = :perm", array(':perm' => 'administer nodes'))->fetchCol(); - // None found. - if (empty($rids)) { - return; - } - $insert = db_insert('role_permission')->fields(array('rid', 'permission')); - foreach ($rids as $rid) { - $insert->values(array( - 'rid' => $rid, - 'permission' => 'bypass node access', - )); - } - $insert->execute(); -} - -/** - * Convert default time zone offset to default time zone name. - */ -function system_update_7013() { - $timezone = NULL; - $timezones = system_time_zones(); - // If the contributed Date module set a default time zone name, use this - // setting as the default time zone. - if (($timezone_name = variable_get('date_default_timezone_name')) && isset($timezones[$timezone_name])) { - $timezone = $timezone_name; - } - // If the contributed Event module has set a default site time zone, look up - // the time zone name and use it as the default time zone. - if (!$timezone && ($timezone_id = variable_get('date_default_timezone_id', 0))) { - try { - $timezone_name = db_query('SELECT name FROM {event_timezones} WHERE timezone = :timezone_id', array(':timezone_id' => $timezone_id))->fetchField(); - if (($timezone_name = str_replace(' ', '_', $timezone_name)) && isset($timezones[$timezone_name])) { - $timezone = $timezone_name; - } - } - catch (PDOException $e) { - // Ignore error if event_timezones table does not exist or unexpected - // schema found. - } - } - - // Check to see if timezone was overriden in update_prepare_d7_bootstrap(). - $offset = variable_get('date_temporary_timezone'); - // If not, use the default. - if (!isset($offset)) { - $offset = variable_get('date_default_timezone', 0); - } - - // If the previous default time zone was a non-zero offset, guess the site's - // intended time zone based on that offset and the server's daylight saving - // time status. - if (!$timezone && $offset) { - $timezone_name = timezone_name_from_abbr('', intval($offset), date('I')); - if ($timezone_name && isset($timezones[$timezone_name])) { - $timezone = $timezone_name; - } - } - // Otherwise, the default time zone offset was zero, which is UTC. - if (!$timezone) { - $timezone = 'UTC'; - } - variable_set('date_default_timezone', $timezone); - drupal_set_message('The default time zone has been set to ' . check_plain($timezone) . '. Check the ' . l('date and time configuration page', 'admin/config/regional/settings') . ' to configure it correctly.', 'warning'); - // Remove temporary override. - variable_del('date_temporary_timezone'); -} - -/** - * Change the user logout path. - */ -function system_update_7015() { - db_update('menu_links') - ->fields(array('link_path' => 'user/logout')) - ->condition('link_path', 'logout') - ->execute(); - db_update('menu_links') - ->fields(array('router_path' => 'user/logout')) - ->condition('router_path', 'logout') - ->execute(); - - db_update('menu_links') - ->fields(array( - 'menu_name' => 'user-menu', - 'plid' => 0, - )) - ->condition(db_or() - ->condition('link_path', 'user/logout') - ->condition('router_path', 'user/logout') - ) - ->condition('module', 'system') - ->condition('customized', 0) - ->execute(); -} - -/** - * Remove custom datatype *_unsigned in PostgreSQL. - */ -function system_update_7016() { - // Only run these queries if the driver used is pgsql. - if (db_driver() == 'pgsql') { - $result = db_query("SELECT c.relname AS table, a.attname AS field, - pg_catalog.format_type(a.atttypid, a.atttypmod) AS type - FROM pg_catalog.pg_attribute a - LEFT JOIN pg_class c ON (c.oid = a.attrelid) - WHERE pg_catalog.pg_table_is_visible(c.oid) AND c.relkind = 'r' - AND pg_catalog.format_type(a.atttypid, a.atttypmod) LIKE '%unsigned%'"); - foreach ($result as $row) { - switch ($row->type) { - case 'smallint_unsigned': - $datatype = 'int'; - break; - case 'int_unsigned': - case 'bigint_unsigned': - default: - $datatype = 'bigint'; - break; - } - db_query('ALTER TABLE ' . $row->table . ' ALTER COLUMN "' . $row->field . '" TYPE ' . $datatype); - db_query('ALTER TABLE ' . $row->table . ' ADD CHECK ("' . $row->field . '" >= 0)'); - } - db_query('DROP DOMAIN IF EXISTS smallint_unsigned'); - db_query('DROP DOMAIN IF EXISTS int_unsigned'); - db_query('DROP DOMAIN IF EXISTS bigint_unsigned'); - } -} - -/** - * Change the theme setting 'toggle_node_info' into a per content type variable. - */ -function system_update_7017() { - // Get the global theme settings. - $settings = variable_get('theme_settings', array()); - // Get the settings of the default theme. - $settings = array_merge($settings, variable_get('theme_' . variable_get('theme_default', 'garland') . '_settings', array())); - - $types = _update_7000_node_get_types(); - foreach ($types as $type) { - if (isset($settings['toggle_node_info_' . $type->type])) { - variable_set('node_submitted_' . $type->type, $settings['toggle_node_info_' . $type->type]); - } - } - - // Unset deprecated 'toggle_node_info' theme settings. - $theme_settings = variable_get('theme_settings', array()); - foreach ($theme_settings as $setting => $value) { - if (substr($setting, 0, 16) == 'toggle_node_info') { - unset($theme_settings[$setting]); - } - } - variable_set('theme_settings', $theme_settings); -} - -/** - * Shorten the {system}.type column and modify indexes. - */ -function system_update_7018() { - db_drop_index('system', 'modules'); - db_drop_index('system', 'type_name'); - db_change_field('system', 'type', 'type', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => '')); - db_add_index('system', 'type_name', array('type', 'name')); -} - -/** - * Enable field and field_ui modules. - */ -function system_update_7020() { - $module_list = array('field_sql_storage', 'field', 'field_ui'); - module_enable($module_list, FALSE); -} - -/** - * Change the PHP for settings permission. - */ -function system_update_7021() { - db_update('role_permission') - ->fields(array('permission' => 'use PHP for settings')) - ->condition('permission', 'use PHP for block visibility') - ->execute(); -} - -/** - * Enable field type modules. - */ -function system_update_7027() { - $module_list = array('text', 'number', 'list', 'options'); - module_enable($module_list, FALSE); -} - -/** - * Add new 'view own unpublished content' permission for authenticated users. - * Preserves legacy behavior from Drupal 6.x. - */ -function system_update_7029() { - db_insert('role_permission') - ->fields(array( - 'rid' => DRUPAL_AUTHENTICATED_RID, - 'permission' => 'view own unpublished content', - )) - ->execute(); -} - -/** -* Alter field hostname to identifier in the {flood} table. - */ -function system_update_7032() { - db_drop_index('flood', 'allow'); - db_change_field('flood', 'hostname', 'identifier', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '')); - db_add_index('flood', 'allow', array('event', 'identifier', 'timestamp')); -} - -/** - * Move CACHE_AGGRESSIVE to CACHE_NORMAL. - */ -function system_update_7033() { - if (variable_get('cache') == 2) { - variable_set('cache', 1); - return t('Aggressive caching was disabled and replaced with normal caching. Read the page caching section in default.settings.php for more information on how to enable similar functionality.'); - } -} - -/** - * Migrate the file path settings and create the new {file_managed} table. - */ -function system_update_7034() { - $files_directory = variable_get('file_directory_path', NULL); - if (variable_get('file_downloads', 1) == 1) { - // Our default is public, so we don't need to set anything. - if (!empty($files_directory)) { - variable_set('file_public_path', $files_directory); - } - } - elseif (variable_get('file_downloads', 1) == 2) { - variable_set('file_default_scheme', 'private'); - if (!empty($files_directory)) { - variable_set('file_private_path', $files_directory); - } - } - variable_del('file_downloads'); - - $schema['file_managed'] = array( - 'description' => 'Stores information for uploaded files.', - 'fields' => array( - 'fid' => array( - 'description' => 'File ID.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'uid' => array( - 'description' => 'The {user}.uid of the user who is associated with the file.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'filename' => array( - 'description' => 'Name of the file with no path components. This may differ from the basename of the filepath if the file is renamed to avoid overwriting an existing file.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'uri' => array( - 'description' => 'URI of file.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'filemime' => array( - 'description' => "The file's MIME type.", - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'filesize' => array( - 'description' => 'The size of the file in bytes.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'status' => array( - 'description' => 'A field indicating the status of the file. Two status are defined in core: temporary (0) and permanent (1). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'size' => 'tiny', - ), - 'timestamp' => array( - 'description' => 'UNIX timestamp for when the file was added.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - ), - 'indexes' => array( - 'uid' => array('uid'), - 'status' => array('status'), - 'timestamp' => array('timestamp'), - ), - 'unique keys' => array( - 'uri' => array('uri'), - ), - 'primary key' => array('fid'), - ); - - db_create_table('file_managed', $schema['file_managed']); -} - -/** - * Split the 'access site in maintenance mode' permission from 'administer site configuration'. - */ -function system_update_7036() { - // Get existing roles that can 'administer site configuration'. - $rids = db_query("SELECT rid FROM {role_permission} WHERE permission = :perm", array(':perm' => 'administer site configuration'))->fetchCol(); - // None found. - if (empty($rids)) { - return; - } - $insert = db_insert('role_permission')->fields(array('rid', 'permission')); - foreach ($rids as $rid) { - $insert->values(array( - 'rid' => $rid, - 'permission' => 'access site in maintenance mode', - )); - } - $insert->execute(); - - // Remove obsolete variable 'site_offline_message'. See - // update_fix_d7_requirements(). - variable_del('site_offline_message'); -} - -/** - * Upgrade the {url_alias} table and create a cache bin for path aliases. - */ -function system_update_7042() { - // update_fix_d7_requirements() adds 'fake' source and alias columns to - // allow bootstrap to run without fatal errors. Remove those columns now - // so that we can rename properly. - db_drop_field('url_alias', 'source'); - db_drop_field('url_alias', 'alias'); - - // Drop indexes. - db_drop_index('url_alias', 'src_language_pid'); - db_drop_unique_key('url_alias', 'dst_language_pid'); - // Rename the fields, and increase their length to 255 characters. - db_change_field('url_alias', 'src', 'source', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')); - db_change_field('url_alias', 'dst', 'alias', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')); - // Add indexes back. We replace the unique key with an index since it never - // provided any meaningful unique constraint ('pid' is a primary key). - db_add_index('url_alias', 'source_language_pid', array('source', 'language', 'pid')); - db_add_index('url_alias', 'alias_language_pid', array('alias', 'language', 'pid')); -} - -/** - * Drop the actions_aid table. - */ -function system_update_7044() { - // The current value of the increment has been taken into account when - // creating the sequences table in update_fix_d7_requirements(). - db_drop_table('actions_aid'); -} - -/** - * Add expiration field to the {flood} table. - */ -function system_update_7045() { - db_add_field('flood', 'expiration', array('description' => 'Expiration timestamp. Expired events are purged on cron run.', 'type' => 'int', 'not null' => TRUE, 'default' => 0)); - db_add_index('flood', 'purge', array('expiration')); -} - -/** - * Switch from the Minnelli theme if it is the default or admin theme. - */ -function system_update_7046() { - if (variable_get('theme_default') == 'minnelli' || variable_get('admin_theme') == 'minnelli') { - // Make sure Garland is enabled. - db_update('system') - ->fields(array('status' => 1)) - ->condition('type', 'theme') - ->condition('name', 'garland') - ->execute(); - if (variable_get('theme_default') != 'garland') { - // If the default theme isn't Garland, transfer all of Minnelli's old - // settings to Garland. - $settings = variable_get('theme_minnelli_settings', array()); - // Set the theme setting width to "fixed" to match Minnelli's old layout. - $settings['garland_width'] = 'fixed'; - variable_set('theme_garland_settings', $settings); - // Remove Garland's color files since they won't match Minnelli's. - foreach (variable_get('color_garland_files', array()) as $file) { - @drupal_unlink($file); - } - if (isset($file) && $file = dirname($file)) { - @drupal_rmdir($file); - } - variable_del('color_garland_palette'); - variable_del('color_garland_stylesheets'); - variable_del('color_garland_logo'); - variable_del('color_garland_files'); - variable_del('color_garland_screenshot'); - } - if (variable_get('theme_default') == 'minnelli') { - variable_set('theme_default', 'garland'); - } - if (variable_get('admin_theme') == 'minnelli') { - variable_set('admin_theme', 'garland'); - } - } -} - -/** - * Normalize the front page path variable. - */ -function system_update_7047() { - variable_set('site_frontpage', drupal_get_normal_path(variable_get('site_frontpage', 'node'))); -} - -/** - * Convert path languages from the empty string to LANGUAGE_NONE. - */ -function system_update_7048() { - db_update('url_alias') - ->fields(array('language' => LANGUAGE_NONE)) - ->condition('language', '') - ->execute(); -} - -/** - * Rename 'Default' profile to 'Standard.' - */ -function system_update_7049() { - if (variable_get('install_profile', 'standard') == 'default') { - variable_set('install_profile', 'standard'); - } -} - -/** - * Change {batch}.id column from serial to regular int. - */ -function system_update_7050() { - db_change_field('batch', 'bid', 'bid', array('description' => 'Primary Key: Unique batch ID.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE)); -} - -/** - * make the IP field IPv6 compatible - */ -function system_update_7051() { - db_change_field('blocked_ips', 'ip', 'ip', array('description' => 'IP address', 'type' => 'varchar', 'length' => 40, 'not null' => TRUE, 'default' => '')); -} - -/** - * Rename file to include_file in {menu_router} table. - */ -function system_update_7052() { - db_change_field('menu_router', 'file', 'include_file', array('type' => 'text', 'size' => 'medium')); -} - -/** - * Upgrade standard blocks and menus. - */ -function system_update_7053() { - if (db_table_exists('menu_custom')) { - // Create the same menus as in menu_install(). - db_insert('menu_custom') - ->fields(array('menu_name' => 'user-menu', 'title' => 'User Menu', 'description' => "The User menu contains links related to the user's account, as well as the 'Log out' link.")) - ->execute(); - - db_insert('menu_custom') - ->fields(array('menu_name' => 'management', 'title' => 'Management', 'description' => "The Management menu contains links for administrative tasks.")) - ->execute(); - } - - block_flush_caches(); - - // Show the new menu blocks along the navigation block. - $blocks = db_query("SELECT theme, status, region, weight, visibility, pages FROM {block} WHERE module = 'system' AND delta = 'navigation'"); - $deltas = db_or() - ->condition('delta', 'user-menu') - ->condition('delta', 'management'); - - foreach ($blocks as $block) { - db_update('block') - ->fields(array( - 'status' => $block->status, - 'region' => $block->region, - 'weight' => $block->weight, - 'visibility' => $block->visibility, - 'pages' => $block->pages, - )) - ->condition('theme', $block->theme) - ->condition('module', 'system') - ->condition($deltas) - ->execute(); - } -} - -/** - * Remove {cache_*}.headers columns. - */ -function system_update_7054() { - // Update: update_fix_d7_requirements() installs this version for cache_path - // already, so we don't include it in this particular update. It should be - // included in later updates though. - $cache_tables = array( - 'cache' => 'Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.', - 'cache_form' => 'Cache table for the form system to store recently built forms and their storage data, to be used in subsequent page requests.', - 'cache_page' => 'Cache table used to store compressed pages for anonymous users, if page caching is enabled.', - 'cache_menu' => 'Cache table for the menu system to store router information as well as generated link trees for various menu/page/user combinations.', - ); - $schema = system_schema_cache_7054(); - foreach ($cache_tables as $table => $description) { - $schema['description'] = $description; - db_drop_table($table); - db_create_table($table, $schema); - } -} - -/** - * Converts fields that store serialized variables from text to blob. - */ -function system_update_7055() { - $spec = array( - 'description' => 'The value of the variable.', - 'type' => 'blob', - 'not null' => TRUE, - 'size' => 'big', - 'translatable' => TRUE, - ); - db_change_field('variable', 'value', 'value', $spec); - - $spec = array( - 'description' => 'Parameters to be passed to the callback function.', - 'type' => 'blob', - 'not null' => TRUE, - 'size' => 'big', - ); - db_change_field('actions', 'parameters', 'parameters', $spec); - - $spec = array( - 'description' => 'A serialized array containing the processing data for the batch.', - 'type' => 'blob', - 'not null' => FALSE, - 'size' => 'big', - ); - db_change_field('batch', 'batch', 'batch', $spec); - - $spec = array( - 'description' => 'A serialized array of function names (like node_load) to be called to load an object corresponding to a part of the current path.', - 'type' => 'blob', - 'not null' => TRUE, - ); - db_change_field('menu_router', 'load_functions', 'load_functions', $spec); - - $spec = array( - 'description' => 'A serialized array of function names (like user_uid_optional_to_arg) to be called to replace a part of the router path with another string.', - 'type' => 'blob', - 'not null' => TRUE, - ); - db_change_field('menu_router', 'to_arg_functions', 'to_arg_functions', $spec); - - $spec = array( - 'description' => 'A serialized array of arguments for the access callback.', - 'type' => 'blob', - 'not null' => FALSE, - ); - db_change_field('menu_router', 'access_arguments', 'access_arguments', $spec); - - $spec = array( - 'description' => 'A serialized array of arguments for the page callback.', - 'type' => 'blob', - 'not null' => FALSE, - ); - db_change_field('menu_router', 'page_arguments', 'page_arguments', $spec); - - $spec = array( - 'description' => 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.', - 'type' => 'blob', - 'not null' => FALSE, - 'translatable' => TRUE, - ); - db_change_field('menu_links', 'options', 'options', $spec); - - $spec = array( - 'description' => 'The serialized contents of $_SESSION, an array of name/value pairs that persists across page requests by this session ID. Drupal loads $_SESSION from here at the start of each request and saves it at the end.', - 'type' => 'blob', - 'not null' => FALSE, - 'size' => 'big', - ); - db_change_field('sessions', 'session', 'session', $spec); - - $spec = array( - 'description' => "A serialized array containing information from the module's .info file; keys can include name, description, package, version, core, dependencies, and php.", - 'type' => 'blob', - 'not null' => FALSE, - ); - db_change_field('system', 'info', 'info', $spec); -} - -/** - * Increase the size of session-ids. - */ -function system_update_7057() { - $spec = array( - 'description' => "A session ID. The value is generated by PHP's Session API.", - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - ); - db_change_field('sessions', 'sid', 'sid', $spec); -} - -/** - * Remove cron semaphore variable. - */ -function system_update_7058() { - variable_del('cron_semaphore'); -} - -/** - * Create the {file_usage} table. - */ -function system_update_7059() { - $spec = array( - 'description' => 'Track where a file is used.', - 'fields' => array( - 'fid' => array( - 'description' => 'File ID.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'module' => array( - 'description' => 'The name of the module that is using the file.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'type' => array( - 'description' => 'The name of the object type in which the file is used.', - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - 'default' => '', - ), - 'id' => array( - 'description' => 'The primary key of the object using the file.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'count' => array( - 'description' => 'The number of times this file is used by this object.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - ), - 'primary key' => array('fid', 'type', 'id', 'module'), - 'indexes' => array( - 'type_id' => array('type', 'id'), - 'fid_count' => array('fid', 'count'), - 'fid_module' => array('fid', 'module'), - ), - ); - db_create_table('file_usage', $spec); -} - -/** - * Create fields in preparation for migrating upload.module to file.module. - */ -function system_update_7060() { - if (!db_table_exists('upload')) { - return; - } - - if (!db_query_range('SELECT 1 FROM {upload}', 0, 1)->fetchField()) { - // There is nothing to migrate. Delete variables and the empty table. There - // is no need to create fields that are not going to be used. - foreach (_update_7000_node_get_types() as $node_type) { - variable_del('upload_' . $node_type->type); - } - db_drop_table('upload'); - return; - } - - // Check which node types have upload.module attachments enabled. - $context['types'] = array(); - foreach (_update_7000_node_get_types() as $node_type) { - if (variable_get('upload_' . $node_type->type, 0)) { - $context['types'][$node_type->type] = $node_type->type; - } - } - - // The {upload} table will be deleted when this update is complete so we - // want to be careful to migrate all the data, even for node types that - // may have had attachments disabled after files were uploaded. Look for - // any other node types referenced by the upload records and add those to - // the list. The admin can always remove the field later. - $results = db_query('SELECT DISTINCT type FROM {node} n INNER JOIN {node_revision} nr ON n.nid = nr.nid INNER JOIN {upload} u ON nr.vid = u.vid'); - foreach ($results as $row) { - if (!isset($context['types'][$row->type])) { - drupal_set_message(t('The content type %rowtype had uploads disabled but contained uploaded file data. Uploads have been re-enabled to migrate the existing data. You may delete the "File attachments" field in the %rowtype type if this data is not necessary.', array('%rowtype' => $row->type))); - $context['types'][$row->type] = $row->type; - } - } - - // Create a single "upload" field on all the content types that have uploads - // enabled, then add an instance to each enabled type. - if (count($context['types']) > 0) { - module_enable(array('file')); - $field = array( - 'field_name' => 'upload', - 'type' => 'file', - 'module' => 'file', - 'locked' => FALSE, - 'cardinality' => FIELD_CARDINALITY_UNLIMITED, - 'translatable' => FALSE, - 'settings' => array( - 'display_field' => 1, - 'display_default' => variable_get('upload_list_default', 1), - 'uri_scheme' => file_default_scheme(), - 'default_file' => 0, - ), - ); - - $upload_size = variable_get('upload_uploadsize_default', 1); - $instance = array( - 'field_name' => 'upload', - 'entity_type' => 'node', - 'bundle' => NULL, - 'label' => 'File attachments', - 'required' => 0, - 'description' => '', - 'widget' => array( - 'weight' => '1', - 'settings' => array( - 'progress_indicator' => 'throbber', - ), - 'type' => 'file_generic', - ), - 'settings' => array( - 'max_filesize' => $upload_size ? ($upload_size . ' MB') : '', - 'file_extensions' => variable_get('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'), - 'file_directory' => '', - 'description_field' => 1, - ), - 'display' => array( - 'default' => array( - 'label' => 'hidden', - 'type' => 'file_table', - 'settings' => array(), - 'weight' => 0, - 'module' => 'file', - ), - 'full' => array( - 'label' => 'hidden', - 'type' => 'file_table', - 'settings' => array(), - 'weight' => 0, - 'module' => 'file', - ), - 'teaser' => array( - 'label' => 'hidden', - 'type' => 'hidden', - 'settings' => array(), - 'weight' => 0, - 'module' => NULL, - ), - 'rss' => array( - 'label' => 'hidden', - 'type' => 'file_table', - 'settings' => array(), - 'weight' => 0, - 'module' => 'file', - ), - ), - ); - - // Create the field. - _update_7000_field_create_field($field); - - // Create the instances. - foreach ($context['types'] as $bundle) { - $instance['bundle'] = $bundle; - _update_7000_field_create_instance($field, $instance); - // Now that the instance is created, we can safely delete any legacy - // node type information. - variable_del('upload_' . $bundle); - } - } - else { - // No uploads or content types with uploads enabled. - db_drop_table('upload'); - } -} - -/** - * Migrate upload.module data to the newly created file field. - */ -function system_update_7061(&$sandbox) { - if (!db_table_exists('upload')) { - return; - } - - if (!isset($sandbox['progress'])) { - // Retrieve a list of node revisions that have uploaded files attached. - // DISTINCT queries are expensive, especially when paged, so we store the - // data in its own table for the duration of the update. - $table = array( - 'description' => t('Stores temporary data for system_update_7061.'), - 'fields' => array('vid' => array('type' => 'int')), - 'primary key' => array('vid'), - ); - db_create_table('system_update_7061', $table); - $query = db_select('upload', 'u'); - $query->distinct(); - $query->addField('u','vid'); - db_insert('system_update_7061') - ->from($query) - ->execute(); - - // Initialize batch update information. - $sandbox['progress'] = 0; - $sandbox['last_vid_processed'] = -1; - $sandbox['max'] = db_query("SELECT COUNT(*) FROM {system_update_7061}")->fetchField(); - } - - // Determine vids for this batch. - // Process all files attached to a given revision during the same batch. - $limit = variable_get('upload_update_batch_size', 100); - $vids = db_query_range('SELECT vid FROM {system_update_7061} WHERE vid > :lastvid ORDER BY vid', 0, $limit, array(':lastvid' => $sandbox['last_vid_processed'])) - ->fetchCol(); - - // Retrieve information on all the files attached to these revisions. - if (!empty($vids)) { - $node_revisions = array(); - $result = db_query('SELECT u.fid, u.vid, u.list, u.description, n.nid, n.type, u.weight FROM {upload} u INNER JOIN {node_revision} nr ON u.vid = nr.vid INNER JOIN {node} n ON n.nid = nr.nid WHERE u.vid IN (:vids) ORDER BY u.vid, u.weight, u.fid', array(':vids' => $vids)); - foreach ($result as $record) { - // For each uploaded file, retrieve the corresponding data from the old - // files table (since upload doesn't know about the new entry in the - // file_managed table). - $file = db_select('files', 'f') - ->fields('f', array('fid', 'uid', 'filename', 'filepath', 'filemime', 'filesize', 'status', 'timestamp')) - ->condition('f.fid', $record->fid) - ->execute() - ->fetchAssoc(); - if (!$file) { - continue; - } - - // Add in the file information from the upload table. - $file['description'] = $record->description; - $file['display'] = $record->list; - - // Create one record for each revision that contains all the uploaded - // files. - $node_revisions[$record->vid]['nid'] = $record->nid; - $node_revisions[$record->vid]['vid'] = $record->vid; - $node_revisions[$record->vid]['type'] = $record->type; - $node_revisions[$record->vid]['file'][LANGUAGE_NONE][] = $file; - } - - // Now that we know which files belong to which revisions, update the - // files'// database entries, and save a reference to each file in the - // upload field on their node revisions. - $basename = variable_get('file_directory_path', conf_path() . '/files'); - $scheme = file_default_scheme() . '://'; - foreach ($node_revisions as $vid => $revision) { - foreach ($revision['file'][LANGUAGE_NONE] as $delta => $file) { - // We will convert filepaths to uri using the default scheme - // and stripping off the existing file directory path. - $file['uri'] = $scheme . str_replace($basename, '', $file['filepath']); - $file['uri'] = file_stream_wrapper_uri_normalize($file['uri']); - unset($file['filepath']); - // Insert into the file_managed table. - // Each fid should only be stored once in file_managed. - db_merge('file_managed') - ->key(array( - 'fid' => $file['fid'], - )) - ->fields(array( - 'uid' => $file['uid'], - 'filename' => $file['filename'], - 'uri' => $file['uri'], - 'filemime' => $file['filemime'], - 'filesize' => $file['filesize'], - 'status' => $file['status'], - 'timestamp' => $file['timestamp'], - )) - ->execute(); - - // Add the usage entry for the file. - $file = (object) $file; - file_usage_add($file, 'file', 'node', $revision['nid']); - - // Update the node revision's upload file field with the file data. - $revision['file'][LANGUAGE_NONE][$delta] = array('fid' => $file->fid, 'display' => $file->display, 'description' => $file->description); - } - - // Write the revision's upload field data into the field_upload tables. - $node = (object) $revision; - _update_7000_field_sql_storage_write('node', $node->type, $node->nid, $node->vid, 'upload', $node->file); - - // Update our progress information for the batch update. - $sandbox['progress']++; - $sandbox['last_vid_processed'] = $vid; - } - } - - // If less than limit node revisions were processed, the update process is - // finished. - if (count($vids) < $limit) { - $finished = TRUE; - } - - // If there's no max value then there's nothing to update and we're finished. - if (empty($sandbox['max']) || isset($finished)) { - db_drop_table('upload'); - db_drop_table('system_update_7061'); - return t('Upload module has been migrated to File module.'); - } - else { - // Indicate our current progress to the batch update system. - $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; - } -} - -/** - * Replace 'system_list' index with 'bootstrap' index on {system}. - */ -function system_update_7062() { - db_drop_index('system', 'bootstrap'); - db_drop_index('system', 'system_list'); - db_add_index('system', 'system_list', array('status', 'bootstrap', 'type', 'weight', 'name')); -} - -/** - * Delete {menu_links} records for 'type' => MENU_CALLBACK which would not appear in a fresh install. - */ -function system_update_7063() { - // For router items where 'type' => MENU_CALLBACK, {menu_router}.type is - // stored as 4 in Drupal 6, and 0 in Drupal 7. Fortunately Drupal 7 doesn't - // store any types as 4, so delete both. - $result = db_query('SELECT ml.mlid FROM {menu_links} ml INNER JOIN {menu_router} mr ON ml.router_path = mr.path WHERE ml.module = :system AND ml.customized = 0 AND mr.type IN(:callbacks)', array(':callbacks' => array(0, 4), ':system' => 'system')); - foreach ($result as $record) { - db_delete('menu_links')->condition('mlid', $record->mlid)->execute(); - } -} - -/** - * Remove block_callback field from {menu_router}. - */ -function system_update_7064() { - db_drop_field('menu_router', 'block_callback'); -} - -/** - * Remove the default value for sid. - */ -function system_update_7065() { - $spec = array( - 'description' => "A session ID. The value is generated by Drupal's session handlers.", - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - ); - db_drop_primary_key('sessions'); - db_change_field('sessions', 'sid', 'sid', $spec, array('primary key' => array('sid', 'ssid'))); - // Delete any sessions with empty session ID. - db_delete('sessions')->condition('sid', '')->execute(); -} - -/** - * Migrate the 'file_directory_temp' variable. - */ -function system_update_7066() { - $d6_file_directory_temp = variable_get('file_directory_temp', file_directory_temp()); - variable_set('file_temporary_path', $d6_file_directory_temp); - variable_del('file_directory_temp'); -} - -/** - * Grant administrators permission to view the administration theme. - */ -function system_update_7067() { - // Users with access to administration pages already see the administration - // theme in some places (if one is enabled on the site), so we want them to - // continue seeing it. - $admin_roles = user_roles(FALSE, 'access administration pages'); - foreach (array_keys($admin_roles) as $rid) { - _update_7000_user_role_grant_permissions($rid, array('view the administration theme'), 'system'); - } - // The above check is not guaranteed to reach all administrative users of the - // site, so if the site is currently using an administration theme, display a - // message also. - if (variable_get('admin_theme')) { - if (empty($admin_roles)) { - drupal_set_message('The new "View the administration theme" permission is required in order to view your site\'s administration theme. You can grant this permission to your site\'s administrators on the permissions page.'); - } - else { - drupal_set_message('The new "View the administration theme" permission is required in order to view your site\'s administration theme. This permission has been automatically granted to the following roles: ' . check_plain(implode(', ', $admin_roles)) . '. You can grant this permission to other roles on the permissions page.'); - } - } -} - -/** - * Update {url_alias}.language description. - */ -function system_update_7068() { - $spec = array( - 'description' => "The language this alias is for; if 'und', the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.", - 'type' => 'varchar', - 'length' => 12, - 'not null' => TRUE, - 'default' => '', - ); - db_change_field('url_alias', 'language', 'language', $spec); -} - -/** - * Remove the obsolete 'site_offline' variable. - * - * @see update_fix_d7_requirements() + * Placeholder update to set the schema version to 8000. */ -function system_update_7069() { - variable_del('site_offline'); +function system_update_8000() { + // Fill in the first update to Drupal 8 when needed. } /** - * @} End of "defgroup updates-6.x-to-7.x" - * The next series of updates should start at 8000. + * @} End of "defgroup updates-7.x-to-8.x" + * The next series of updates should start at 9000. */ diff --git modules/taxonomy/taxonomy.install modules/taxonomy/taxonomy.install index f28ffed..10009d6 100644 --- modules/taxonomy/taxonomy.install +++ modules/taxonomy/taxonomy.install @@ -241,581 +241,3 @@ function taxonomy_field_schema($field) { ), ); } - -/** - * Implements hook_update_dependencies(). - */ -function taxonomy_update_dependencies() { - // Taxonomy update 7002 creates comment Field API bundles and therefore must - // run after the Field module has been enabled, but before upgrading field - // data. - $dependencies['taxonomy'][7002] = array( - 'system' => 7049, - ); - $dependencies['user'][7006] = array( - 'taxonomy' => 7002, - ); - $dependencies['system'][7050] = array( - 'taxonomy' => 7002, - ); - // It also must run before nodes are upgraded to use the Field API. - $dependencies['node'][7006] = array( - 'taxonomy' => 7002, - ); - // Ensure that format columns are only changed after Filter module has changed - // the primary records. - $dependencies['taxonomy'][7009] = array( - 'filter' => 7010, - ); - - return $dependencies; -} - -/** - * Utility function: get the list of vocabularies directly from the database. - * - * This function is valid for a database schema version 7002. - * - * @ingroup update-api-6.x-to-7.x - */ -function _update_7002_taxonomy_get_vocabularies() { - return db_query('SELECT v.* FROM {taxonomy_vocabulary} v ORDER BY v.weight, v.name')->fetchAllAssoc('vid', PDO::FETCH_OBJ); -} - -/** - * Rename taxonomy tables. - */ -function taxonomy_update_7001() { - db_rename_table('term_data', 'taxonomy_term_data'); - db_rename_table('term_hierarchy', 'taxonomy_term_hierarchy'); - db_rename_table('term_node', 'taxonomy_term_node'); - db_rename_table('term_relation', 'taxonomy_term_relation'); - db_rename_table('term_synonym', 'taxonomy_term_synonym'); - db_rename_table('vocabulary', 'taxonomy_vocabulary'); - db_rename_table('vocabulary_node_types', 'taxonomy_vocabulary_node_type'); -} - -/** - * Add {vocabulary}.machine_name column. - */ -function taxonomy_update_7002() { - $field = array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - 'description' => 'The vocabulary machine name.', - ); - - db_add_field('taxonomy_vocabulary', 'machine_name', $field); - - // Do a direct query here, rather than calling taxonomy_get_vocabularies(), - // in case Taxonomy module is disabled. - $vids = db_query('SELECT vid FROM {taxonomy_vocabulary}')->fetchCol(); - foreach ($vids as $vid) { - $machine_name = 'vocabulary_' . $vid; - db_update('taxonomy_vocabulary') - ->fields(array('machine_name' => $machine_name)) - ->condition('vid', $vid) - ->execute(); - } - - // The machine_name unique key can only be added after we ensure the - // machine_name column contains unique values. - db_add_unique_key('taxonomy_vocabulary', 'machine_name', array('machine_name')); -} - -/** - * Remove the related terms setting from vocabularies. - * - * This setting has not been used since Drupal 6. The {taxonomy_relations} table - * itself is retained to allow for data to be upgraded. - */ -function taxonomy_update_7003() { - db_drop_field('taxonomy_vocabulary', 'relations'); -} - -/** - * Move taxonomy vocabulary associations for nodes to fields and field instances. - */ -function taxonomy_update_7004() { - $taxonomy_index = array( - 'description' => 'Maintains denormalized information about node/term relationships.', - 'fields' => array( - 'nid' => array( - 'description' => 'The {node}.nid this record tracks.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'tid' => array( - 'description' => 'The term ID.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'sticky' => array( - 'description' => 'Boolean indicating whether the node is sticky.', - 'type' => 'int', - 'not null' => FALSE, - 'default' => 0, - 'size' => 'tiny', - ), - 'created' => array( - 'description' => 'The Unix timestamp when the node was created.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default'=> 0, - ), - ), - 'indexes' => array( - 'term_node' => array('tid', 'sticky', 'created'), - 'nid' => array('nid'), - ), - 'foreign keys' => array( - 'tracked_node' => array( - 'table' => 'node', - 'columns' => array('nid' => 'nid'), - ), - 'term' => array( - 'table' => 'taxonomy_term_data', - 'columns' => array('tid' => 'tid'), - ), - ), - ); - db_create_table('taxonomy_index', $taxonomy_index); - - // Use an inline version of Drupal 6 taxonomy_get_vocabularies() here since - // we can no longer rely on $vocabulary->nodes from the API function. - $result = db_query('SELECT v.*, n.type FROM {taxonomy_vocabulary} v LEFT JOIN {taxonomy_vocabulary_node_type} n ON v.vid = n.vid ORDER BY v.weight, v.name'); - $vocabularies = array(); - foreach ($result as $record) { - // If no node types are associated with a vocabulary, the LEFT JOIN will - // return a NULL value for type. - if (isset($record->type)) { - $node_types[$record->vid][$record->type] = $record->type; - unset($record->type); - $record->nodes = $node_types[$record->vid]; - } - elseif (!isset($record->nodes)) { - $record->nodes = array(); - } - $vocabularies[$record->vid] = $record; - } - - foreach ($vocabularies as $vocabulary) { - $field_name = 'taxonomy_' . $vocabulary->machine_name; - $field = array( - 'field_name' => $field_name, - 'module' => 'taxonomy', - 'type' => 'taxonomy_term_reference', - 'cardinality' => $vocabulary->multiple || $vocabulary->tags ? FIELD_CARDINALITY_UNLIMITED : 1, - 'settings' => array( - 'required' => $vocabulary->required ? TRUE : FALSE, - 'allowed_values' => array( - array( - 'vocabulary' => $vocabulary->machine_name, - 'parent' => 0, - ), - ), - ), - ); - _update_7000_field_create_field($field); - - foreach ($vocabulary->nodes as $bundle) { - $instance = array( - 'label' => $vocabulary->name, - 'field_name' => $field_name, - 'bundle' => $bundle, - 'entity_type' => 'node', - 'settings' => array(), - 'description' => $vocabulary->help, - 'widget' => array(), - 'display' => array( - 'default' => array( - 'type' => 'taxonomy_term_reference_link', - 'weight' => 10, - ), - 'teaser' => array( - 'type' => 'taxonomy_term_reference_link', - 'weight' => 10, - ), - ), - ); - if ($vocabulary->tags) { - $instance['widget'] = array( - 'type' => 'taxonomy_autocomplete', - 'module' => 'taxonomy', - 'settings' => array( - 'size' => 60, - 'autocomplete_path' => 'taxonomy/autocomplete', - ), - ); - } - else { - $instance['widget'] = array( - 'type' => 'select', - 'module' => 'options', - 'settings' => array(), - ); - } - _update_7000_field_create_instance($field, $instance); - } - } - - // Some contrib projects stored term node associations without regard for the - // selections in the taxonomy_vocabulary_node_types table, or have more terms - // for a single node than the vocabulary allowed. We construct the - // taxonomyextra field to store all the extra stuff. - - // Allowed values for this extra vocabs field is every vocabulary. - $allowed_values = array(); - foreach (_update_7002_taxonomy_get_vocabularies() as $vocabulary) { - $allowed_values[] = array( - 'vocabulary' => $vocabulary->machine_name, - 'parent' => 0, - ); - } - - $field_name = 'taxonomyextra'; - $field = array( - 'field_name' => $field_name, - 'module' => 'taxonomy', - 'type' => 'taxonomy_term_reference', - 'cardinality' => FIELD_CARDINALITY_UNLIMITED, - 'settings' => array( - 'required' => FALSE, - 'allowed_values' => $allowed_values, - ), - ); - _update_7000_field_create_field($field); - - foreach (_update_7000_node_get_types() as $bundle) { - $instance = array( - 'label' => 'Taxonomy upgrade extras', - 'field_name' => $field_name, - 'entity_type' => 'node', - 'bundle' => $bundle->type, - 'settings' => array(), - 'description' => 'Debris left over after upgrade from Drupal 6', - 'widget' => array( - 'type' => 'taxonomy_autocomplete', - 'module' => 'taxonomy', - 'settings' => array(), - ), - 'display' => array( - 'default' => array( - 'type' => 'taxonomy_term_reference_link', - 'weight' => 10, - ), - 'teaser' => array( - 'type' => 'taxonomy_term_reference_link', - 'weight' => 10, - ), - ), - ); - _update_7000_field_create_instance($field, $instance); - } - - $fields = array('help', 'multiple', 'required', 'tags'); - foreach ($fields as $field) { - db_drop_field('taxonomy_vocabulary', $field); - } -} - -/** - * Migrate {taxonomy_term_node} table to field storage. - * - * @todo: This function can possibly be made much faster by wrapping a - * transaction around all the inserts. - */ -function taxonomy_update_7005(&$sandbox) { - // $sandbox contents: - // - total: The total number of term_node relationships to migrate. - // - count: The number of term_node relationships that have been - // migrated so far. - // - last: The db_query_range() offset to use when querying - // term_node; this field is incremented in quantities of $batch - // (1000) but at the end of each call to this function, last and - // count are the same. - // - vocabularies: An associative array mapping vocabulary id and node - // type to field name. If a voc id/node type pair does not appear - // in this array but a term_node relationship exists mapping a - // term in voc id to node of that type, the relationship is - // assigned to the taxonomymyextra field which allows terms of all - // vocabularies. - // - cursor[values], cursor[deltas]: The contents of $values and - // $deltas at the end of the previous call to this function. These - // need to be preserved across calls because a single batch of - // 1000 rows from term_node may end in the middle of the terms for - // a single node revision. - // - // $values is the array of values about to be/most recently inserted - // into the SQL data table for the taxonomy_term_reference - // field. Before $values is constructed for each record, the - // $values from the previous insert is checked to see if the two - // records are for the same node revision id; this enables knowing - // when to reset the delta counters which are incremented across all - // terms for a single field on a single revision, but reset for each - // new field and revision. - // - // $deltas is an associative array mapping field name to the number - // of term references stored so far for the current revision, which - // provides the delta value for each term reference data insert. The - // deltas are reset for each new revision. - - $conditions = array( - 'type' => 'taxonomy_term_reference', - 'deleted' => 0, - ); - $field_info = _update_7000_field_read_fields($conditions, 'field_name'); - - // This is a multi-pass update. On the first call we need to initialize some - // variables. - if (!isset($sandbox['total'])) { - $sandbox['last'] = 0; - $sandbox['count'] = 0; - - // Run the same joins as the query that is used later to retrieve the - // term_node data, this ensures that bad records in that table - for - // tids which aren't in taxonomy_term_data or nids which aren't in {node} - // are not included in the count. - $sandbox['total'] = db_query('SELECT COUNT(*) FROM {taxonomy_term_data} td INNER JOIN {taxonomy_term_node} tn ON td.tid = tn.tid INNER JOIN {node} n ON tn.nid = n.nid LEFT JOIN {node} n2 ON tn.vid = n2.vid')->fetchField(); - - // Use an inline version of Drupal 6 taxonomy_get_vocabularies() here since - // we can no longer rely on $vocabulary->nodes from the API function. - $result = db_query('SELECT v.vid, v.machine_name, n.type FROM {taxonomy_vocabulary} v INNER JOIN {taxonomy_vocabulary_node_type} n ON v.vid = n.vid'); - $vocabularies = array(); - foreach ($result as $record) { - - // If no node types are associated with a vocabulary, the LEFT JOIN will - // return a NULL value for type. - if (isset($record->type)) { - $vocabularies[$record->vid][$record->type] = 'taxonomy_'. $record->machine_name; - } - } - - if (!empty($vocabularies)) { - $sandbox['vocabularies'] = $vocabularies; - } - } - else { - // We do each pass in batches of 1000. - $batch = 1000; - - // Query selects all revisions at once and processes them in revision and - // term weight order. Join types: - // - // - INNER JOIN term_node ON tn.tid: We are migrating term-node - // relationships. If there are none for a term, we do not need the - // term_data row. - // - INNER JOIN {node} n ON n.nid: If a term-node relationship exists for a - // nid that does not exist, we cannot migrate it as we have no node to - // relate it to; thus we do not need that row from term_node. - // - LEFT JOIN {node} n2 ON n2.vid: If the current term-node relationship - // is for the current revision of the node, this left join will match and - // is_current will be non-NULL (we also get the current sticky and - // created in this case). This tells us whether to insert into the - // current data tables in addition to the revision data tables. - // - // This query must return a consistent ordering across multiple calls. We - // need them ordered by node vid (since we use that to decide when to reset - // the delta counters) and by term weight so they appear within each node - // in weight order. However, tn.vid,td.weight is not guaranteed to be - // unique, so we add tn.tid as an additional sort key because tn.tid,tn.vid - // is the primary key of the D6 term_node table and so is guaranteed - // unique. Unfortunately it also happens to be in the wrong order which is - // less efficient, but c'est la vie. - $query = 'SELECT td.vid AS vocab_id, td.tid, tn.nid, tn.vid, n.type, n2.created, n2.sticky, n2.nid AS is_current FROM {taxonomy_term_data} td INNER JOIN {taxonomy_term_node} tn ON td.tid = tn.tid INNER JOIN {node} n ON tn.nid = n.nid LEFT JOIN {node} n2 ON tn.vid = n2.vid ORDER BY tn.vid, td.weight ASC, tn.tid'; - $result = db_query_range($query, $sandbox['last'], $batch); - if (isset($sandbox['cursor'])) { - $values = $sandbox['cursor']['values']; - $deltas = $sandbox['cursor']['deltas']; - } - else { - $deltas = array(); - } - foreach ($result as $record) { - $sandbox['count'] += 1; - - // Use the valid field for this vocabulary and node type or use the - // overflow vocabulary if there is no valid field. - $field_name = isset($sandbox['vocabularies'][$record->vocab_id][$record->type]) ? $sandbox['vocabularies'][$record->vocab_id][$record->type] : 'taxonomyextra'; - $field = $field_info[$field_name]; - - // Start deltas from 0, and increment by one for each term attached to a - // node. - if (!isset($deltas[$field_name])) { - $deltas[$field_name] = 0; - } - - if (isset($values)) { - - // If the last inserted revision_id is the same as the current record, - // use the previous deltas to calculate the next delta. - if ($record->vid == $values[2]) { - - // For limited cardinality fields, the delta must not be allowed to - // exceed the cardinality during the update. So ensure that the - // delta about to be inserted is within this limit. - // @see field_default_validate(). - if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED && ($deltas[$field_name] + 1) > $field['cardinality']) { - - // For excess values of a single-term vocabulary, switch over to - // the overflow field. - $field_name = 'taxonomyextra'; - $field = $field_info[$field_name]; - if (!isset($deltas[$field_name])) { - $deltas[$field_name] = 0; - } - } - } - else { - - // When the record is a new revision, empty the deltas array. - $deltas = array($field_name => 0); - } - } - - // Table and column found in the field's storage details. During upgrades, - // it's always SQL. - $table_name = "field_data_{$field_name}"; - $revision_name = "field_revision_{$field_name}"; - $value_column = $field_name . '_tid'; - - // Column names and values in field storage are the same for current and - // revision. - $columns = array('entity_type', 'entity_id', 'revision_id', 'bundle', 'language', 'delta', $value_column); - $values = array('node', $record->nid, $record->vid, $record->type, LANGUAGE_NONE, $deltas[$field_name]++, $record->tid); - - // Insert rows into the revision table. - db_insert($revision_name)->fields($columns)->values($values)->execute(); - - // is_current column is a node ID if this revision is also current. - if ($record->is_current) { - db_insert($table_name)->fields($columns)->values($values)->execute(); - - // Update the {taxonomy_index} table. - db_insert('taxonomy_index') - ->fields(array('nid', 'tid', 'sticky', 'created',)) - ->values(array($record->nid, $record->tid, $record->sticky, $record->created)) - ->execute(); - } - } - - // Store the set of inserted values and the current revision's deltas in the - // sandbox. - $sandbox['cursor'] = array( - 'values' => $values, - 'deltas' => $deltas, - ); - $sandbox['last'] += $batch; - } - - if ($sandbox['count'] < $sandbox['total']) { - $sandbox['#finished'] = FALSE; - } - else { - db_drop_table('taxonomy_vocabulary_node_type'); - db_drop_table('taxonomy_term_node'); - - // If there are no vocabs, we're done. - $sandbox['#finished'] = TRUE; - - // Determine necessity of taxonomyextras field. - $field = $field_info['taxonomyextra']; - $revision_name = 'field_revision_' . $field['field_name']; - $node_types = db_select($revision_name)->distinct()->fields($revision_name, array('bundle')) - ->execute()->fetchCol(); - - if (empty($node_types)) { - // Delete the overflow field if there are no rows in the revision table. - _update_7000_field_delete_field('taxonomyextra'); - } - else { - // Remove instances which are not actually used. - $bundles = db_query('SELECT bundle FROM {field_config_instance} WHERE field_name = :field_name', array(':field_name' => 'taxonomyextra'))->fetchCol(); - $bundles = array_diff($bundles, $node_types); - foreach ($bundles as $bundle) { - _update_7000_field_delete_instance('taxonomyextra', 'node', $bundle); - } - } - } -} - -/** - * Add {taxonomy_term_data}.format column. - */ -function taxonomy_update_7006() { - db_add_field('taxonomy_term_data', 'format', array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => FALSE, - 'description' => 'The {filter_format}.format of the description.', - )); -} - -/** - * Add index on {taxonomy_term_data}.name column to speed up taxonomy_get_term_by_name(). - */ -function taxonomy_update_7007() { - db_add_index('taxonomy_term_data', 'name', array('name')); -} - -/** - * Change the weight columns to normal int. - */ -function taxonomy_update_7008() { - db_drop_index('taxonomy_term_data', 'taxonomy_tree'); - db_change_field('taxonomy_term_data', 'weight', 'weight', array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The weight of this term in relation to other terms.', - ), array( - 'indexes' => array( - 'taxonomy_tree' => array('vid', 'weight', 'name'), - ), - )); - - db_drop_index('taxonomy_vocabulary', 'list'); - db_change_field('taxonomy_vocabulary', 'weight', 'weight', array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The weight of this vocabulary in relation to other vocabularies.', - ), array( - 'indexes' => array( - 'list' => array('weight', 'name'), - ), - )); -} - -/** - * Change {taxonomy_term_data}.format into varchar. - */ -function taxonomy_update_7009() { - db_change_field('taxonomy_term_data', 'format', 'format', array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - 'description' => 'The {filter_format}.format of the description.', - )); -} - -/** - * Change {taxonomy_index}.created to support signed int. -*/ -function taxonomy_update_7010() { - db_change_field('taxonomy_index', 'created', 'created', array( - 'description' => 'The Unix timestamp when the node was created.', - 'type' => 'int', - 'unsigned' => FALSE, - 'not null' => TRUE, - 'default'=> 0, - )); -} - diff --git modules/tracker/tracker.install modules/tracker/tracker.install index 244f537..cfe8dc7 100644 --- modules/tracker/tracker.install +++ modules/tracker/tracker.install @@ -111,110 +111,3 @@ function tracker_schema() { return $schema; } - -/** - * @addtogroup updates-6.x-to-7.x - * @{ - */ - -/** - * Create new tracker_node and tracker_user tables. - */ -function tracker_update_7000() { - $schema['tracker_node'] = array( - 'description' => 'Tracks when nodes were last changed or commented on', - 'fields' => array( - 'nid' => array( - 'description' => 'The {node}.nid this record tracks.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'published' => array( - 'description' => 'Boolean indicating whether the node is published.', - 'type' => 'int', - 'not null' => FALSE, - 'default' => 0, - 'size' => 'tiny', - ), - 'changed' => array( - 'description' => 'The Unix timestamp when the node was most recently saved or commented on.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - ), - 'indexes' => array( - 'tracker' => array('published', 'changed'), - ), - 'primary key' => array('nid'), - 'foreign keys' => array( - 'tracked_node' => array( - 'table' => 'node', - 'columns' => array('nid' => 'nid'), - ), - ), - ); - - $schema['tracker_user'] = array( - 'description' => 'Tracks when nodes were last changed or commented on, for each user that authored the node or one of its comments.', - 'fields' => array( - 'nid' => array( - 'description' => 'The {node}.nid this record tracks.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'uid' => array( - 'description' => 'The {users}.uid of the node author or commenter.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'published' => array( - 'description' => 'Boolean indicating whether the node is published.', - 'type' => 'int', - 'not null' => FALSE, - 'default' => 0, - 'size' => 'tiny', - ), - 'changed' => array( - 'description' => 'The Unix timestamp when the node was most recently saved or commented on.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - ), - 'indexes' => array( - 'tracker' => array('uid', 'published', 'changed'), - ), - 'primary key' => array('nid', 'uid'), - 'foreign keys' => array( - 'tracked_node' => array( - 'table' => 'node', - 'columns' => array('nid' => 'nid'), - ), - 'tracked_user' => array( - 'table' => 'users', - 'columns' => array('uid' => 'uid'), - ), - ), - ); - - foreach ($schema as $name => $table) { - db_create_table($name, $table); - } - - $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField(); - if ($max_nid != 0) { - variable_set('tracker_index_nid', $max_nid); - } -} - -/** - * @} End of "addtogroup updates-6.x-to-7.x" - */ diff --git modules/trigger/trigger.install modules/trigger/trigger.install index 9a172a2..7dded60 100644 --- modules/trigger/trigger.install +++ modules/trigger/trigger.install @@ -51,20 +51,3 @@ function trigger_install() { // Do initial synchronization of actions in code and the database. actions_synchronize(); } - -/** - * Adds operation names to the hook names and drops the "op" field. - */ -function trigger_update_7000() { - $result = db_query("SELECT hook, op, aid FROM {trigger_assignments} WHERE op <> ''"); - - foreach ($result as $record) { - db_update('trigger_assignments') - ->fields(array('hook' => $record->hook . '_' . $record->op)) - ->condition('hook', $record->hook) - ->condition('op', $record->op) - ->condition('aid', $record->aid) - ->execute(); - } - db_drop_field('trigger_assignments', 'op'); -} diff --git modules/update/update.install modules/update/update.install index 70fb6c3..f0d5499 100644 --- modules/update/update.install +++ modules/update/update.install @@ -157,34 +157,3 @@ function _update_requirement_check($project, $type) { $requirement['value'] = l($requirement_label, update_manager_access() ? 'admin/reports/updates/update' : 'admin/reports/updates'); return $requirement; } - -/** - * @addtogroup updates-6.x-to-7.x - * @{ - */ - -/** - * Create a queue to store tasks for requests to fetch available update data. - */ -function update_update_7000() { - module_load_include('inc', 'system', 'system.queue'); - $queue = DrupalQueue::get('update_fetch_tasks'); - $queue->createQueue(); -} - -/** - * Recreates cache_update table. - * - * Converts fields that hold serialized variables from text to blob. - * Removes 'headers' column. - */ -function update_update_7001() { - $schema = system_schema_cache_7054(); - - db_drop_table('cache_update'); - db_create_table('cache_update', $schema); -} - -/** - * @} End of "addtogroup updates-6.x-to-7.x" - */ diff --git modules/user/user.install modules/user/user.install index 0967818..370427f 100644 --- modules/user/user.install +++ modules/user/user.install @@ -335,524 +335,3 @@ function user_install() { ->execute(); } } - -/** - * Implements hook_update_dependencies(). - */ -function user_update_dependencies() { - // Run all the critical user upgrades before everything. - $dependencies['system'][7000] = array( - 'user' => 7008, - ); - // Both user_update_7006() and user_update_7010() need to query the list of - // existing text formats and therefore must run after filter_update_7003(). - // @todo: move user_update_7006 down below in the upgrade process. - $dependencies['user'][7006] = array( - 'filter' => 7003, - ); - // user_update_7013 relies on system_update_7060. - $dependencies['user'][7013] = array( - 'system' => 7059, - ); - // Ensure that format columns are only changed after Filter module has changed - // the primary records. - $dependencies['user'][7015] = array( - 'filter' => 7010, - ); - - return $dependencies; -} - -/** - * Utility function: grant a set of permissions to a role during update. - * - * This function is valid for a database schema version 7000. - * - * @param $rid - * The role ID. - * @param $permissions - * An array of permissions names. - * @param $module - * The name of the module defining the permissions. - * @ingroup update-api-6.x-to-7.x - */ -function _update_7000_user_role_grant_permissions($rid, array $permissions, $module) { - // Grant new permissions for the role. - foreach ($permissions as $name) { - db_merge('role_permission') - ->key(array( - 'rid' => $rid, - 'permission' => $name, - )) - ->fields(array( - 'module' => $module, - )) - ->execute(); - } -} - -/** - * @addtogroup updates-6.x-to-7.x - * @{ - */ - -/** - * Increase the length of the password field to accommodate better hashes. - * - * Also re-hashes all current passwords to improve security. This may be a - * lengthy process, and is performed batch-wise. - */ -function user_update_7000(&$sandbox) { - $sandbox['#finished'] = 0; - // Lower than DRUPAL_HASH_COUNT to make the update run at a reasonable speed. - $hash_count_log2 = 11; - // Multi-part update. - if (!isset($sandbox['user_from'])) { - db_change_field('users', 'pass', 'pass', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '')); - $sandbox['user_from'] = 0; - $sandbox['user_count'] = db_query("SELECT COUNT(uid) FROM {users}")->fetchField(); - } - else { - require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc'); - // Hash again all current hashed passwords. - $has_rows = FALSE; - // Update this many per page load. - $count = 1000; - $result = db_query_range("SELECT uid, pass FROM {users} WHERE uid > 0 ORDER BY uid", $sandbox['user_from'], $count); - foreach ($result as $account) { - $has_rows = TRUE; - $new_hash = user_hash_password($account->pass, $hash_count_log2); - if ($new_hash) { - // Indicate an updated password. - $new_hash = 'U' . $new_hash; - db_update('users') - ->fields(array('pass' => $new_hash)) - ->condition('uid', $account->uid) - ->execute(); - } - } - $sandbox['#finished'] = $sandbox['user_from']/$sandbox['user_count']; - $sandbox['user_from'] += $count; - if (!$has_rows) { - $sandbox['#finished'] = 1; - return t('User passwords rehashed to improve security'); - } - } -} - -/** - * Remove the 'threshold', 'mode' and 'sort' columns from the {users} table. - * - * These fields were previously used to store per-user comment settings. - */ - -function user_update_7001() { - db_drop_field('users', 'threshold'); - db_drop_field('users', 'mode'); - db_drop_field('users', 'sort'); -} - -/** - * Convert user time zones from time zone offsets to time zone names. - */ -function user_update_7002(&$sandbox) { - $sandbox['#finished'] = 0; - - // Multi-part update. - if (!isset($sandbox['user_from'])) { - db_change_field('users', 'timezone', 'timezone', array('type' => 'varchar', 'length' => 32, 'not null' => FALSE)); - $sandbox['user_from'] = 0; - $sandbox['user_count'] = db_query("SELECT COUNT(uid) FROM {users}")->fetchField(); - $sandbox['user_not_migrated'] = 0; - } - else { - $timezones = system_time_zones(); - // Update this many per page load. - $count = 10000; - $contributed_date_module = db_field_exists('users', 'timezone_name'); - $contributed_event_module = db_field_exists('users', 'timezone_id'); - - $results = db_query_range("SELECT uid FROM {users} ORDER BY uid", $sandbox['user_from'], $count); - foreach ($results as $account) { - $timezone = NULL; - // If the contributed Date module has created a users.timezone_name - // column, use this data to set each user's time zone. - if ($contributed_date_module) { - $date_timezone = db_query("SELECT timezone_name FROM {users} WHERE uid = :uid", array(':uid' => $account->uid))->fetchField(); - if (isset($timezones[$date_timezone])) { - $timezone = $date_timezone; - } - } - // If the contributed Event module has stored user time zone information - // use that information to update the user accounts. - if (!$timezone && $contributed_event_module) { - try { - $event_timezone = db_query("SELECT t.name FROM {users} u LEFT JOIN {event_timezones} t ON u.timezone_id = t.timezone WHERE u.uid = :uid", array(':uid' => $account->uid))->fetchField(); - $event_timezone = str_replace(' ', '_', $event_timezone); - if (isset($timezones[$event_timezone])) { - $timezone = $event_timezone; - } - } - catch (PDOException $e) { - // Ignore error if event_timezones table does not exist or unexpected - // schema found. - } - } - if ($timezone) { - db_update('users') - ->fields(array('timezone' => $timezone)) - ->condition('uid', $account->uid) - ->execute(); - } - else { - $sandbox['user_not_migrated']++; - db_update('users') - ->fields(array('timezone' => NULL)) - ->condition('uid', $account->uid) - ->execute(); - } - $sandbox['user_from']++; - } - - $sandbox['#finished'] = $sandbox['user_from'] / $sandbox['user_count']; - if ($sandbox['user_from'] == $sandbox['user_count']) { - if ($sandbox['user_not_migrated'] > 0) { - variable_set('empty_timezone_message', 1); - drupal_set_message('Some user time zones have been emptied and need to be set to the correct values. Use the new ' . l('time zone options', 'admin/config/regional/settings') . ' to choose whether to remind users at login to set the correct time zone.', 'warning'); - } - return t('Migrated user time zones'); - } - } -} - -/** - * Update user settings for cancelling user accounts. - * - * Prior to 7.x, users were not able to cancel their accounts. When - * administrators deleted an account, all contents were assigned to uid 0, - * which is the same as the 'user_cancel_reassign' method now. - */ -function user_update_7003() { - // Set the default account cancellation method. - variable_set('user_cancel_method', 'user_cancel_reassign'); - // Re-assign notification setting. - if ($setting = variable_get('user_mail_status_deleted_notify', FALSE)) { - variable_set('user_mail_status_canceled_notify', $setting); - variable_del('user_mail_status_deleted_notify'); - } - // Re-assign "Account deleted" mail strings to "Account canceled" mail. - if ($setting = variable_get('user_mail_status_deleted_subject', FALSE)) { - variable_set('user_mail_status_canceled_subject', $setting); - variable_del('user_mail_status_deleted_subject'); - } - if ($setting = variable_get('user_mail_status_deleted_body', FALSE)) { - variable_set('user_mail_status_canceled_body', $setting); - variable_del('user_mail_status_deleted_body'); - } -} - -/** - * Changes the users table to allow longer e-mail addresses. - */ -function user_update_7005(&$sandbox) { - $mail_field = array( - 'type' => 'varchar', - 'length' => 254, - 'not null' => FALSE, - 'default' => '', - 'description' => "User's e-mail address.", - ); - $init_field = array( - 'type' => 'varchar', - 'length' => 254, - 'not null' => FALSE, - 'default' => '', - 'description' => 'E-mail address used for initial account creation.', - ); - db_drop_index('users', 'mail'); - db_change_field('users', 'mail', 'mail', $mail_field, array('indexes' => array('mail' => array('mail')))); - db_change_field('users', 'init', 'init', $init_field); -} - -/** - * Add module data to {role_permission}. - */ -function user_update_7006(&$sandbox) { - $module_field = array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - 'description' => "The module declaring the permission.", - ); - // Check that the field hasn't been updated in an aborted run of this - // update. - if (!db_field_exists('role_permission', 'module')) { - // Add a new field for the fid. - db_add_field('role_permission', 'module', $module_field); - } - $permissions = user_permission_get_modules(); - foreach ($permissions as $key => $value) { - db_update('role_permission') - ->fields(array('module' => $value)) - ->condition('permission', $key) - ->execute(); - } -} - -/** - * Add a weight column to user roles. - */ -function user_update_7007() { - db_add_field('role', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); - db_add_index('role', 'name_weight', array('name', 'weight')); -} - -/** - * If 'user_register' variable was unset in Drupal 6, set it to be the same as - * the Drupal 6 default setting. - */ -function user_update_7008() { - if (!isset($GLOBALS['conf']['user_register'])) { - // Set to the Drupal 6 default, "visitors can create accounts". - variable_set('user_register', USER_REGISTER_VISITORS); - } -} - -/** - * Converts fields that store serialized variables from text to blob. - */ -function user_update_7009() { - $spec = array( - 'type' => 'blob', - 'not null' => FALSE, - 'size' => 'big', - 'serialize' => TRUE, - 'description' => 'A serialized array of name value pairs that are related to the user. Any form values posted during user edit are stored and are loaded into the $user object during user_load(). Use of this field is discouraged and it will likely disappear in a future version of Drupal.', - ); - db_change_field('users', 'data', 'data', $spec); -} - -/** - * Update the {user}.signature_format column. - */ -function user_update_7010() { - // Update the database column to allow NULL values. - db_change_field('users', 'signature_format', 'signature_format', array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => FALSE, - 'description' => 'The {filter_format}.format of the signature.', - )); - - // Replace the signature format with NULL if the signature is empty and does - // not already have a stored text format. - // - // In Drupal 6, "0" (the former FILTER_FORMAT_DEFAULT constant) could be used - // to indicate this situation, but in Drupal 7, only NULL is supported. This - // update therefore preserves the ability of user accounts which were never - // given a signature (for example, if the site did not have user signatures - // enabled, or if the user never edited their account information) to not - // have a particular text format assumed for them the first time the - // signature is edited. - db_update('users') - ->fields(array('signature_format' => NULL)) - ->condition('signature', '') - ->condition('signature_format', 0) - ->execute(); - - // There are a number of situations in which a Drupal 6 site could store - // content with a nonexistent text format. This includes text formats that - // had later been deleted, or non-empty content stored with a value of "0" - // (the former FILTER_FORMAT_DEFAULT constant). Drupal 6 would filter this - // content using whatever the site-wide default text format was at the moment - // the text was being displayed. - // - // In Drupal 7, this behavior is no longer supported, and all content must be - // stored with an explicit text format (or it will not be displayed when it - // is filtered). Therefore, to preserve the behavior of the site after the - // upgrade, we must replace all instances described above with the current - // value of the (old) site-wide default format at the moment of the upgrade. - $existing_formats = db_query("SELECT format FROM {filter_format}")->fetchCol(); - $default_format = variable_get('filter_default_format', 1); - db_update('users') - ->fields(array('signature_format' => $default_format)) - ->isNotNull('signature_format') - ->condition('signature_format', $existing_formats, 'NOT IN') - ->execute(); -} - -/** - * Updates email templates to use new tokens. - * - * This function upgrades customized email templates from the old !token format - * to the new core tokens format. Additionally, in Drupal 7 we no longer e-mail - * plain text passwords to users, and there is no token for a plain text - * password in the new token system. Therefore, it also modifies any saved - * templates using the old '!password' token such that the token is removed, and - * displays a warning to users that they may need to go and modify the wording - * of their templates. - */ -function user_update_7011() { - $message = ''; - - $tokens = array( - '!site-name-token' => '[site:name]', - '!site-url-token' => '[site:url]', - '!user-name-token' => '[user:name]', - '!user-mail-token' => '[user:mail]', - '!site-login-url-token' => '[site:login-url]', - '!site-url-brief-token' => '[site:url-brief]', - '!user-edit-url-token' => '[user:edit-url]', - '!user-one-time-login-url-token' => '[user:one-time-login-url]', - '!user-cancel-url-token' => '[user:cancel-url]', - '!password' => '', - ); - - $result = db_select('variable', 'v') - ->fields('v', array('name', 'value')) - ->condition('value', db_like('user_mail_') . '%', 'LIKE') - ->execute(); - - foreach ($result as $row) { - if (empty($message) && (strpos($row->value, '!password') !== FALSE)) { - $message = t('The ability to send users their passwords in plain text has been removed in Drupal 7. Your existing email templates have been modified to remove it. You should review these templates to make sure they read properly.', array('@template-url' => url('admin/config/people/accounts'))); - } - - variable_set($row->name, str_replace(array_keys($tokens), $tokens, $row->value)); - } - - return $message; -} - -/** - * Add the user's pictures to the {file_managed} table and make them managed - * files. - */ -function user_update_7012(&$sandbox) { - - $picture_field = array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => "Foreign key: {file_managed}.fid of user's picture.", - ); - - if (!isset($sandbox['progress'])) { - // Check that the field hasn't been updated in an aborted run of this - // update. - if (!db_field_exists('users', 'picture_fid')) { - // Add a new field for the fid. - db_add_field('users', 'picture_fid', $picture_field); - } - - // Initialize batch update information. - $sandbox['progress'] = 0; - $sandbox['last_user_processed'] = -1; - $sandbox['max'] = db_query("SELECT COUNT(*) FROM {users} WHERE picture <> ''")->fetchField(); - } - - // As a batch operation move the photos into the {file_managed} table and - // update the {users} records. - $limit = 500; - $result = db_query_range("SELECT uid, picture FROM {users} WHERE picture <> '' AND uid > :uid ORDER BY uid", 0, $limit, array(':uid' => $sandbox['last_user_processed'])); - foreach ($result as $user) { - // Don't bother adding files that don't exist. - if (file_exists($user->picture)) { - - // Check if the file already exists. - $files = file_load_multiple(array(), array('uri' => $user->picture)); - if (count($files)) { - $file = reset($files); - } - else { - // Create a file object. - $file = new stdClass(); - $file->uri = $user->picture; - $file->filename = basename($file->uri); - $file->filemime = file_get_mimetype($file->uri); - $file->uid = $user->uid; - $file->status = FILE_STATUS_PERMANENT; - $file = file_save($file); - } - - db_update('users') - ->fields(array('picture_fid' => $file->fid)) - ->condition('uid', $user->uid) - ->execute(); - } - - // Update our progress information for the batch update. - $sandbox['progress']++; - $sandbox['last_user_processed'] = $user->uid; - } - - // Indicate our current progress to the batch update system. If there's no - // max value then there's nothing to update and we're finished. - $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']); - - // When we're finished, drop the old picture field and rename the new one to - // replace it. - if (isset($sandbox['#finished']) && $sandbox['#finished'] == 1) { - db_drop_field('users', 'picture'); - db_change_field('users', 'picture_fid', 'picture', $picture_field); - } -} - -/** - * Add user module file usage entries. - */ -function user_update_7013(&$sandbox) { - if (!isset($sandbox['progress'])) { - // Initialize batch update information. - $sandbox['progress'] = 0; - $sandbox['last_uid_processed'] = -1; - $sandbox['max'] = db_query("SELECT COUNT(*) FROM {users} u WHERE u.picture <> 0")->fetchField(); - } - - // Add usage entries for the user picture files. - $limit = 500; - $result = db_query_range('SELECT f.*, u.uid as user_uid FROM {users} u INNER JOIN {file_managed} f ON u.picture = f.fid WHERE u.picture <> 0 AND u.uid > :uid ORDER BY u.uid', 0, $limit, array(':uid' => $sandbox['last_uid_processed']))->fetchAllAssoc('fid', PDO::FETCH_ASSOC); - foreach ($result as $row) { - $uid = $row['user_uid']; - $file = (object) $row; - file_usage_add($file, 'user', 'user', $uid); - - // Update our progress information for the batch update. - $sandbox['progress']++; - $sandbox['last_uid_processed'] = $uid; - } - - // Indicate our current progress to the batch update system. - $sandbox['#finished'] = empty($sandbox['max']) || ($sandbox['progress'] / $sandbox['max']); -} - -/** - * Rename the 'post comments without approval' permission. - * - * In Drupal 7, this permission has been renamed to 'skip comment approval'. - */ -function user_update_7014() { - db_update('role_permission') - ->fields(array('permission' => 'skip comment approval')) - ->condition('permission', 'post comments without approval') - ->execute(); - - return t("Renamed the 'post comments without approval' permission to 'skip comment approval'."); -} - -/** - * Change {users}.signature_format into varchar. - */ -function user_update_7015() { - db_change_field('users', 'signature_format', 'signature_format', array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - 'description' => 'The {filter_format}.format of the signature.', - )); -} - -/** - * @} End of "addtogroup updates-6.x-to-7.x" - */ diff --git update.php update.php index 785c50b..05957fe 100644 --- update.php +++ update.php @@ -346,13 +346,7 @@ require_once DRUPAL_ROOT . '/includes/common.inc'; require_once DRUPAL_ROOT . '/includes/file.inc'; require_once DRUPAL_ROOT . '/includes/entity.inc'; require_once DRUPAL_ROOT . '/includes/unicode.inc'; -update_prepare_d7_bootstrap(); - -// Temporarily disable configurable timezones so the upgrade process uses the -// site-wide timezone. This prevents a PHP notice during session initlization -// and before offsets have been converted in user_update_7002(). -$configurable_timezones = variable_get('configurable_timezones', 1); -$conf['configurable_timezones'] = 0; +update_prepare_d8_bootstrap(); // Determine if the current user has access to run update.php. drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); @@ -391,13 +385,13 @@ if (empty($op) && update_access_allowed()) { install_goto('update.php?op=info'); } -// update_fix_d7_requirements() needs to run before bootstrapping beyond path. +// update_fix_d8_requirements() needs to run before bootstrapping beyond path. // So bootstrap to DRUPAL_BOOTSTRAP_LANGUAGE then include unicode.inc. drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE); include_once DRUPAL_ROOT . '/includes/unicode.inc'; -update_fix_d7_requirements(); +update_fix_d8_requirements(); // Now proceed with a full bootstrap. -- 1.6.5.1 From e638152fc213620924789b43388902d502be7752 Mon Sep 17 00:00:00 2001 From: Nathan Haug Date: Fri, 18 Mar 2011 00:32:39 -0700 Subject: [PATCH 2/3] drupal_core_remove_7x_updates --- includes/update.inc | 52 +--------------------------------------- modules/system/system.install | 52 ----------------------------------------- 2 files changed, 2 insertions(+), 102 deletions(-) diff --git includes/update.inc includes/update.inc index f5a4275..e31293b 100644 --- includes/update.inc +++ includes/update.inc @@ -79,40 +79,8 @@ function update_check_incompatibility($name, $type = 'module') { * irreversible changes to the database are made here. */ function update_prepare_d8_bootstrap() { - // Check that PDO is available and that the correct PDO database driver is - // loaded. Bootstrapping to DRUPAL_BOOTSTRAP_DATABASE will result in a fatal - // error otherwise. - $message = ''; - $pdo_link = 'http://drupal.org/requirements/pdo'; - // Check that PDO is loaded. - if (!extension_loaded('pdo')) { - $message = '

PDO is required!

Drupal 7 requires PHP ' . DRUPAL_MINIMUM_PHP . ' or higher with the PHP Data Objects (PDO) extension enabled.

'; - } - // The PDO::ATTR_DEFAULT_FETCH_MODE constant is not available in the PECL - // version of PDO. - elseif (!defined('PDO::ATTR_DEFAULT_FETCH_MODE')) { - $message = '

The wrong version of PDO is installed!

Drupal 7 requires the PHP Data Objects (PDO) extension from PHP core to be enabled. This system has the older PECL version installed.'; - $pdo_link = 'http://drupal.org/requirements/pdo#pecl'; - } - // Check that the correct driver is loaded for the database being updated. - // If we have no driver information (for example, if someone tried to create - // the Drupal 7 $databases array themselves but did not do it correctly), - // this message will be confusing, so do not perform the check; instead, just - // let the database connection fail in the code that follows. - elseif (isset($databases['default']['default']['driver']) && !in_array($databases['default']['default']['driver'], PDO::getAvailableDrivers())) { - $message = '

A PDO database driver is required!

You need to enable the PDO_' . strtoupper($databases['default']['default']['driver']) . ' database driver for PHP ' . DRUPAL_MINIMUM_PHP . ' or higher so that Drupal 7 can access the database.

'; - } - if ($message) { - print $message . '

See the system requirements page for more information.

'; - exit(); - } - - // Allow the database system to work even if the registry has not been - // created yet. - drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); - - // If the site has not updated to Drupal 7 yet, check to make sure that it is - // running an up-to-date version of Drupal 6 before proceeding. Note this has + // If the site has not updated to Drupal 8 yet, check to make sure that it is + // running an up-to-date version of Drupal 7 before proceeding. Note this has // to happen AFTER the database bootstraps because of // drupal_get_installed_schema_version(). $system_schema = drupal_get_installed_schema_version('system'); @@ -126,22 +94,6 @@ function update_prepare_d8_bootstrap() { 'description' => $has_required_schema ? '' : 'Please update your Drupal 7 installation to the most recent version before attempting to upgrade to Drupal 8', ), ); - - // Make sure that the database environment is properly set up. - try { - db_run_tasks(db_driver()); - } - catch (DatabaseTaskException $e) { - $requirements['database tasks'] = array( - 'title' => 'Database environment', - 'value' => 'There is a problem with your database environment', - 'severity' => REQUIREMENT_ERROR, - 'description' => $e->getMessage(), - ); - } - - update_extra_requirements($requirements); - } } /** diff --git modules/system/system.install modules/system/system.install index d47cbc1..c89ce4f 100644 --- modules/system/system.install +++ modules/system/system.install @@ -1646,58 +1646,6 @@ function system_schema() { return $schema; } -/** - * The cache schema corresponding to system_update_7054. - * - * Drupal 7 adds several new cache tables. Since they all have identical schema - * this helper function allows them to re-use the same definition, without - * relying on system_schema(), which may change with future updates. - */ -function system_schema_cache_7054() { - return array( - 'description' => 'Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.', - 'fields' => array( - 'cid' => array( - 'description' => 'Primary Key: Unique cache ID.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'data' => array( - 'description' => 'A collection of data to cache.', - 'type' => 'blob', - 'not null' => FALSE, - 'size' => 'big', - ), - 'expire' => array( - 'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'created' => array( - 'description' => 'A Unix timestamp indicating when the cache entry was created.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'serialized' => array( - 'description' => 'A flag to indicate whether content is serialized (1) or not (0).', - 'type' => 'int', - 'size' => 'small', - 'not null' => TRUE, - 'default' => 0, - ), - ), - 'indexes' => array( - 'expire' => array('expire'), - ), - 'primary key' => array('cid'), - ); -} - - // Updates for core. function system_update_last_removed() { -- 1.6.5.1 From 34e62a15df2dce36545d3d8a930ec43c65b03f8b Mon Sep 17 00:00:00 2001 From: Nathan Haug Date: Fri, 18 Mar 2011 00:35:19 -0700 Subject: [PATCH 3/3] drupal_core_remove_7x_updates --- includes/update.inc | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git includes/update.inc includes/update.inc index e31293b..7b8dc1f 100644 --- includes/update.inc +++ includes/update.inc @@ -94,6 +94,7 @@ function update_prepare_d8_bootstrap() { 'description' => $has_required_schema ? '' : 'Please update your Drupal 7 installation to the most recent version before attempting to upgrade to Drupal 8', ), ); + } } /** -- 1.6.5.1