Commit bc058bad authored by webchick's avatar webchick

Issue #2168011 by xjm, jessebeach, Damien Tournoud, znerol, Xano: Remove all...

Issue #2168011 by xjm, jessebeach, Damien Tournoud, znerol, Xano: Remove all 7.x to 8.x update hooks and disallow updates from the previous major version.
parent 76bcb27b
......@@ -630,8 +630,14 @@ function drupal_install_system($install_state) {
$system_path = drupal_get_path('module', 'system');
require_once DRUPAL_ROOT . '/' . $system_path . '/system.install';
// Set the schema version to the number of the last update provided by the
// module, or the minimum core schema version.
$system_version = \Drupal::CORE_MINIMUM_SCHEMA_VERSION;
$system_versions = drupal_get_schema_versions('system');
$system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED;
if ($system_versions) {
$system_version = max(max($system_versions), $system_version);
}
\Drupal::keyValue('system.schema')->set('system', $system_version);
// System module needs to be enabled and the system/module lists need to be
......
......@@ -19,11 +19,6 @@
*/
const SCHEMA_UNINSTALLED = -1;
/**
* Indicates that a module has been installed.
*/
const SCHEMA_INSTALLED = 0;
/**
* Gets the schema definition of a table, or the whole database schema.
*
......
......@@ -1046,7 +1046,6 @@ function theme_get_setting($setting_name, $theme = NULL) {
* Converts theme settings to configuration.
*
* @see system_theme_settings_submit()
* @see system_update_8054()
*
* @param array $theme_settings
* An array of theme settings from system setting form or a Drupal 7 variable.
......
This diff is collapsed.
......@@ -86,6 +86,11 @@ class Drupal {
*/
const CORE_COMPATIBILITY = '8.x';
/**
* Core minimum schema version.
*/
const CORE_MINIMUM_SCHEMA_VERSION = 8000;
/**
* The currently active container object.
*
......
......@@ -627,10 +627,13 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
// Now install the module's schema if necessary.
drupal_install_schema($module);
// Set the schema version to the number of the last update provided
// by the module.
// Set the schema version to the number of the last update provided by
// the module, or the minimum core schema version.
$version = \Drupal::CORE_MINIMUM_SCHEMA_VERSION;
$versions = drupal_get_schema_versions($module);
$version = $versions ? max($versions) : SCHEMA_INSTALLED;
if ($versions) {
$version = max(max($versions), $version);
}
// Install default configuration of the module.
\Drupal::service('config.installer')->installDefaultConfig('module', $module);
......
......@@ -42,7 +42,7 @@ public function getImplementations($hook) {
// Forms do not render without the basic elements in
// drupal_common_theme() called from system_theme().
case 'theme':
// user_update_8011() uses public:// to create the image style directory.
// Allow access to stream wrappers.
case 'stream_wrappers':
return array('system');
......@@ -71,10 +71,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
$schema_store = \Drupal::keyValue('system.schema');
$old_schema = array();
foreach ($module_list as $module) {
// Check for initial schema and install it. The schema version of a newly
// installed module is always 0. Using 8000 here would be inconsistent
// since $module_update_8000() may involve a schema change, and we want
// to install the schema as it was before any updates were added.
// Check for initial schema and install it.
module_load_install($module);
$function = $module . '_schema_0';
if (function_exists($function)) {
......
......@@ -198,52 +198,3 @@ function aggregator_schema() {
return $schema;
}
/**
* Moves aggregator settings from variables to config.
*
* @ingroup config_upgrade
*/
function aggregator_update_8000() {
update_variables_to_config('aggregator.settings', array(
'aggregator_fetcher' => 'fetcher',
'aggregator_parser' => 'parser',
'aggregator_processors' => 'processors',
'aggregator_allowed_html_tags' => 'items.allowed_html',
'aggregator_teaser_length' => 'items.teaser_length',
'aggregator_clear' => 'items.expire',
'aggregator_summary_items' => 'source.list_max',
));
}
/**
* Adds the langcode field to {aggregator_item} and {aggregator_feed}.
*/
function aggregator_update_8001() {
// Add the field.
db_add_field('aggregator_feed', 'langcode', array(
'description' => 'The {language}.langcode of this feed.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'initial' => Language::LANGCODE_NOT_SPECIFIED,
));
db_add_field('aggregator_item', 'langcode', array(
'description' => 'The {language}.langcode of this feed item.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'initial' => Language::LANGCODE_NOT_SPECIFIED,
));
}
/**
* Add index on timestamp.
*/
function aggregator_update_8002() {
if (!db_index_exists('aggregator_item', 'timestamp')) {
db_add_index('aggregator_item', 'timestamp', array('timestamp'));
}
}
......@@ -17,352 +17,3 @@ function block_install() {
// so before block module runs, there will not be much to alter.
module_set_weight('block', -5);
}
/**
* @addtogroup updates-7.x-to-8.x
* @{
*/
/**
* Implements hook_update_dependencies().
*/
function block_update_dependencies() {
// Convert role IDs after User module converted {role}.
$dependencies['block'][8002] = array(
'user' => 8002,
);
// Migrate users.data after User module prepared the tables.
$dependencies['block'][8005] = array(
'user' => 8016,
);
// Migrate custom blocks after field storage has been reorganized.
$dependencies['block'][8008] = array(
'field' => 8006,
);
return $dependencies;
}
/**
* Block cache is always enabled in 8.x.
*
* @ingroup config_upgrade
*/
function block_update_8000() {
update_variable_del('block_cache');
}
/**
* Creates table {block_language} for language visibility settings per block.
*/
function block_update_8001() {
$schema = array(
'description' => 'Sets up display criteria for blocks based on langcode.',
'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' => "Language type name. Applied to filter the block by that type.",
),
'langcode' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'description' => "The machine-readable name of this language from {language}.langcode.",
),
),
'primary key' => array('module', 'delta', 'type', 'langcode'),
);
db_create_table('block_language', $schema);
}
/**
* Replace serial role IDs with machine name strings.
*
* @see user_update_8002()
*/
function block_update_8002() {
// Change serial rid column into string.
$column = array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => "The user's role ID from {users_roles}.rid.",
);
db_change_field('block_role', 'rid', 'rid', $column);
// Rename the built-in serial role IDs into the hardcoded machine names.
db_update('block_role')
->fields(array('rid' => DRUPAL_ANONYMOUS_RID))
->condition('rid', 1)
->execute();
db_update('block_role')
->fields(array('rid' => DRUPAL_AUTHENTICATED_RID))
->condition('rid', 2)
->execute();
}
/**
* Increase {block}.title length to 255 characters.
*/
function block_update_8003() {
db_change_field('block', 'title', 'title', array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Custom title for the block. (Empty string will use block default title, - None - will remove the title, text will cause block to use specified title.)',
)
);
}
/**
* Rename default menu names.
*/
function block_update_8004() {
// System menu's new block deltas are prefixed with 'menu-'.
$map = array(
'navigation' => 'menu-tools',
'management' => 'menu-admin',
'user-menu' => 'menu-account',
'main-menu' => 'menu-main',
);
foreach ($map as $old => $new) {
db_update('block')
->condition('module', 'system')
->condition('delta', $old)
->fields(array('delta' => $new))
->execute();
db_update('block_language')
->condition('module', 'system')
->condition('delta', $old)
->fields(array('delta' => $new))
->execute();
db_update('block_role')
->condition('module', 'system')
->condition('delta', $old)
->fields(array('delta' => $new))
->execute();
}
}
/**
* Migrate {users}.data into {users_data}.
*/
function block_update_8005() {
$query = db_select('_d7_users_data', 'ud');
$query->addField('ud', 'uid');
$query->addExpression("'block'", 'module');
$query->addExpression("'block'", 'name');
// Take over the extracted and serialized value in {_d7_users_data} as-is.
$query->addField('ud', 'value');
$query->addExpression('1', 'serialized');
$query->condition('name', 'block');
db_insert('users_data')
->from($query)
->execute();
db_delete('_d7_users_data')
->condition('name', 'block')
->execute();
}
/**
* Enable the Custom Block module.
*/
function block_update_8006() {
\Drupal::moduleHandler()->install(array('custom_block'));
}
/**
* Migrate {block_custom} to {custom_block}.
*
* Note this table now resides in custom_block_schema() but for 7.x to 8.x
* upgrades, changes must be made from block module as custom_block module is
* only enabled during upgrade process.
*/
function block_update_8007() {
// Populate the {custom_block} and {custom_block_revision} table.
$results = db_select('block_custom', 'bc')->fields('bc')->execute();
$uuid = \Drupal::service('uuid');
$execute = FALSE;
$block_insert = db_insert('custom_block')->fields(array(
'id',
'uuid',
'info',
'revision_id',
'langcode',
'type',
'changed',
));
$revision_insert = db_insert('custom_block_revision')->fields(array(
'id',
'revision_id',
'log',
'info',
'changed',
));
foreach ($results as $block) {
$custom_block = array(
'id' => $block->bid,
'uuid' => $uuid->generate(),
'info' => $block->info,
'revision_id' => $block->bid,
'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'type' => 'basic',
'changed' => REQUEST_TIME,
);
$revision = array(
'id' => $block->bid,
'revision_id' => $block->bid,
'info' => $block->info,
'log' => 'Initial value from 7.x to 8.x upgrade',
'changed' => REQUEST_TIME,
);
$block_insert->values($custom_block);
$revision_insert->values($revision);
// We have something to execute.
$execute = TRUE;
}
if ($execute) {
$block_insert->execute();
$revision_insert->execute();
}
}
/**
* Migrate {block_custom}.body and {block_custom}.format to body field.
*/
function block_update_8008() {
$sandbox['#finished'] = 0;
if (!isset($sandbox['total'])) {
// Initial invocation.
// First, create the body field.
$body_field = array(
'name' => 'body',
'entity_type' => 'custom_block',
'type' => 'text_with_summary',
'module' => 'text',
'cardinality' => 1,
'schema' => array(
'columns' => array(
'value' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'summary' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'format' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
'indexes' => array(
'format' => array('format'),
),
),
);
_update_8003_field_create_field($body_field);
$instance = array(
'entity_type' => 'custom_block',
'bundle' => 'basic',
'label' => 'Block body',
'settings' => array('display_summary' => FALSE),
);
_update_8003_field_create_instance($body_field, $instance);
module_load_install('entity');
// Assign form settings for the 'default' form mode.
$form_display = _update_8000_entity_get_form_display('custom_block', 'basic', 'default');
$form_display->set('content.user_picture', array(
'type' => 'text_textarea_with_summary',
))
->save();
// Initialize state for future calls.
$sandbox['last'] = 0;
$sandbox['count'] = 0;
$query = db_select('block_custom', 'bc');
$sandbox['total'] = $query->countQuery()->execute()->fetchField();
$sandbox['body_field_id'] = $body_field['id'];
}
else {
// Subsequent invocations.
$found = FALSE;
if ($sandbox['total']) {
// Operate on each block in turn.
$batch_size = 200;
$query = db_select('block_custom', 'bc');
$query
->fields('bc', array('bid', 'body', 'format'))
->condition('bc.bid', $sandbox['last'], '>')
->orderBy('bc.bid', 'ASC')
->range(0, $batch_size);
$blocks = $query->execute();
// Load the block, set up 'body' and save the field data.
foreach ($blocks as $block) {
$found = TRUE;
$data = array(
Language::LANGCODE_NOT_SPECIFIED => array(
array(
'format' => $block->format,
'value' => $block->body
)
)
);
// This is a core update and no contrib modules are enabled yet, so
// we can assume default field storage for a faster update.
_update_8006_field_write_data_sql('custom_block', 'basic', $block->bid, $block->bid, 'body', $data);
$sandbox['last'] = $block->bid;
$sandbox['count'] += 1;
}
$sandbox['#finished'] = min(0.99, $sandbox['count'] / $sandbox['total']);
}
if (!$found) {
// All blocks are processed.
// Remove the now-obsolete body info from block_custom.
db_drop_field('block_custom', 'body');
db_drop_field('block_custom', 'format');
// We're done.
$sandbox['#finished'] = 1;
}
}
}
/**
* @} End of "addtogroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
*/
......@@ -56,26 +56,3 @@ function book_schema() {
return $schema;
}
/**
* Move the Book module settings from variables to config.
*
* @ingroup config_upgrade
*/
function book_update_8000() {
update_variables_to_config('book.settings', array(
'book_child_type' => 'child_type',
'book_block_mode' => 'block.navigation.mode',
));
$allowed_types = update_variable_get('book_allowed_types', FALSE);
if ($allowed_types) {
// Ensure consistent ordering of allowed_types.
// @see book_admin_settings_submit()
sort($allowed_types);
\Drupal::config('book.settings')
->set('allowed_types', $allowed_types)
->save();
}
}
......@@ -37,31 +37,3 @@ function color_requirements($phase) {
return $requirements;
}
/**
* Converts variables to config.
*/
function color_update_8001() {
$themes = db_select('variable', 'v')
->fields('v', array('name'))
->condition('v.name', db_like('color_') . '%' . db_like('_palette'), 'LIKE')
->execute()
->fetchAllAssoc('name');
foreach ($themes as $theme_palette => $theme) {
// Get theme name from color palette variable.
preg_match('/color_(.*)_palette/', $theme_palette, $matches);
$theme_key = $matches[1];
$config = \Drupal::config('color.' . $theme_key);
$config->set('palette', update_variable_get('color_' . $theme_key . '_palette'));
$config->set('logo', update_variable_get('color_' . $theme_key . '_logo'));
$config->set('stylesheets', update_variable_get('color_' . $theme_key . '_stylesheets'));
$config->set('files', update_variable_get('color_' . $theme_key . '_files'));
// Screenshot is optional.
if (update_variable_get('color_' . $theme_key . '_screenshot')) {
$config->set('screenshot', update_variable_get('color_' . $theme_key . '_screenshot'));
}
$config->save();
}
}
This diff is collapsed.
......@@ -17,94 +17,3 @@ function contact_install() {
}
\Drupal::config('contact.category.feedback')->set('recipients', array($site_mail))->save();
}
/**
* @addtogroup updates-7.x-to-8.x
* @{
*/
/**
* Implements hook_update_dependencies().
*/
function contact_update_dependencies() {
// Migrate users.data after User module prepared the tables.
$dependencies['contact'][8003] = array(
'user' => 8011,
);
return $dependencies;
}
/**
* Moves contact setting from variable to config.
*
* @ingroup config_upgrade
*/
function contact_update_8000() {
update_variables_to_config('contact.settings', array(
'contact_default_status' => 'user_default_enabled',
'contact_threshold_limit' => 'flood.limit',
'contact_threshold_window' => 'flood.interval',
));
}
/**
* Migrate contact categories into configuration.
*
* @ingroup config_upgrade
*/
function contact_update_8001() {
$uuid = \Drupal::service('uuid');
$result = db_query('SELECT * FROM {contact}');
foreach ($result as $category) {
// Take over the category's serial ID as new machine name.
$category->id = $category->cid;
// Save default category setting.
if ($category->selected) {
\Drupal::config('contact.settings')
->set('default_category', $category->id)
->save();
}
// Save the config object.
\Drupal::config('contact.category.' . $category->id)
->set('id', $category->id)
->set('uuid', $uuid->generate())
->set('label', $category->category)
->set('recipients', explode(',', $category->recipients))
->set('reply', $category->reply)
->set('weight', $category->weight)
->set('langcode', Language::LANGCODE_NOT_SPECIFIED)
->save();
}
}
/**
* Drop the {contact} table.
*/
function contact_update_8002() {
db_drop_table('contact');
}
/**
* Migrate {users}.data into {users_data}.
*/
function contact_update_8003() {
$query = db_select('_d7_users_data', 'ud');
$query->condition('name', 'contact');
$query->addField('ud', 'uid');
$query->addExpression("'contact'", 'module');
$query->addExpression("'enabled'", 'name');
$query->addField('ud', 'value', 'value');
$query->addExpression(1, 'serialized');
db_insert('users_data')
->from($query)
->execute();
db_delete('_d7_users_data')
->condition('name', 'contact')
->execute();
}
/**
* @} End of "defgroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
*/
......@@ -92,41 +92,3 @@ function dblog_schema() {
return $schema;
}
/**
* @addtogroup updates-7.x-to-8.x
* @{
*/
/**
* Update settings to the new configuration system.
*/
function dblog_update_8000() {
update_variables_to_config('dblog.settings', array(
'dblog_row_limit' => 'row_limit',
));
}
/**
* Make *id fields unsigned.
*/
function dblog_update_8001() {
db_drop_index('watchdog', 'uid');
db_change_field('watchdog', 'uid', 'uid',
array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {users}.uid of the user who triggered the event.',
),
array('indexes' => array(
'uid' => array('uid'),
))
);
}
/**
* @} End of "addtogroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
*/
<?php
/**
* @file
* Install, update and uninstall functions for the entity module.
*/
/**
* Returns the raw configuration object for an EntityDisplay entity.
*
* The function returns the existing configuration entry if it exists, or