function entity_updates_main

8.0.x update.inc entity_updates_main()
master update.inc entity_updates_main()

Apply pending entity schema updates.

1 call to entity_updates_main()
drush_core_entity_updates in commands/core/core.drush.inc
Command handler. Apply pending entity schema updates.

File

commands/core/drupal/update.inc, line 349
Update.php for provisioned sites. This file is a derivative of the standard drupal update.php, which has been modified to allow being run from the command line.

Code

function entity_updates_main() {
  $change_summary = \Drupal::entityDefinitionUpdateManager()->getChangeSummary();
  if (!empty($change_summary)) {
    drush_print(dt('The following updates are pending:'));
    drush_print();

    foreach ($change_summary as $entity_type_id => $changes) {
      drush_print($entity_type_id . ' entity type : ');
      foreach ($changes as $change) {
        drush_print(strip_tags($change), 2);
      }
    }

    if (!drush_confirm(dt('Do you wish to run all pending updates?'))) {
      return drush_user_abort();
    }

    $operations[] = array('drush_update_entity_definitions', array());


    $batch['operations'] = $operations;
    $batch += array(
      'title' => 'Updating',
      'init_message' => 'Starting updates',
      'error_message' => 'An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.',
      'finished' => 'drush_update_finished',
      'file' => 'includes/update.inc',
    );
    batch_set($batch);
    \Drupal::service('state')->set('system.maintenance_mode', TRUE);
    drush_backend_batch_process('updatedb-batch-process');
    \Drupal::service('state')->set('system.maintenance_mode', FALSE);
  }
  else {
    drush_log(dt("No entity schema updates required"), LogLevel::SUCCESS);
  }
}