Commit bf2e5a65 authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian

#415152 - moved update command upstream to drush, now calling it via...

#415152 - moved update command upstream to drush, now calling it via drush_backend_invoke. removing 1000 lines of code from provision. yay
parent ec7743f0
<?php
// $Id$
/**
* @file
* 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.
*/
ob_start();
include_once("update.php");
ob_end_clean();
function update_main() {
include_once './includes/install.inc';
drupal_load_updates();
update_fix_schema_version();
update_fix_watchdog_115();
update_fix_watchdog();
update_fix_sessions();
$start = array();
foreach (module_list() as $module) {
$updates = drupal_get_schema_versions($module);
if ($updates !== FALSE) {
$updates = drupal_map_assoc($updates);
$updates[] = 'No updates available';
$default = drupal_get_installed_schema_version($module);
foreach (array_keys($updates) as $update) {
if ($update > $default) {
$default = $update;
break;
}
}
$start[$module] = $default;
}
}
$update_results = array();
foreach ($start as $module => $version) {
drupal_set_installed_schema_version($module, $version - 1);
$updates = drupal_get_schema_versions($module);
$max_version = max($updates);
if ($version <= $max_version) {
drush_log(pt('Updating module @module from schema version @start to schema version @max', array('@module' => $module, '@start' => $version - 1, '@max' => $max_version)));
foreach ($updates as $update) {
$finished = FALSE;
if ($update >= $version) {
while (!$finished) {
// do update
$ret = module_invoke($module, 'update_' . $update);
_drush_log_update_sql($ret);
$finished = 1;
if (isset($ret['#finished'])) {
$finished = $ret['#finished'];
unset($ret['#finished']);
}
}
drupal_set_installed_schema_version($module, $update);
}
}
}
else {
drush_log(pt('No updates for @module module', array('@module' => $module)));
}
}
}
update_main();
This diff is collapsed.
This diff is collapsed.
......@@ -33,7 +33,6 @@ function provision_drupal_drush_help($section) {
function provision_drupal_drush_engine_drupal() {
$engines = array();
$engines['install'] = array();
$engines['update'] = array();
$engines['import'] = array();
$engines['deploy'] = array();
$engines['clear'] = array();
......
......@@ -6,7 +6,8 @@ function provision_drupal_provision_update_validate() {
function provision_drupal_provision_update($url) {
_provision_drupal_create_settings_file($url);
drush_backend_invoke("update", array('uri' => "http://$url"));
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
drush_include_engine('drupal', 'update');
drush_include_engine('drupal', 'clear');
# drush_include_engine('drupal', 'update');
# drush_include_engine('drupal', 'clear');
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment