From a22d2912de3dbfde134faad9adafb1593f9f1ea9 Mon Sep 17 00:00:00 2001 From: florenttorregrosa Date: Thu, 1 Dec 2016 17:45:54 +0100 Subject: [PATCH] Issue #2830557 by Grimreaper, helmo, colan: Support for --entity-updates option on drush updb command --- drush/provision_tasks_extra.drush.inc | 31 +++++++++++++++++++++++++++++-- hosting_tasks_extra.module | 9 +++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drush/provision_tasks_extra.drush.inc b/drush/provision_tasks_extra.drush.inc index 181e2fa..d6ad68f 100644 --- a/drush/provision_tasks_extra.drush.inc +++ b/drush/provision_tasks_extra.drush.inc @@ -97,8 +97,15 @@ function drush_provision_tasks_extra_provision_run_cron() { */ function drush_provision_tasks_extra_provision_update() { drush_errors_on(); - provision_backend_invoke(d()->name, 'updatedb'); - drush_log(dt('Drush updatedb task completed')); + $options = d()->options; + if (isset($options['entity_updates']) && $options['entity_updates'] && drush_drupal_major_version(d()->root) >= 8) { + provision_backend_invoke(d()->name, 'updatedb', array('--entity-updates')); + drush_log(dt('Drush updatedb task completed with --entity-updates')); + } + else { + provision_backend_invoke(d()->name, 'updatedb'); + drush_log(dt('Drush updatedb task completed w/o --entity-updates')); + } } /** @@ -192,3 +199,23 @@ function drush_provision_tasks_extra_provision_features_revert_all() { provision_backend_invoke(d()->name, 'features-revert-all'); drush_log(dt('All features reverted.')); } + +/** + * Implements drush_HOOK_pre_COMMAND(). + * + * This runs for each tasks during the command + * drush @hostmaster hosting-tasks + * + * NOTE: This ONLY runs when being called from a hostmaster task. + * This hook should ONLY be used to pass Options from a hostmaster task form to + * the $task object, or if you don't need this functionality from the command + * line. + */ +function drush_provision_tasks_extra_pre_hosting_task() { + $task = &drush_get_context('HOSTING_TASK'); + + // Update. + if ($task->ref->type == 'site' && $task->task_type == 'update' && isset($task->task_args['entity_updates'])) { + $task->options['entity_updates'] = $task->task_args['entity_updates']; + } +} diff --git a/hosting_tasks_extra.module b/hosting_tasks_extra.module index 3cbd01d..0b61af8 100644 --- a/hosting_tasks_extra.module +++ b/hosting_tasks_extra.module @@ -133,6 +133,15 @@ function hosting_task_update_form($node) { $form['operations'] = array( '#value' => $value, ); + + $platform_node = node_load($node->platform); + $core_major_version = $platform_node->release->version[0]; + if ($core_major_version >= 8) { + $form['entity_updates'] = array( + '#type' => 'checkbox', + '#title' => t('Run automatic entity schema updates at the end of any update hooks.'), + ); + } return $form; } -- 1.9.1