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

moved the drupal installation process into it's own php process, to avoid...

moved the drupal installation process into it's own php process, to avoid cross db issues. much simpler now.
parent 398cc27d
This diff is collapsed.
This diff is collapsed.
......@@ -5,23 +5,13 @@
* Rebuild all the caches
*/
require_once(dirname(__FILE__) . '/../provision.inc');
if ($argv[1]) {
// Fake the necessary HTTP headers that Drupal needs:
$drupal_base_url = parse_url(sprintf("http://" . $argv[1]));
$_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
$_SERVER['PHP_SELF'] = $drupal_base_url['path'].'/index.php';
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
$_SERVER['REMOTE_ADDR'] = '';
$_SERVER['REQUEST_METHOD'] = NULL;
$_SERVER['SERVER_SOFTWARE'] = NULL;
require_once('includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once(dirname(__FILE__) . '/../provision.inc');
provision_external_init($argv[1]);
}
else {
print "USAGE: provision_drupal_clear.php url\n";
exit(PROVISION_FRAMEWORK_ERROR);
provision_set_error(PROVISION_FRAMEWORK_ERROR);
provision_log("error", "USAGE: clear.php url\n");
}
cache_clear_all();
......
<?php
if ($argv[1]) {
// Fake the necessary HTTP headers that Drupal needs:
$drupal_base_url = parse_url(sprintf("http://" . $argv[1]));
$_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
$_SERVER['PHP_SELF'] = $drupal_base_url['path'].'/index.php';
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
$_SERVER['REMOTE_ADDR'] = '';
$_SERVER['REQUEST_METHOD'] = NULL;
$_SERVER['SERVER_SOFTWARE'] = NULL;
require_once('includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once(dirname(__FILE__) . '/../provision.inc');
require_once(dirname(__FILE__) . '/../provision.inc');
if ($argv[1]) {
provision_external_init($argv[1]);
}
else {
print "USAGE: provision_drupal_import.php url\n";
exit(PROVISION_FRAMEWORK_ERROR);
provision_set_error(PROVISION_FRAMEWORK_ERROR);
provision_log("error", "USAGE: import.php url\n");
}
if ($parts = @parse_url($GLOBALS['db_url'])) {
......
......@@ -649,3 +649,51 @@ function provision_get_option($option, $default) {
return $default;
}
}
/**
* A wrapper for t(). The st() function is too specific for our purposes
*/
function pt($string, $args = array()) {
if (function_exists('t')) {
return call_user_func('t', $string, $args);
}
else {
// Transform arguments before inserting them
foreach ($args as $key => $value) {
switch ($key[0]) {
// Escaped only
case '@':
$args[$key] = check_plain($value);
break;
// Escaped and placeholder
case '%':
default:
$args[$key] = '<em>'. check_plain($value) .'</em>';
break;
// Pass-through
case '!':
}
}
return strtr($string, $args);
}
}
/**
* This is a script that allows external scripts to initialize themselves to a certain url (usually $argv[1])
*
* Some scripts need to run with drupal as the only active database, and this allows us to do that.
*/
function provision_external_init($url, $bootstrap = TRUE) {
$drupal_base_url = parse_url(sprintf("http://" . $url));
$_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
$_SERVER['PHP_SELF'] = $drupal_base_url['path'].'/install.php';
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
$_SERVER['REMOTE_ADDR'] = '';
$_SERVER['REQUEST_METHOD'] = NULL;
$_SERVER['SERVER_SOFTWARE'] = NULL;
if ($bootstrap) {
include_once('includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
}
}
......@@ -408,14 +408,7 @@ function provision_install_cmd($url) {
* Boolean denoting whether the provision_invoke rolled back changes made.
*/
function _provision_pre_install($url, &$data) {
$rolled_back = provision_invoke("pre_install", $url, $data);
if (!provision_get_error()) {
// This is the actual drupal provisioning requirements.
_provision_drupal_create_directories($url, $data['profile']);
// Requires at least the database settings to complete.
_provision_drupal_create_settings_file($url, $data);
}
return $rolled_back;
return provision_invoke("pre_install", $url, $data);
}
/**
......@@ -436,19 +429,7 @@ function _provision_pre_install($url, &$data) {
* Boolean denoting whether the provision_invoke rolled back changes made.
*/
function _provision_install($url, &$data) {
$rolled_back = provision_invoke("install", $url, $data);
if (!$rolled_back) {
_provision_drupal_switch_active_site($url); # Change headers and db info, also backs up
_provision_drupal_force_load_modules($url);
_provision_drupal_install_schema($url, $data['profile'], $data['language'], $data['client_email']);
_provision_drupal_maintain_aliases($url, $data); # Create symlinks for site aliases (if any)
_provision_drupal_force_load_modules();
_provision_drupal_switch_active_site(); # This *should* bring the site back to where we were before installing
}
return $rolled_back;
return provision_invoke("install", $url, $data);
}
/**
......@@ -465,11 +446,7 @@ function _provision_install($url, &$data) {
* Boolean denoting whether the provision_invoke rolled back changes made.
*/
function _provision_post_install($url, &$data) {
$rolled_back = provision_invoke("post_install", $url, $data);
if (!$rolled_back) {
$data['installed'] = TRUE;
}
return $rolled_back;
return provision_invoke("post_install", $url, $data);
}
/**
......
......@@ -35,15 +35,15 @@ define('PROVISION_DB_ERROR', 128);
//List of provisioning errors. This is a global so that other modules can reference it.
global $provision_errors;
$provision_errors = array(
PROVISION_SUCCESS => t("Successful"),
PROVISION_QUEUED => t("Queued"),
PROVISION_DB_ERROR => t("Database error"),
PROVISION_INSTALL_ERROR => t("Drupal installation error"),
PROVISION_PERM_ERROR => t("File permission error"),
PROVISION_WEB_ERROR => t("Web server error"),
PROVISION_FRAMEWORK_ERROR => t("Provision framework error"),
PROVISION_SITE_NOT_FOUND => t("Site not found"),
PROVISION_SITE_INSTALLED => t("Site has already been installed"),
PROVISION_SUCCESS => pt("Successful"),
PROVISION_QUEUED => pt("Queued"),
PROVISION_DB_ERROR => pt("Database error"),
PROVISION_INSTALL_ERROR => pt("Drupal installation error"),
PROVISION_PERM_ERROR => pt("File permission error"),
PROVISION_WEB_ERROR => pt("Web server error"),
PROVISION_FRAMEWORK_ERROR => pt("Provision framework error"),
PROVISION_SITE_NOT_FOUND => pt("Site not found"),
PROVISION_SITE_INSTALLED => pt("Site has already been installed"),
);
/**
* @} End of "name Error status defintions".
......
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