Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions commands/core/drupal/update.inc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ function update_main() {
drupal_load_updates();
update_fix_compatibility();

// Check requirements before updating.
if (!drush_update_check_requirements()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be a validation callback instead, so it's run before we hit the actual command? Then drush_update_check_requirements can just be used directly or the validation command can call out to that as the code is now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well then we have to go through the rigmarole of loading all the .install files in the validation

return;
}

// Pending hook_update_N() implementations.
$pending = update_get_update_list();

Expand Down Expand Up @@ -186,6 +191,36 @@ function update_main() {
return count($pending) + count($change_summary) + count($post_updates);
}

/**
* Check update requirements and report any errors.
*/
function drush_update_check_requirements() {
$continue = TRUE;

\Drupal::moduleHandler()->resetImplementations();
$requirements = update_check_requirements();
$severity = drupal_requirements_severity($requirements);

// If there are issues, report them.
if ($severity != REQUIREMENT_OK) {
if ($severity === REQUIREMENT_ERROR) {
$continue = FALSE;
}
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] != REQUIREMENT_OK) {
$message = isset($requirement['description']) ? $requirement['description'] : '';
if (isset($requirement['value']) && $requirement['value']) {
$message .= ' (Currently using '. $requirement['title'] .' '. $requirement['value'] .')';
}
$log_level = $requirement['severity'] === REQUIREMENT_ERROR ? LogLevel::ERROR : LogLevel::WARNING;
drush_log($message, $log_level);
}
}
}

return $continue;
}

function _update_batch_command($id) {
// In D8, we expect to be in full bootstrap.
drush_bootstrap_to_phase(DRUSH_BOOTSTRAP_DRUPAL_FULL);
Expand Down