Skip to content
Snippets Groups Projects
Commit 3872c8a5 authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian
Browse files

Fix some issues with the site.php generation, that caused catastrophic...

Fix some issues with the site.php generation, that caused catastrophic problems when the site was synched (upon editing of the site node), because the site.php had been overwritten and lost it's db settings.
parent bced4f80
Branches
Tags
No related merge requests found
...@@ -237,6 +237,11 @@ function provision_mysql_provision_verify() { ...@@ -237,6 +237,11 @@ function provision_mysql_provision_verify() {
provision_set_active_db(); provision_set_active_db();
} }
function provision_mysql_restore($url, $backup_file, &$data) { function provision_mysql_pre_restore($url, $backup_file, &$data) {
}
function provision_mysql_import_dump($url, $backup_file, &$data) {
} }
...@@ -257,7 +257,8 @@ function provision_get_site_data($url) { ...@@ -257,7 +257,8 @@ function provision_get_site_data($url) {
} }
} }
$site_data['site_url'] = $url; $site_data['site_url'] = $url;
$site_data['site_action_type'] = $args['commands'][1]; $site_data['action_type'] = $args['commands'][1];
$site_data['action_id'] = drush_get_option('action_id', null);
$site_data['publish_path'] = PROVISION_DOCROOT_PATH; $site_data['publish_path'] = PROVISION_DOCROOT_PATH;
$site_data['site_profile'] = ($site_data['site_profile']) ? $site_data['site_profile'] : variable_get('provision_default_profile', 'default'); $site_data['site_profile'] = ($site_data['site_profile']) ? $site_data['site_profile'] : variable_get('provision_default_profile', 'default');
$site_data['site_ip'] = variable_get('provision_apache_server_ip', '127.0.0.1'); $site_data['site_ip'] = variable_get('provision_apache_server_ip', '127.0.0.1');
...@@ -282,7 +283,7 @@ function provision_load_site_data($url) { ...@@ -282,7 +283,7 @@ function provision_load_site_data($url) {
# Load the configuration data. # Load the configuration data.
$conf_file = "sites/$url/site.php"; $conf_file = "sites/$url/site.php";
if (file_exists($conf_file) && is_readable($conf_file)) { if (file_exists($conf_file) && is_readable($conf_file)) {
require_once($conf_file); require($conf_file);
return (array) $data; return (array) $data;
} }
return false; return false;
...@@ -298,30 +299,41 @@ function provision_load_site_data($url) { ...@@ -298,30 +299,41 @@ function provision_load_site_data($url) {
*/ */
function provision_save_site_data($url, $data) { function provision_save_site_data($url, $data) {
global $args; global $args;
$conf_file = "sites/$url/site.php";
$old_data = provision_load_site_data($url); $old_data = provision_load_site_data($url);
$conf_file = "sites/$url/site.php"; //initialize the file. this is lame, i know. but it will work.
$fp = fopen($conf_file, "w+"); # Append to the end of the config file. if (!file_exists($conf_file)) {
$fp = fopen($conf_file, "a+"); # Append to the end of the config file.
fwrite($fp, "<?php\n");
fclose($fp);
}
$fp = fopen($conf_file, "a+");
if (!$fp) { if (!$fp) {
provision_log("error", "Site config file could not be written"); provision_log("error", "Site config file could not be written");
provision_set_error(PROVISION_PERM_ERROR); provision_set_error(PROVISION_PERM_ERROR);
} }
else { else {
fwrite($fp, "<?php\n"); fwrite($fp, "\n\n#" . format_date(mktime(), "large"));
if ($data['action_id']) {
$action = array('id' => $data['action_id'], $action = array('id' => $data['action_id'],
'timestamp' => mktime(), 'timestamp' => mktime(),
'action' => $data['site_action_type'], 'action' => $data['site_action_type'],
'success' => $data['success']); 'status' => provision_get_error());
$line = "\n\n\$actions[] = " . var_export($action, TRUE) . ';'; $line = "\n\$actions[] = " . str_replace(array(" ", "\n"), "", var_export($action, TRUE)) . ";";
fwrite($fp, $line); fwrite($fp, $line);
}
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if (preg_match("/^site_/", $key)) {
if ($data[$key] != $old_data[$key]) { if ($data[$key] != $old_data[$key]) {
$line = "\n\$data['$key'] = " . var_export($value, true) . ';'; $line = "\n\$data['$key'] = " . var_export($value, true) . ';';
fwrite($fp, $line); fwrite($fp, $line);
} }
} }
}
fclose($fp); fclose($fp);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment