function update_fix_d8_requirements

Performs Drupal 7.x to 8.x required update.php updates.

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.

1 call to update_fix_d8_requirements()
update.php in drupal/core/update.php
Administrative page for handling updates from one Drupal version to another.

File

drupal/core/includes/update.inc, line 627
Drupal database update API.

Code

function update_fix_d8_requirements() {
  if (drupal_get_installed_schema_version('system') < 8000 && !update_variable_get('update_d8_requirements', FALSE)) {

    // Make sure that file.module is enabled as it is required for the user
    // picture upgrade path.
    module_enable(array(
      'file',
    ));
    $schema = array(
      'description' => 'Generic key/value storage table with an expiration.',
      'fields' => array(
        'collection' => array(
          'description' => 'A named collection of key and value pairs.',
          'type' => 'varchar',
          'length' => 128,
          'not null' => TRUE,
          'default' => '',
        ),
        'name' => array(
          // KEY is an SQL reserved word, so use 'name' as the key's field name.
          'description' => 'The key of the key/value pair.',
          'type' => 'varchar',
          'length' => 128,
          'not null' => TRUE,
          'default' => '',
        ),
        'value' => array(
          'description' => 'The value of the key/value pair.',
          'type' => 'blob',
          'not null' => TRUE,
          'size' => 'big',
        ),
        'expire' => array(
          'description' => 'The time since Unix epoch in seconds when this item expires. Defaults to the maximum possible time.',
          'type' => 'int',
          'not null' => TRUE,
          'default' => 2147483647,
        ),
      ),
      'primary key' => array(
        'collection',
        'name',
      ),
      'indexes' => array(
        'all' => array(
          'name',
          'collection',
          'expire',
        ),
      ),
    );
    db_create_table('key_value_expire', $schema);

    // Views module is required to convert all previously existing listings into
    // views configurations.
    // Like any other module APIs and services, Views' services are not available
    // in update.php. Existing listings are migrated into configuration, using
    // the limited standard tools of raw database queries and config().
    module_enable(array(
      'views',
    ));
    update_variable_set('update_d8_requirements', TRUE);
  }
}