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

Better fix for DB type requirement. Now in _INIT. Change perm of sites/default...

Better fix for DB type requirement. Now in _INIT. Change perm of sites/default before and after writing config
parent 49e11bb9
......@@ -475,14 +475,11 @@ function provision_shell_exec() {
*/
function provision_set_active_db($new_db_url = NULL) {
static $old_db_url = NULL;
static $old_db_type = NULL;
global $db_url;
#initialize static
if (!$old_db_url) {
$old_db_url = $db_url;
preg_match("$^([a-z]*)://$", $old_db_url, $matches);
$old_db_type = $matches[1];
$db_url = array();
$db_url['default'] = $old_db_url;
}
......@@ -490,8 +487,8 @@ function provision_set_active_db($new_db_url = NULL) {
if ($new_db_url) {
preg_match("$^([a-z]*)://$", $new_db_url, $matches);
if ($matches[1] != $old_db_type) {
$new_db_url = preg_replace("/^" .$matches[1]. "/", $old_db_type, $new_db_url);
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));
......
......@@ -90,11 +90,14 @@ function provision_init() {
define('PROVISION_WEB_MAINTENENCE_URL', PROVISION_MASTER_URL .'/provision/maintenance');
$db = parse_url(PROVISION_MASTER_DB);
define('PROVISION_DB_TYPE', $db['scheme']);
define('PROVISION_DB_USER', $db['user']);
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]);
}
......@@ -141,6 +144,7 @@ function _provision_config_defaults() {
*/
function _provision_generate_config($data = array()) {
provision_log('notice', t("Generating provision.settings.php file"));
provision_path("chmod", "sites/default", 0750);
if (provision_path("exists", "sites/default/provision.settings.php")) {
provision_path("chmod", "sites/default/provision.settings.php", 0600,
t('Changed permissions of provision.settings.php to @confirm'),
......@@ -157,6 +161,7 @@ function _provision_generate_config($data = array()) {
provision_path("chmod", "sites/default/provision.settings.php", 0400,
t('Changed permissions of provision.settings.php to @confirm'),
t('Could not change permissions of provision.settings.php to @confirm'));
provision_path("chmod", "sites/default", 0550);
return TRUE;
}
......
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