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

Migration from 5 to 6 to 7 now fully working. Still lacking dependency checking, so caveat emptor

parent 331ace95
......@@ -73,5 +73,5 @@ function provision_drupal_provision_deploy_rollback(&$data, $url) {
function provision_drupal_provision_post_deploy(&$data, $url) {
provision_invoke('update', $data, $url);
provision_platform_include(dirname(__FILE__), 'deploy');
provision_platform_include($data, dirname(__FILE__), 'deploy');
}
......@@ -53,14 +53,7 @@ function update_main() {
while (!$finished) {
// do update
$ret = module_invoke($module, 'update_' . $update);
// Assume the update finished unless the update results indicate otherwise.
foreach ($ret as $info) {
if (!$info['success']) {
provision_set_error('PROVISION_DB_ERROR');
}
provision_log( ($info['success']) ? 'success' : 'error', $info['query']);
}
provision_drupal_install_log($ret);
$finished = 1;
if (isset($ret['#finished'])) {
$finished = $ret['#finished'];
......
......@@ -18,8 +18,8 @@ function update_main() {
include_once './includes/batch.inc';
drupal_load_updates();
update_fix_d6_requirements();
update_fix_compatibility();
provision_drupal_install_log(update_fix_d6_requirements());
provision_drupal_install_log(update_fix_compatibility());
$start = array();
$modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
......@@ -99,12 +99,7 @@ function _update_do_one($module, $number, &$context) {
$function = $module .'_update_'. $number;
if (function_exists($function)) {
$ret = $function($context['sandbox']);
}
foreach ($ret as $info) {
if (!$info['success']) {
provision_set_error('PROVISION_DB_ERROR');
}
provision_log( ($info['success']) ? 'success' : 'error', $info['query']);
provision_drupal_install_log($ret);
}
if (isset($ret['#finished'])) {
......
......@@ -18,8 +18,8 @@ function update_main() {
include_once './includes/batch.inc';
drupal_load_updates();
update_fix_d6_requirements();
update_fix_compatibility();
provision_drupal_install_log(update_fix_d6_requirements());
provision_drupal_install_log(update_fix_compatibility());
$start = array();
$modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
......
......@@ -19,6 +19,6 @@ function provision_drupal_provision_import_validate() {
*/
function provision_drupal_provision_import(&$data, $url = NULL) {
provision_internal_init($url);
provision_platform_include(dirname(__FILE__), 'import');
provision_platform_include($data, dirname(__FILE__), 'import');
}
......@@ -37,7 +37,7 @@ function provision_drupal_provision_install(&$data, $url = NULL) {
// Requires at least the database settings to complete.
_provision_drupal_create_settings_file($data, $url);
provision_internal_init($url, FALSE);
provision_platform_include(dirname(__FILE__), 'install');
provision_platform_include($data, dirname(__FILE__), 'install');
}
/**
......
......@@ -213,10 +213,8 @@ function _provision_drupal_create_directories($url, $profile = NULL) {
*/
function _provision_drupal_rebuild_caches(&$data, $url = NULL) {
if (PLATFORM_CONTEXT_SITE) {
ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);
provision_internal_init($url);
provision_platform_include(dirname(__FILE__), 'clear');
provision_platform_include($data, dirname(__FILE__), 'clear');
}
}
......@@ -362,4 +360,12 @@ function _provision_drupal_delete_aliases($aliases) {
}
}
function provision_drupal_install_log($ret) {
foreach ($ret as $info) {
if (!$info['success']) {
provision_set_error('PROVISION_DB_ERROR');
}
provision_log( ($info['success']) ? 'success' : 'error', $info['query']);
}
}
......@@ -6,6 +6,8 @@ function provision_drupal_provision_update_validate() {
}
function provision_drupal_provision_update(&$data, $url) {
_provision_drupal_create_settings_file($data, $url);
provision_internal_init($data['site_url'], false);
provision_platform_include(dirname(__FILE__), 'update');
provision_platform_include($data, dirname(__FILE__), 'update');
provision_platform_include($data, dirname(__FILE__), 'clear');
}
......@@ -34,7 +34,7 @@ function provision_drupal_provision_verify(&$data, $url = null) {
// Requires at least the database settings to complete.
_provision_drupal_create_settings_file($data, $url);
// provision_internal_init($url);
// provision_platform_include(dirname(__FILE__), 'verify');
// provision_platform_include($data, dirname(__FILE__), 'verify');
}
if (is_array($data['modules'])) {
// get the correct version names for everything.
......
......@@ -56,8 +56,6 @@ function provision_init() {
provision_set_error(PROVISION_FRAMEWORK_ERROR);
provision_output($url);
}
// Load requested additional modules
#provision_load_from_args();
// Set up defines for platform
$docroot = provision_get_option(array("r", "root"), $_SERVER['PWD']);
......@@ -104,9 +102,7 @@ function provision_init() {
define('PROVISION_DB_PASSWD', $db['pass']);
define('PROVISION_DB_HOST', $db['host']);
// Drupal does not support multiple types of connections in the same session
preg_match("$^([a-z]*)://$", $GLOBALS['db_url'], $matches);
define('PROVISION_DB_TYPE', $matches[1]);
define('PROVISION_DB_TYPE', $db['scheme']);
}
......@@ -283,50 +279,6 @@ function _provision_generate_config() {
}
/**
* Load additional modules just for this process
*
* Load additional modules specified by --load_module_name
*/
function provision_load_from_args() {
if (!function_exists('drush_verify_cli')) {
return null;
}
global $args;
$reset = FALSE;
foreach ($args['options'] as $arg => $value) {
if (preg_match("/^load-([a-z\-]*)$/", $arg, $matches)) {
$module = str_replace("-", "_", $matches[1]);
// find file : can only search under provision path
$files = file_scan_directory(dirname(__FILE__), "$module.module", array('.', '..', 'CVS'), 0, TRUE, 'name');
if (isset($files[$module])) {
provision_log("notice", dt("Loading @module on request", array("@module" => $module)));
$loaded[$module]['name'] = $module;
$loaded[$module]['filename'] = $files[$module]->filename;
include_once($loaded[$module]['filename']);
}
$reset = TRUE;
}
}
$existing = array();
$list = module_list(TRUE, FALSE);
foreach ($list as $module) {
$existing[$module]['name'] = $module;
$existing[$module]['filename'] = drupal_get_filename('module', $module);
drupal_load('module', $module);
}
$loaded = array_merge($existing, (array) $loaded);
foreach ($loaded as $name => $info) {
$files = file_scan_directory(dirname($info['filename']), ".drush.inc$");
foreach ($files as $filename => $info2) {
include_once($filename);
}
}
module_list(TRUE, FALSE, TRUE, $loaded);
// Force to regenerate the stored list of hook implementations.
module_implements('', TRUE, TRUE);
}
function _provision_default_restart_cmd() {
# try to detect the apache restart command
......
......@@ -476,11 +476,13 @@ function provision_value_list() {
* Generate the text for a config file using php
*/
function provision_render_config($template, $variables) {
_provision_errors_off();
extract($variables, EXTR_SKIP); // Extract the variables to a local namespace
ob_start(); // Start output buffering
eval('?>'. $template); // Generate content
$contents = ob_get_contents(); // Get the contents of the buffer
ob_end_clean(); // End buffering and discard
_provision_errors_on();
return $contents; // Return the contents
}
......@@ -559,53 +561,6 @@ function provision_shell_exec() {
return drush_shell_exec($command);
}
/**
* Set the active database.
*
* Wrapper around db_set_active, which provides switching out of db_url.
* @param new_db_url
* The database url to set the connection to. If not provided, will switch back to Drupal default.
*/
function provision_set_active_db($new_db_url = NULL) {
static $old_db_url = NULL;
global $db_url;
#initialize static
if (!$old_db_url) {
$old_db_url = $db_url;
$db_url = array();
$db_url['default'] = $old_db_url;
}
if ($new_db_url) {
preg_match("$^([a-z]*)://$", $new_db_url, $matches);
if ($matches[1] != PROVISION_DB_TYPE) {
$new_db_url = preg_replace("/^" .$matches[1]. "/", PROVISION_DB_TYPE, $new_db_url);
}
$db_url[md5($new_db_url)] = $new_db_url;
db_set_active(md5($new_db_url));
}
else {
db_set_active('default');
}
}
/**
* Close an active connection
*
* This is an INCREDIBLY dangerous function, that is only used during import of sites
* to avoid creating connections for every site being imported
*/
function provision_close_active_db() {
global $active_db;
$close_db = $active_db;
db_set_active('default');
if ($close_db !== $active_db) {
db_close($close_db);
}
}
/**
......@@ -841,7 +796,7 @@ function provision_password($length = 10) {
return $pass;
}
function provision_platform_include($path, $command, $version = null, $platform = 'drupal') {
function provision_platform_include(&$data, $path, $command, $version = null, $platform = 'drupal') {
$version = ($version) ? $version : drush_drupal_major_version();
$options[] = sprintf("%s_%s_%s", $platform, $version, $command);
$options[] = sprintf("%s_%s", $platform, $command);
......@@ -861,3 +816,15 @@ function provision_platform_include($path, $command, $version = null, $platform
include_once($file);
}
}
function _provision_errors_on() {
ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);
}
_provision_errors_on();
function _provision_errors_off() {
ini_set('error_reporting', ~E_ALL);
ini_set('display_errors', FALSE);
}
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