Commit 161eef00 authored by anarcat's avatar anarcat Committed by anarcat

follow the error API changes, see #411822

parent cd6cd737
......@@ -9,13 +9,6 @@
*/
include_once('provision.mysql.inc');
define('PROVISION_CREATE_DB_FAILED', 'PROVISION_CREATE_DB_FAILED');
define('PROVISION_DROP_DB_FAILED', 'PROVISION_DROP_DB_FAILED');
define('PROVISION_DB_DUMP_NOT_FOUND', 'PROVISION_DB_DUMP_NOT_FOUND');
define('PROVISION_DB_DUMP_NOT_READABLE', 'PROVISION_DB_DUMP_NOT_READABLE');
define('PROVISION_DB_IMPORT_FAILED', 'PROVISION_DB_IMPORT_FAILED');
function provision_mysql_provision_init() {
drush_set_default('master_db', $GLOBALS['db_url']);
$master_db = drush_get_option('master_db');
......@@ -48,7 +41,7 @@ function provision_mysql_drush_help($section) {
function _provision_mysql_new_site_db($db_name, $db_user, $db_passwd, $db_host) {
if (!_provision_mysql_create_database($db_name) ||
!_provision_mysql_database_exists($db_name) ) {
drush_set_error(PROVISION_CREATE_DB_FAILED);
drush_set_error('PROVISION_CREATE_DB_FAILED');
drush_log("Database could not be created.", 'error');
return FALSE;
}
......@@ -65,7 +58,7 @@ function _provision_mysql_new_site_db($db_name, $db_user, $db_passwd, $db_host)
drush_log(dt('Created @name database', array("@name" => $db_name)), 'success');
}
else {
drush_set_error(PROVISION_CREATE_DB_FAILED, dt("Could not create @name database", array("@name" => $db_name)));
drush_set_error('PROVISION_CREATE_DB_FAILED', dt("Could not create @name database", array("@name" => $db_name)));
}
return $status;
//TODO : Test to confirm that the database is actually writeable. Taking this on faith for now.
......@@ -84,7 +77,7 @@ function _provision_mysql_destroy_site_db($db_name, $db_user, $db_passwd, $db_ho
}
if ( _provision_mysql_database_exists($db_name) ) {
drush_set_error(PROVISION_DROP_DB_FAILED);
drush_set_error('PROVISION_DROP_DB_FAILED');
return FALSE;
}
......@@ -147,7 +140,7 @@ function _provision_mysql_import_dump($dump_file, $db_name, $db_user, $db_passwd
drush_log(sprintf("Importing database using command: mysql -u%s -p%s -h%s %s < %s",
$db_user, $db_passwd, $db_host, $db_name, $dump_file));
if (!provision_shell_exec("mysql -u%s -p%s -h%s %s < %s", $db_user, $db_passwd, $db_host, $db_name, $dump_file )) {
drush_set_error(PROVISION_DB_IMPORT_FAILED, dt("Database import failed"));
drush_set_error('PROVISION_DB_IMPORT_FAILED', dt("Database import failed"));
}
}
}
......
......@@ -15,7 +15,7 @@ function provision_dns_provision_pre_install($url = NULL) {
if ($url) {
# $url_parts = _provision_dns_split_url($url);
# if (!isset($url_parts['zone'])) {
# drush_set_error(PROVISION_FRAMEWORK_ERROR);
# drush_set_error('PROVISION_FRAMEWORK_ERROR');
# return;
# }
......
......@@ -134,7 +134,7 @@ function provision_bind_update_zone($zone, $exists = FALSE) {
fwrite($fd, $zone_str); # Write the zonefile
fclose($fd);
} else {
drush_set_error(PROVISION_PERM_ERROR);
drush_set_error('PROVISION_PERM_ERROR');
}
}
......@@ -179,7 +179,7 @@ function _provision_bind_add_record($zone, $record) {
fwrite($fh, $line);
fclose($fh);
} else {
drush_set_error(PROVISION_PERM_ERROR);
drush_set_error('PROVISION_PERM_ERROR');
}
}
......@@ -279,12 +279,12 @@ function _provision_bind_editfile($file, $old, $new = '') {
}
fclose($fd);
} else {
drush_set_error(PROVISION_PERM_ERROR);
drush_set_error('PROVISION_PERM_ERROR');
}
# Write out the changed lines to the original file again.
if (!file_put_contents($file, $lines)) {
drush_set_error(PROVISION_PERM_ERROR);
drush_set_error('PROVISION_PERM_ERROR');
}
}
......
......@@ -26,7 +26,7 @@ function provision_dns_provision_verify($url = NULL) {
drush_log("notice", "Hit provision_dns_provision_verify hook: $url");
# $url_parts = _provision_dns_split_url($url);
if (!isset($url_parts['zone'])) {
//drush_set_error(PROVISION_FRAMEWORK_ERROR);
//drush_set_error('PROVISION_FRAMEWORK_ERROR');
return;
}
......
......@@ -12,19 +12,19 @@
function provision_drupal_provision_backup_validate($url = NULL, $backup_file = NULL) {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
if (!drush_get_option('installed')) {
drush_set_error(PROVISION_DRUPAL_SITE_FOUND);
drush_set_error('PROVISION_DRUPAL_SITE_FOUND');
}
// This is the actual drupal provisioning requirements.
if (!is_dir(drush_get_option('backup_path'))) {
drush_set_error(PROVISION_BACKUP_PATH_NOT_FOUND);
drush_set_error('PROVISION_BACKUP_PATH_NOT_FOUND');
}
if ($backup_file) {
if ( provision_path("exists", $backup_file, FALSE,
dt("Backing site up to @path."),
dt("Back up file @path already exists."),
PROVISION_BACKUP_ALREADY_EXISTS)) {
'PROVISION_BACKUP_ALREADY_EXISTS')) {
drush_get_option('backup_file', $backup_file);
}
}
......@@ -52,7 +52,7 @@ function provision_drupal_provision_backup($url) {
$result = provision_shell_exec("cd %s; tar -rf %s * ", drush_get_option('sites_path') . "/$url", $backup_file);
if (!$result) {
drush_set_error(PROVISION_BACKUP_FAILED, dt("Could not back up sites directory for drupal"));
drush_set_error('PROVISION_BACKUP_FAILED', dt("Could not back up sites directory for drupal"));
}
}
......
......@@ -29,7 +29,7 @@ function provision_drupal_provision_deploy_validate($url = null, $backup_file =
$exists = provision_path("exists", $backup_file, TRUE,
dt("Deploying site from @path"),
dt("Could not find backup file @path"),
PROVISION_BACKUP_NOT_FOUND);
'PROVISION_BACKUP_NOT_FOUND');
if ($exists) {
drush_set_option('backup_file', $backup_file);
}
......@@ -42,7 +42,7 @@ function provision_drupal_provision_pre_deploy($url, $backup_file) {
$extracted = provision_path("extract", drush_get_option('backup_file'), drush_get_option('sites_path') ."/$url",
dt('Successfully extracted the contents of @path'),
dt('Failed to extract the contents of @path'),
PROVISION_BACKUP_EXTRACTION_FAILED);
'PROVISION_BACKUP_EXTRACTION_FAILED');
if ($extracted) {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
// @TODO Clear up this properly.
......
......@@ -15,7 +15,7 @@ function provision_drupal_provision_disable_validate() {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
if (!drush_get_option('installed')) {
drush_set_error(PROVISION_DRUPAL_SITE_FOUND);
drush_set_error('PROVISION_DRUPAL_SITE_FOUND');
}
}
......
......@@ -119,12 +119,12 @@ function install_main() {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_DATABASE);
// Check if Drupal is installed.
if (install_verify_drupal()) {
drush_set_error(PROVISION_DRUPAL_SITE_INSTALLED, st('Site is already installed'));
drush_set_error('PROVISION_DRUPAL_SITE_INSTALLED', st('Site is already installed'));
return FALSE;
}
}
else {
drush_set_error(PROVISION_CONFIG_NOT_VALID, st('Config file could not be loaded'));
drush_set_error('PROVISION_CONFIG_NOT_VALID', st('Config file could not be loaded'));
return FALSE;
}
// Load module basics (needed for hook invokes).
......@@ -158,7 +158,7 @@ function install_main() {
$modules = drupal_verify_profile($profile, $install_locale);
if (!$modules) {
drush_set_error(PROVISION_DRUPAL_INSTALL_FAILED);
drush_set_error('PROVISION_DRUPAL_INSTALL_FAILED');
return FALSE;
}
foreach ($modules as $module) {
......
......@@ -151,11 +151,11 @@ function install_main() {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_DATABASE);
if (install_verify_drupal()) {
return drush_set_error(PROVISION_DRUPAL_SITE_INSTALLED);
return drush_set_error('PROVISION_DRUPAL_SITE_INSTALLED');
}
}
else {
return drush_set_error(PROVISION_CONFIG_NOT_VALID);
return drush_set_error('PROVISION_CONFIG_NOT_VALID');
}
......@@ -197,14 +197,14 @@ function install_main() {
}
if ($missing_requirement) {
return drush_set_error(PROVISION_INSTALL_MISSING_REQUIREMENTS);
return drush_set_error('PROVISION_INSTALL_MISSING_REQUIREMENTS');
}
// Verify existence of all required modules.
$modules = drupal_verify_profile($profile, $language);
if (!$modules) {
return drush_set_error(PROVISION_DRUPAL_INSTALL_FAILED);
return drush_set_error('PROVISION_DRUPAL_INSTALL_FAILED');
}
$system_path = dirname(drupal_get_filename('module', 'system', NULL));
......
......@@ -327,7 +327,7 @@ function update_main() {
// are removed, it will == 0.
$last_removed = module_invoke($module, 'update_last_removed');
if ($schema_version < $last_removed) {
drush_set_error(PROVISION_DRUPAL_UPDATE_FAILED, dt( $module .' module can not be updated. Its schema version is '. $schema_version .'. Updates up to and including '. $last_removed .' have been removed in this release. In order to update '. $module .' module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.'));
drush_set_error('PROVISION_DRUPAL_UPDATE_FAILED', dt( $module .' module can not be updated. Its schema version is '. $schema_version .'. Updates up to and including '. $last_removed .' have been removed in this release. In order to update '. $module .' module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.'));
continue;
}
......
......@@ -162,7 +162,7 @@ function install_main() {
// Check if Drupal is installed.
if (install_verify_drupal()) {
return drush_set_error(PROVISION_DRUPAL_SITE_INSTALLED);
return drush_set_error('PROVISION_DRUPAL_SITE_INSTALLED');
}
}
else {
......@@ -215,7 +215,7 @@ function install_main() {
}
if ($missing_requirement) {
return drush_set_error(PROVISION_DRUPAL_INSTALL_MISSING_REQUIREMENTS);
return drush_set_error('PROVISION_DRUPAL_INSTALL_MISSING_REQUIREMENTS');
}
// Verify existence of all required modules.
......@@ -224,7 +224,7 @@ function install_main() {
$severity = drupal_requirements_severity($requirements);
if ($severity == REQUIREMENT_ERROR) {
return drush_set_error(PROVISION_DRUPAL_INSTALL_MISSING_REQUIREMENTS);
return drush_set_error('PROVISION_DRUPAL_INSTALL_MISSING_REQUIREMENTS');
}
drupal_install_system();
......
......@@ -31,7 +31,7 @@ function update_main() {
// are removed, it will == 0.
$last_removed = module_invoke($module, 'update_last_removed');
if ($schema_version < $last_removed) {
drush_set_error(PROVISION_DRUPAL_UPDATE_FAILED, dt( $module .' module can not be updated. Its schema version is '. $schema_version .'. Updates up to and including '. $last_removed .' have been removed in this release. In order to update '. $module .' module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.'));
drush_set_error('PROVISION_DRUPAL_UPDATE_FAILED', dt( $module .' module can not be updated. Its schema version is '. $schema_version .'. Updates up to and including '. $last_removed .' have been removed in this release. In order to update '. $module .' module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.'));
continue;
}
......
......@@ -16,7 +16,7 @@
*/
function provision_drupal_provision_install_validate() {
if (drush_get_option('installed')) {
drush_set_error(PROVISION_SITE_INSTALLED);
drush_set_error('PROVISION_SITE_INSTALLED');
}
}
......
......@@ -8,16 +8,6 @@
* and all the install api code.
*/
define('PROVISION_BACKUP_PATH_NOT_FOUND', 'PROVISION_BACKUP_PATH_NOT_FOUND');
define('PROVISION_BACKUP_FAILED', 'PROVISION_BACKUP_FAILED');
define('PROVISION_DRUPAL_INSTALL_FAILED', 'PROVISION_DRUPAL_INSTALL_FAILED');
define('PROVISION_DRUPAL_UPDATE_FAILED', 'PROVISION_DRUPAL_UPDATE_FAILED');
define('PROVISION_DRUPAL_INSTALL_MISSING_REQUIREMENTS', 'PROVISION_DRUPAL_INSTALL_MISSING_REQUIREMENTS');
define('PROVISION_DRUPAL_SITE_INSTALLED', 'PROVISION_DRUPAL_SITE_INSTALLED');
define('PROVISION_DRUPAL_SITE_NOT_FOUND', 'PROVISION_DRUPAL_SITE_NOT_FOUND');
define('PROVISION_CONFIG_NOT_VALID', 'PROVISION_CONFIG_NOT_VALID');
define('PROVISION_REQUIRES_URL', 'PROVISION_REQUIRES_URL');
function provision_drupal_drush_help($section) {
switch ($section) {
case 'error:PROVISION_CONFIG_NOT_VALID' :
......@@ -88,7 +78,7 @@ function provision_drupal_provision_finalize($url = NULL) {
*/
function _provision_drupal_url_required() {
if (PROVISION_CONTEXT_PLATFORM) {
drush_set_error(PROVISION_REQUIRES_URL);
drush_set_error('PROVISION_REQUIRES_URL');
}
}
......@@ -100,7 +90,7 @@ function _provision_drupal_url_required() {
function _provision_drupal_valid_site() {
if (PROVISION_CONTEXT_SITE) {
if (!_provision_drupal_site_exists(drush_get_option('site_url'))) {
drush_set_error(PROVISION_DRUPAL_SITE_NOT_FOUND);
drush_set_error('PROVISION_DRUPAL_SITE_NOT_FOUND');
}
}
}
......@@ -126,7 +116,7 @@ function _provision_drupal_site_exists($url) {
function _provision_drupal_valid_installed_site() {
if (PROVISION_CONTEXT_SITE) {
if (!_provision_drupal_site_installed(drush_get_option('site_url'))) {
drush_set_error(PROVISION_DRUPAL_SITE_NOT_FOUND);
drush_set_error('PROVISION_DRUPAL_SITE_NOT_FOUND');
}
}
}
......@@ -134,7 +124,7 @@ function _provision_drupal_valid_installed_site() {
function _provision_drupal_valid_not_installed_site() {
if (PROVISION_CONTEXT_SITE) {
if (_provision_drupal_site_installed(drush_get_option('site_url'))) {
drush_set_error(PROVISION_DRUPAL_SITE_INSTALLED);
drush_set_error('PROVISION_DRUPAL_SITE_INSTALLED');
}
}
}
......@@ -379,7 +369,7 @@ function provision_drupal_install_log($ret) {
foreach ($ret as $info) {
if (is_array($info)) {
if (!$info['success']) {
drush_set_error(PROVISION_DRUPAL_INSTALL_FAILED, $msg);
drush_set_error('PROVISION_DRUPAL_INSTALL_FAILED', $msg);
}
drush_log($info['query'], ($info['success']) ? 'success' : 'error');
}
......
......@@ -29,7 +29,7 @@ function provision_drupal_provision_restore_validate($url = null, $restore_file
$exists = provision_path("exists", $restore_file, TRUE,
dt("Restoring site from @path"),
dt("Could not find backup file @path"),
PROVISION_BACKUP_NOT_FOUND);
'PROVISION_BACKUP_NOT_FOUND');
if ($exists) {
drush_set_option('restore_file', $restore_file);
}
......
......@@ -37,7 +37,7 @@
// Do not allow the program to be run as the root user. ever
$name = posix_getpwuid(posix_geteuid());
if ($name['name'] == 'root') {
return drush_set_error(PROVISION_IS_ROOT, dt('You are running the provision script as the root user. Exiting'));
return drush_set_error('PROVISION_IS_ROOT', dt('You are running the provision script as the root user. Exiting'));
}
/**
......
......@@ -13,8 +13,6 @@
* @see provisionvalues
*/
define('PROVISION_OUTPUT', 'PROVISION_OUTPUT_START>>>%s<<<PROVISION_OUTPUT_END');
/**
* Invoke provision api calls.
*
......
......@@ -79,7 +79,7 @@ function _provision_apache_create_vhost_config($url, $template = NULL) {
drush_log(dt("Generate virtual host configuration file."));
$writable = provision_path("writable", drush_get_option('vhost_path'), TRUE , NULL,
dt("Virtual host configuration path @path is not writable."),
PROVISION_VHOST_PATH_NOT_WRITABLE);
'PROVISION_VHOST_PATH_NOT_WRITABLE');
$options['extra_config'] = "# Extra configuration from modules:\n";
foreach (drush_command_implements('provision_vhost_config') as $module) {
$options['extra_config'] .= "# -- $module settings --\n";
......@@ -103,7 +103,7 @@ function _provision_apache_restart_apache($cause_error = FALSE) {
$return = drush_shell_exec(escapeshellcmd(drush_get_option('restart_cmd')));
if (!$return) {
if ($cause_error) {
return drush_set_error(PROVISION_WEB_RESTART_FAILED, dt("Web server could not be restarted. Changes might not be available until this has been done."));
return drush_set_error('PROVISION_WEB_RESTART_FAILED', dt("Web server could not be restarted. Changes might not be available until this has been done."));
}
else {
drush_log(dt("Web server could not be restarted. Changes might not be available until this has been done."), "warning");
......
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