Commit fabaaaaa authored by Dries's avatar Dries

- Patch #278592 by catch, Dave Reid, lilou et al: remove D5 to D6 updates.

parent f96c141f
......@@ -67,37 +67,3 @@ function blogapi_schema() {
return $schema;
}
/**
* @defgroup updates-5.x-to-6.x Blog API updates from 5.x to 6.x
* @{
*/
/**
* Inform users about the new permission.
*/
function blogapi_update_6000() {
drupal_set_message("Blog API module does not depend on blog module's permissions anymore, but provides its own 'administer content with blog api' permission instead. Until <a href=\"" . url('admin/user/permissions', array('fragment' => 'module-blogapi')) . '">this permission is assigned</a> to at least one user role, only the site administrator will be able to use Blog API features.');
return array();
}
/**
* Add blogapi_files table to enable size restriction for BlogAPI file uploads.
*
* This table was introduced in Drupal 6.4.
*/
function blogapi_update_6001() {
$ret = array();
if (!db_table_exists('blogapi_files')) {
$schema = blogapi_schema();
db_create_table($ret, 'blogapi_files', $schema['blogapi_files']);
}
return $ret;
}
/**
* @} End of "defgroup updates-5.x-to-6.x"
* The next series of updates should start at 7000.
*/
......@@ -48,209 +48,6 @@ function _book_install_type_create() {
variable_set('book_child_type', 'book');
}
/**
* Drupal 5.x to 6.x update.
*
* This function moves any existing book hierarchy into the new structure used
* in the 6.x module. Rather than storing the hierarchy in the {book} table,
* the menu API is used to store the hierarchy in the {menu_links} table and the
* {book} table serves to uniquely connect a node to a menu link.
*
* In order to accomplish this, the current hierarchy is processed using a stack.
* The stack insures that each parent is processed before any of its children
* in the book hierarchy, and is compatible with batched update processing.
*
*/
function book_update_6000() {
$ret = array();
// Set up for a multi-part update.
if (!isset($_SESSION['book_update_6000'])) {
$schema['book'] = array(
'fields' => array(
'mlid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'bid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
),
'primary key' => array('mlid'),
'unique keys' => array(
'nid' => array('nid'),
),
'indexes' => array(
'bid' => array('bid'),
),
);
// Add the node type.
_book_install_type_create();
// Fix role permissions to account for the changed names
// Setup the array holding strings to match and the corresponding
// strings to replace them with.
$replace = array(
'outline posts in books' => 'administer book outlines',
'create book pages' => 'create book content',
'edit book pages' => 'edit any book content',
'edit own book pages' => 'edit own book content',
'see printer-friendly version' => 'access printer-friendly version',
);
// Loop over all the roles, and do the necessary transformations.
$query = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
while ($role = db_fetch_object($query)) {
// Replace all the old permissions with the corresponding new permissions.
$fixed_perm = strtr($role->perm, $replace);
// If the user could previously create book pages, they should get the new
// 'add content to books' permission.
if (strpos($role->perm, 'create book pages') !== FALSE) {
$fixed_perm .= ', add content to books';
}
// Only save if the permissions have changed.
if ($fixed_perm != $role->perm) {
$ret[] = update_sql("UPDATE {permission} SET perm = '$fixed_perm' WHERE rid = $role->rid");
}
}
// Determine whether there are any existing nodes in the book hierarchy.
if (db_result(db_query("SELECT COUNT(*) FROM {book}"))) {
// Temporary table for the old book hierarchy; we'll discard revision info.
$schema['book_temp'] = array(
'fields' => array(
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'parent' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
),
'indexes' => array(
'parent' => array('parent')
),
'primary key' => array('nid'),
);
db_create_table($ret, 'book_temp', $schema['book_temp']);
// Insert each node in the old table into the temporary table.
$ret[] = update_sql("INSERT INTO {book_temp} (nid, parent, weight) SELECT b.nid, b.parent, b.weight FROM {book} b INNER JOIN {node} n on b.vid = n.vid");
$ret[] = update_sql("DROP TABLE {book}");
db_create_table($ret, 'book', $schema['book']);
$_SESSION['book_update_6000_orphans'] = array('from' => 0);
$_SESSION['book_update_6000'] = array();
$result = db_query("SELECT * from {book_temp} WHERE parent = 0");
// Collect all books - top-level nodes.
while ($a = db_fetch_array($result)) {
$_SESSION['book_update_6000'][] = $a;
}
$ret['#finished'] = FALSE;
return $ret;
}
else {
// No existing nodes in the hierarchy, so drop the table and re-create it.
$ret[] = update_sql("DROP TABLE {book}");
db_create_table($ret, 'book', $schema['book']);
return $ret;
}
}
elseif (isset($_SESSION['book_update_6000_orphans'])) {
// Do the first batched part of the update - collect orphans.
$update_count = 400; // Update this many at a time.
$result = db_query_range("SELECT * FROM {book_temp}", $_SESSION['book_update_6000_orphans']['from'], $update_count);
$has_rows = FALSE;
// Go through the next $update_count book pages and locate the orphans.
while ($book = db_fetch_array($result)) {
$has_rows = TRUE;
// Orphans are defined as nodes whose parent does not exist in the table.
if ($book['parent'] && !db_result(db_query("SELECT COUNT(*) FROM {book_temp} WHERE nid = %d", $book['parent']))) {
if (empty($_SESSION['book_update_6000_orphans']['book'])) {
// The first orphan becomes the parent for all other orphans.
$book['parent'] = 0;
$_SESSION['book_update_6000_orphans']['book'] = $book;
$ret[] = array('success' => TRUE, 'query' => 'Relocated orphan book pages.');
}
else {
// Re-assign the parent value of the book, and add it to the stack.
$book['parent'] = $_SESSION['book_update_6000_orphans']['book']['nid'];
$_SESSION['book_update_6000'][] = $book;
}
}
}
if ($has_rows) {
$_SESSION['book_update_6000_orphans']['from'] += $update_count;
}
else {
if (!empty($_SESSION['book_update_6000_orphans']['book'])) {
// The orphans' parent is added last, so it will be processed first.
$_SESSION['book_update_6000'][] = $_SESSION['book_update_6000_orphans']['book'];
}
$_SESSION['book_update_6000_orphans'] = FALSE;
}
$ret['#finished'] = FALSE;
return $ret;
}
else {
// Run the next batched part of the update.
$update_count = 100; // Update this many at a time
while ($update_count && $_SESSION['book_update_6000']) {
// Get the last node off the stack.
$book = array_pop($_SESSION['book_update_6000']);
// Add all of this node's children to the stack.
$result = db_query("SELECT * FROM {book_temp} WHERE parent = %d", $book['nid']);
while ($a = db_fetch_array($result)) {
$_SESSION['book_update_6000'][] = $a;
}
if ($book['parent']) {
// If its not a top level page, get its parent's mlid.
$parent = db_fetch_array(db_query("SELECT b.mlid AS plid, b.bid FROM {book} b WHERE b.nid = %d", $book['parent']));
$book = array_merge($book, $parent);
}
else {
// There is no parent - this is a new book.
$book['plid'] = 0;
$book['bid'] = $book['nid'];
}
$book += array(
'module' => 'book',
'link_path' => 'node/' . $book['nid'],
'router_path' => 'node/%',
'menu_name' => 'book-toc-' . $book['bid'],
);
$book = array_merge($book, db_fetch_array(db_query("SELECT title AS link_title FROM {node} WHERE nid = %d", $book['nid'])));
// Items with depth > MENU_MAX_DEPTH cannot be saved.
if (menu_link_save($book)) {
db_query("INSERT INTO {book} (mlid, nid, bid) VALUES (%d, %d, %d)", $book['mlid'], $book['nid'], $book['bid']);
}
else {
// The depth was greater then MENU_MAX_DEPTH, so attach it to the
// closest valid parent.
$book['plid'] = db_result(db_query("SELECT plid FROM {menu_links} WHERE mlid = %d", $book['plid']));
if (menu_link_save($book)) {
db_query("INSERT INTO {book} (mlid, nid, bid) VALUES (%d, %d, %d)", $book['mlid'], $book['nid'], $book['bid']);
}
}
$update_count--;
}
$ret['#finished'] = FALSE;
}
if (empty($_SESSION['book_update_6000'])) {
$ret['#finished'] = TRUE;
$ret[] = array('success' => TRUE, 'query' => 'Relocated existing book pages.');
$ret[] = update_sql("DROP TABLE {book_temp}");
unset($_SESSION['book_update_6000']);
unset($_SESSION['book_update_6000_orphans']);
}
return $ret;
}
/**
* Implement hook_schema().
*/
......
......@@ -60,62 +60,6 @@ function comment_update_1() {
return array();
}
/**
* @defgroup updates-5.x-to-6.x Comment updates from 5.x to 6.x
* @{
*/
function comment_update_6001() {
$ret[] = update_sql("ALTER TABLE {comments} DROP score");
$ret[] = update_sql("ALTER TABLE {comments} DROP users");
return $ret;
}
/**
* Changed comment settings from global to per-node -- copy global
* settings to all node types.
*/
function comment_update_6002() {
// Comment module might not be enabled when this is run, but we need the
// constants defined by the module for this update.
drupal_load('module', 'comment');
$settings = array(
'comment_default_mode' => COMMENT_MODE_THREADED_EXPANDED,
'comment_default_order' => COMMENT_ORDER_NEWEST_FIRST,
'comment_default_per_page' => 50,
'comment_controls' => COMMENT_CONTROLS_HIDDEN,
'comment_anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT,
'comment_subject_field' => 1,
'comment_preview' => COMMENT_PREVIEW_REQUIRED,
'comment_form_location' => COMMENT_FORM_SEPARATE_PAGE,
);
$types = node_type_get_types();
foreach ($settings as $setting => $default) {
$value = variable_get($setting, $default);
foreach ($types as $type => $object) {
variable_set($setting . '_' . $type, $value);
}
variable_del($setting);
}
return array(array('success' => TRUE, 'query' => 'Global comment settings copied to all node types.'));
}
/**
* Add index to parent ID field.
*/
function comment_update_6003() {
$ret = array();
db_add_index($ret, 'comments', 'pid', array('pid'));
return $ret;
}
/**
* @} End of "defgroup updates-5.x-to-6.x"
* The next series of updates should start at 7000.
*/
/**
* @defgroup updates-6.x-to-7.x Comment updates from 6.x to 7.x
* @{
......
......@@ -110,33 +110,3 @@ function forum_schema() {
return $schema;
}
/**
* Create the forum vocabulary if does not exist. Assign the
* vocabulary a low weight so it will appear first in forum topic
* create and edit forms. Do not just call forum_enable() because in
* future versions it might do something different.
*/
function forum_update_6000() {
$ret = array();
$vid = variable_get('forum_nav_vocabulary', 0);
$vocabularies = taxonomy_get_vocabularies();
if (!isset($vocabularies[$vid])) {
$vocabulary = array(
'name' => t('Forums'),
'multiple' => 0,
'required' => 0,
'hierarchy' => 1,
'relations' => 0,
'module' => 'forum',
'weight' => -10,
'nodes' => array('forum' => 1),
);
taxonomy_save_vocabulary($vocabulary);
variable_set('forum_nav_vocabulary', $vocabulary['vid']);
}
return $ret;
}
......@@ -30,205 +30,6 @@ function locale_install() {
->execute();
}
/**
* @defgroup updates-5.x-to-6.x Locale updates from 5.x to 6.x
* @{
*/
/**
* {locales_meta} table became {languages}.
*/
function locale_update_6000() {
$ret = array();
$schema['languages'] = array(
'fields' => array(
'language' => array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
),
'name' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'native' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'direction' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'enabled' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'plurals' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'formula' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'domain' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'prefix' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'javascript' => array( //Adds a column to store the filename of the JavaScript translation file.
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('language'),
'indexes' => array(
'list' => array('weight', 'name'),
),
);
db_create_table($ret, 'languages', $schema['languages']);
// Save the languages
$ret[] = update_sql("INSERT INTO {languages} (language, name, native, direction, enabled, plurals, formula, domain, prefix, weight) SELECT locale, name, name, 0, enabled, plurals, formula, '', locale, 0 FROM {locales_meta}");
// Save the language count in the variable table
$count = db_result(db_query('SELECT COUNT(*) FROM {languages} WHERE enabled = 1'));
variable_set('language_count', $count);
// Save the default language in the variable table
$default = db_fetch_object(db_query('SELECT * FROM {locales_meta} WHERE isdefault = 1'));
variable_set('language_default', (object) array('language' => $default->locale, 'name' => $default->name, 'native' => '', 'direction' => 0, 'enabled' => 1, 'plurals' => $default->plurals, 'formula' => $default->formula, 'domain' => '', 'prefix' => $default->locale, 'weight' => 0));
$ret[] = update_sql("DROP TABLE {locales_meta}");
return $ret;
}
/**
* Change locale column to language. The language column is added by
* update_fix_d6_requirements() in update.php to avoid a large number
* of error messages from update.php. All we need to do here is copy
* locale to language and then drop locale.
*/
function locale_update_6001() {
$ret = array();
$ret[] = update_sql('UPDATE {locales_target} SET language = locale');
db_drop_field($ret, 'locales_target', 'locale');
return $ret;
}
/**
* Remove empty translations, we don't need these anymore.
*/
function locale_update_6002() {
$ret = array();
$ret[] = update_sql("DELETE FROM {locales_target} WHERE translation = ''");
return $ret;
}
/**
* Prune strings with no translations (will be automatically re-registered if still in use)
*/
function locale_update_6003() {
$ret = array();
$ret[] = update_sql("DELETE FROM {locales_source} WHERE lid NOT IN (SELECT lid FROM {locales_target})");
return $ret;
}
/**
* Fix remaining inconsistent indexes.
*/
function locale_update_6004() {
$ret = array();
db_add_index($ret, 'locales_target', 'language', array('language'));
switch ($GLOBALS['db_type']) {
case 'pgsql':
db_drop_index($ret, 'locales_source', 'source');
db_add_index($ret, 'locales_source', 'source', array(array('source', 30)));
break;
}
return $ret;
}
/**
* Change language setting variable of content types.
*
* Use language_content_type_<content_type> instead of language_<content_type>
* so content types such as 'default', 'count' or 'negotiation' will not
* interfere with language variables.
*/
function locale_update_6005() {
foreach (node_type_get_types() as $type => $content_type) {
// Default to NULL, so we can skip dealing with non-existent settings.
$setting = variable_get('language_' . $type);
if ($type == 'default' && is_numeric($setting)) {
// language_default was overwritten with the content type setting,
// so reset the default language and save the content type setting.
variable_set('language_content_type_default', $setting);
variable_del('language_default');
drupal_set_message('The default language setting has been reset to its default value. Check the ' . l('language configuration page', 'admin/settings/language') . ' to configure it correctly.');
}
elseif ($type == 'negotiation') {
// language_content_type_negotiation is an integer either if it is
// the negotiation setting or the content type setting.
// The language_negotiation setting is not reset, but
// the user is alerted that this setting possibly was overwritten
variable_set('language_content_type_negotiation', $setting);
drupal_set_message('The language negotiation setting was possibly overwritten by a content type of the same name. Check the ' . l('language configuration page', 'admin/settings/language/configure') . ' and the ' . l('<em>' . $content_type->name . "</em> content type's multilingual support settings", 'admin/build/types/negotiation', array('html' => TRUE)) . ' to configure them correctly.');
}
elseif (!is_null($setting)) {
// Change the language setting variable for any other content type.
// Do not worry about language_count, it will be updated below.
variable_set('language_content_type_' . $type, $setting);
variable_del('language_' . $type);
}
}
// Update language count variable that might be overwritten.
$count = db_result(db_query('SELECT COUNT(*) FROM {languages} WHERE enabled = 1'));
variable_set('language_count', $count);
return array();
}
/**
* Allow longer location.
*/
function locale_update_6006() {
$ret = array();
db_change_field($ret, 'locales_source', 'location', 'location', array('type' => 'text', 'not null' => FALSE));
return $ret;
}
/**
* @} End of "defgroup updates-5.x-to-6.x"
*/
/**
* @defgroup updates-6.x-to-7.x Locale updates from 6.x to 7.x
* @{
......
This diff is collapsed.
......@@ -12,8 +12,6 @@
function update_install() {
// Create cache table.
drupal_install_schema('update');
// Remove stale variables from update_status 5.x contrib, if any.
_update_remove_update_status_variables();
}
/**
......@@ -44,26 +42,3 @@ function update_schema() {
$schema['cache_update']['description'] = 'Cache table for the Update module to store information about available releases, fetched from central server.';
return $schema;
}
/**
* Private helper to clear out stale variables from update_status 5.x contrib.
*
* @see update_install()
* @see update_update_6000()
*/
function _update_remove_update_status_variables() {
variable_del('update_status_settings');
variable_del('update_status_notify_emails');
variable_del('update_status_check_frequency');
variable_del('update_status_notification_threshold');
variable_del('update_status_last');
variable_del('update_status_fetch_url');
}
/**
* Clear out stale variables from update_status.
*/
function update_update_6000() {
_update_remove_update_status_variables();
return array();
}
......@@ -444,34 +444,6 @@ function update_access_denied_page() {
</ol>';
}
/**
* Create the batch table.
*
* This is part of the Drupal 5.x to 6.x migration.
*/
function update_create_batch_table() {
// If batch table exists, update is not necessary
if (db_table_exists('batch')) {
return;
}
$schema['batch'] = array(
'fields' => array(
'bid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'token' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE),
'timestamp' => array('type' => 'int', 'not null' => TRUE),
'batch' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big')
),
'primary key' => array('bid'),
'indexes' => array('token' => array('token')),
);
$ret = array();
db_create_table($ret, 'batch', $schema['batch']);
return $ret;
}
/**
* Disable anything in the {system} table that is not compatible with the
* current version of Drupal core.
......@@ -519,61 +491,6 @@ function update_check_incompatibility($name, $type = 'module') {
return FALSE;
}
/**
* Perform Drupal 5.x to 6.x updates that are required for update.php
* to function properly.
*
* This function runs when update.php is run the first time for 6.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.
* Just adding columns is safe. However, renaming the
* system.description column to owner is not. Therefore, we add the
* system.owner column and leave it to system_update_6008() to copy
* the data from description and remove description. The same for
* renaming locales_target.locale to locales_target.language, which
* will be finished by locale_update_6002().
*/
function update_fix_d6_requirements() {
$ret = array();
if (drupal_get_installed_schema_version('system') < 6000 && !variable_get('update_d6_requirements', FALSE)) {
$spec = array('type' => 'int', 'size' => 'small', 'default' => 0, 'not null' => TRUE);
db_add_field($ret, 'cache', 'serialized', $spec);
db_add_field($ret, 'cache_filter', 'serialized', $spec);
db_add_field($ret, 'cache_page', 'serialized', $spec);
db_add_field($ret, 'cache_menu', 'serialized', $spec);
db_add_field($ret, 'system', 'info', array('type' => 'text'));
db_add_field($ret, 'system', 'owner', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
if (db_table_exists('locales_target')) {
db_add_field($ret, 'locales_target', 'language', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
}
if (db_table_exists('locales_source')) {
db_add_field($ret, 'locales_source', 'textgroup', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'default'));
db_add_field($ret, 'locales_source', 'version', array('type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => 'none'));
}
variable_set('update_d6_requirements', TRUE);
// Create the cache_block table. See system_update_6027() for more details.
$schema['cache_block'] = array(
'fields' => array(
'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'headers' => array('type' => 'text', 'not null' => FALSE),
'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
),
'indexes' => array('expire' => array('expire')),
'primary key' => array('cid'),
);
db_create_table($ret, 'cache_block', $schema['cache_block']);
}
return $ret;
}
/**
* 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment