1 update.inc update_fix_requirements()

Perform Drupal 7.x to Backdrop 1.x updates that are required for update.php to function properly.

This function runs when update.php is run the first time for Backdrop 1.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.


core/includes/update.inc, line 384
Backdrop database update API.


function update_fix_requirements() {
  if (backdrop_get_installed_schema_version('system') > 7000 && !state_get('update_backdrop_requirements', FALSE)) {
    // Copy over the private key for continuity between the sites. If this is
    // not migrated, a random key will be generated when visiting update.php.
    if ($key = update_variable_get('drupal_private_key')) {
      state_set('private_key', $key);

    // Enable the Views module if necessary.
    if (!db_query("SELECT name FROM {system} WHERE name = 'views' AND type = 'module' AND status = 1")->fetchField()) {
      $schema_cache_views = backdrop_get_schema_unprocessed('system', 'cache');
      $schema_cache_views['description'] = 'Cache table for Views to store loaded view configurations.';

      $schema_cache_views_data = backdrop_get_schema_unprocessed('system', 'cache');
      $schema_cache_views_data['description'] = 'Cache table for views to store pre-rendered queries, results, and display output.';
      $schema_cache_views_data['fields']['serialized']['default'] = 1;

      if (!db_table_exists('cache_views')) {
        db_create_table('cache_views', $schema_cache_views);
      if (!db_table_exists('cache_views_data')) {
        db_create_table('cache_views_data', $schema_cache_views_data);

    // Enable the File module if necessary, as it is a required module in
    // Backdrop, but may be off in Drupal.
    if (!db_query("SELECT name FROM {system} WHERE name = 'file' AND type = 'module' AND status = 1")->fetchField()) {

    // Empty a few basic caches.

    state_set('update_backdrop_requirements', TRUE);