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

#308255 - cleaned up a bunch of coder warnings

parent 3649f452
<?php
// $Id$
/**
* @file mysql db api extension
*
......@@ -33,7 +34,7 @@ function _provision_mysql_new_site_db($db_name, $db_user, $db_passwd, $db_host)
provision_set_active_db();
return $status;
#TODO : Test to confirm that the database is actually writeable. Taking this on faith for now.
//TODO : Test to confirm that the database is actually writeable. Taking this on faith for now.
}
/**
......@@ -88,9 +89,9 @@ function _provision_mysql_can_create_database() {
_provision_mysql_create_database($test);
if (_provision_mysql_database_exists($test)) {
_provision_mysql_drop_database($test);
return true;
return TRUE;
}
return false;
return FALSE;
}
function _provision_mysql_grant($name, $username, $password, $host = '') {
......@@ -118,12 +119,12 @@ function _provision_master_db_url($data = array()) {
function _provision_mysql_import_dump($dump_file, $db_name, $db_user, $db_passwd, $db_host) {
$exists = provision_path("exists", $dump_file, true,
$exists = provision_path("exists", $dump_file, TRUE,
t('Found database dump at @path.'),
t('No database dump was found at @path.'),
PROVISION_FRAMEWORK_ERROR);
if ($exists) {
$readable = provision_path("readable", $dump_file, true, '',
$readable = provision_path("readable", $dump_file, TRUE, '',
t('The database dump at @path could not be read.'),
PROVISION_PERM_ERROR);
if ($readable) {
......@@ -146,10 +147,10 @@ function _provision_mysql_import_dump($dump_file, $db_name, $db_user, $db_passwd
function _provision_mysql_suggest_db_name($url, $data) {
provision_set_active_db(_provision_master_db_url());
if ($data['site_id']) {
$id_suggest = 'site_' . $data['site_id'];
$id_suggest = 'site_'. $data['site_id'];
$suggest[] = $id_suggest;
for ($i = 0; $i < 100; $i++) {
$suggest[] = $id_suggest . '_' . $i;
$suggest[] = $id_suggest .'_'. $i;
}
}
else {
......@@ -158,7 +159,7 @@ function _provision_mysql_suggest_db_name($url, $data) {
$url_suggest = substr(0, 14, str_replace(array(".", "-"), '' , ereg_replace("^www\.", "", $url)));
$suggest[] = $url_suggest;
for ($i = 0; $i < 100; $i++) {
$suggest[] = $url_suggest . '_' . $i;
$suggest[] = $url_suggest .'_'. $i;
}
}
......
<?php
// $Id$
/**
* @file
* Mysql provisioning module.
......@@ -57,7 +58,7 @@ function provision_mysql_provision_service() {
/**
* Implementation of provision_configure
*/
function provision_mysql_provision_configure($node = null) {
function provision_mysql_provision_configure($node = NULL) {
if (!is_object($node) && ($nid = variable_get('hosting_own_db_server', 0))) {
$node = node_load($nid);
}
......@@ -136,7 +137,7 @@ function provision_mysql_provision_pre_restore($url, &$data) {
$success = _provision_mysql_new_site_db($data['site_db_name'], $data['site_db_user'], $data['site_db_passwd'], $data['site_db_host']);
if ($success) {
_provision_mysql_import_dump(PROVISION_SITES_PATH . '/' . $url . '.restore/database.sql', $data['site_db_name'], $data['site_db_user'], $data['site_db_passwd'], $data['site_db_host']);
_provision_mysql_import_dump(PROVISION_SITES_PATH .'/'. $url .'.restore/database.sql', $data['site_db_name'], $data['site_db_user'], $data['site_db_passwd'], $data['site_db_host']);
}
else {
provision_set_error(PROVISION_DB_ERROR);
......@@ -149,7 +150,7 @@ function provision_mysql_provision_pre_restore_rollback($url, &$data) {
//Restore the original database credentials of the site.
foreach ($keys as $key) {
$data[$key] = $data['old_' . $key];
$data[$key] = $data['old_'. $key];
}
}
......@@ -165,7 +166,7 @@ function provision_mysql_provision_delete($url, &$data) {
// Rollback doesn't apply here yet. Unless we trigger a restore of the first dump
// made. Which could go on infinitely if something is really long.
function provision_mysql_provision_post_restore($url, &$data) {
provision_path('unlink', 'sites/' . $url . '/database.sql', true,
provision_path('unlink', 'sites/'. $url .'/database.sql', TRUE,
t("Removed dump file @path after restoring from it"),
t("Could not remove dump file @path"), PROVISION_PERM_ERROR);
return _provision_mysql_destroy_site_db($data['old_site_db_name'], $data['old_site_db_user'], $data['old_site_db_passwd'], $data['old_site_db_host']);
......@@ -193,9 +194,4 @@ function provision_mysql_provision_verify() {
provision_log("message", t('Mysql can create new databases.'));
}
provision_set_active_db();
}
}
\ No newline at end of file
<?php
// $Id$
/**
* @file
* Drupal specific functions for the provisioning framework.
......@@ -80,7 +81,7 @@ function _provision_drupal_site_installed($url) {
return isset($data['site_installed']) ? $data['site_installed'] : FALSE;
}
}
return false;
return FALSE;
}
/**
......@@ -104,7 +105,7 @@ function provision_drupal_provision_backup($url, $data) {
* The default template for the config file
*/
function _provision_drupal_default_template() {
return file_get_contents(drupal_get_path('module', 'provision_drupal') . '/provision_drupal_settings.tpl.php');
return file_get_contents(drupal_get_path('module', 'provision_drupal') .'/provision_drupal_settings.tpl.php');
}
/**
......@@ -126,7 +127,7 @@ function _provision_drupal_create_settings_file($url, &$data) {
$fp = fopen("sites/$url/settings.php", "w");
$text = variable_get('provision_drupal_settings_template', _provision_drupal_default_template());
fwrite($fp, "<?php\n" . provision_render_config($text, $data));
fwrite($fp, "<?php\n". provision_render_config($text, $data));
fclose($fp);
# Change the permissions of the file
......@@ -143,7 +144,7 @@ function _provision_drupal_create_settings_file($url, &$data) {
*
* Also maintains permissions on existing directories.
*/
function _provision_drupal_create_directories($url, $profile = null) {
function _provision_drupal_create_directories($url, $profile = NULL) {
$paths = array(
"sites/$url" => 0750,
"sites/$url/files" => 02770,
......@@ -156,7 +157,7 @@ function _provision_drupal_create_directories($url, $profile = null) {
foreach ($paths as $path => $perm) {
if (!is_dir($path)) {
provision_path("mkdir", $path, true,
provision_path("mkdir", $path, TRUE,
t("Created <code>@path</code>"),
t("Could not create <code>@path</code>"),
PROVISION_PERM_ERROR | PROVISION_INSTALL_ERROR );
......@@ -183,7 +184,7 @@ function _provision_drupal_create_directories($url, $profile = null) {
* so that it can cleanly install the database schema. It also handles switching back to the
* main provisioning site.
*/
function _provision_drupal_switch_active_site($url = null) {
function _provision_drupal_switch_active_site($url = NULL) {
static $backups;
if ($url) {
/* Pretend to be the site being installed */
......@@ -191,8 +192,9 @@ function _provision_drupal_switch_active_site($url = null) {
// Fake the necessary HTTP headers that Drupal needs:
$drupal_base_url = parse_url($url);
$_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['PHP_SELF'] = $drupal_base_url['path'] .'/index.php';
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF']; // Coder generates a warning. But this is correct.
$_SERVER['REMOTE_ADDR'] = NULL;
$_SERVER['REQUEST_METHOD'] = NULL;
......@@ -205,10 +207,10 @@ function _provision_drupal_switch_active_site($url = null) {
global $base_url, $base_path, $base_root;
global $cookie_domain, $conf, $profile, $profile, $db_prefix;
# This is just for backup, to be able to restore to the old DRUSH system.
// This is just for backup, to be able to restore to the old DRUSH system.
$backups = compact("active_db", "base_url", "base_path", "db_prefix", "cookie_domain", "conf", "profile");
include_once $_SERVER['DOCUMENT_ROOT'] .'sites/' . $url . '/settings.php';
include_once $_SERVER['DOCUMENT_ROOT'] .'sites/'. $url .'/settings.php';
// Create base URL
$base_root = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
......@@ -231,16 +233,17 @@ function _provision_drupal_switch_active_site($url = null) {
// Fake the necessary HTTP headers that Drupal needs:
$drupal_base_url = parse_url(DRUSH_URI);
$_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['PHP_SELF'] = $drupal_base_url['path'] .'/index.php';
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF']; // Coder generates a warning, but this is correct.
$_SERVER['REMOTE_ADDR'] = NULL;
$_SERVER['REQUEST_METHOD'] = NULL;
global $base_url, $base_path, $base_root;
// Export the following settings.php variables to the global namespace
// Export the following settings.php variables to the global namespace
global $db_prefix, $cookie_domain, $conf, $profile;
# This is just for backup, to be able to restore to the old DRUSH system.
// This is just for backup, to be able to restore to the old DRUSH system.
extract($backups, EXTR_OVERWRITE);
provision_set_active_db();
}
......@@ -251,8 +254,8 @@ function provision_drupal_provision_post_restore($url, $data) {
}
function provision_drupal_provision_restore($url, $data) {
$old = PROVISION_SITES_PATH . "/$url.restore";
$new = PROVISION_SITES_PATH . "/$url";
$old = PROVISION_SITES_PATH ."/$url.restore";
$new = PROVISION_SITES_PATH ."/$url";
provision_path("switch_paths", $old, $new ,
t('Swapping out the @path and @confirm directories was successful.'),
t('Swapping the @path and @confirm directories has failed.'),
......@@ -270,7 +273,7 @@ function provision_drupal_provision_restore_rollback($url, $data) {
/**
* Force drupal to load the modules it expects to find on an uninstalled site
*/
function _provision_drupal_force_load_modules($url = null) {
function _provision_drupal_force_load_modules($url = NULL) {
static $backup_list;
if ($url) {
$backup_list = module_list();
......@@ -314,7 +317,7 @@ function _provision_drupal_install_schema($profile, $language = 'en') {
}
}
return false;
return FALSE;
}
// Verify existence of all required modules.
......@@ -322,7 +325,7 @@ function _provision_drupal_install_schema($profile, $language = 'en') {
if (!$modules) {
provision_set_error(PROVISION_FRAMEWORK_ERROR);
return false;
return FALSE;
}
// Perform actual installation defined in the profile.
......@@ -342,7 +345,7 @@ function _provision_drupal_install_schema($profile, $language = 'en') {
* implementation of provision_verify
*/
function provision_drupal_provision_verify($url, &$data) {
provision_path("writable", "sites", true, t("Drupal sites directory is writable by the provisioning script"),
provision_path("writable", "sites", TRUE, t("Drupal sites directory is writable by the provisioning script"),
t("Drupal sites directory is not writable by the provisioning script"), PROVISION_PERM_ERROR);
$exists = _provision_create_dir(PROVISION_DRUSHRC_PATH, t('Drush configuration path'), 0700);
$data['modules'] = _provision_drupal_get_cvs_versions(module_rebuild_cache());
......@@ -429,7 +432,7 @@ function provision_drupal_provision_import($url, &$data) {
}
}
//Just make sure our ini settings and the like aren't wiped out.
include(conf_path() . "/settings.php");
include(conf_path() ."/settings.php");
}
......
<?php
// $Id$
/**
* @file ProvisionHelp contains the bulk of the provision help system
*/
......@@ -85,35 +86,35 @@ function provision_help($section) {
The Hostmaster profile is capable of driving several provision backends, in a distributed manner, and provides an interface for the functionality of provision.</p>');
$output .= t('<p>It is not required to run the hosting front end to use the Provision framework, but the system does not provide much in the way of a web accessible front end, by design.</p>');
$output .= '<a name=\'requirements\'><h3>' . t('Requirements') . '</h3></a>';
$output .= '<a name=\'requirements\'><h3>'. t('Requirements') .'</h3></a>';
$output .= t('<p>For a more detailed breakdown of steps that need to be taken to configure Provisioning to run with your system, please read the <a href="@url">in depth requirement documentation</a></p>',
array('@url' => url('admin/help/provision/requirements')));
$output .= '<a name=\'commands\'><h3>' . t('Commands') . '</h3></a>';
$output .= '<a name=\'commands\'><h3>'. t('Commands') .'</h3></a>';
$commands = module_invoke_all('drush_command');
$output .= "<dl>";
foreach ($commands as $command => $info) {
if (preg_match('/^provision/', $command)) {
if (sizeof($info['arguments'])) {
$command .= ' ' . implode(' ', (array) key($info['arguments']));
$command .= ' '. implode(' ', (array) key($info['arguments']));
}
if (sizeof($info['optional arguments'])) {
$command .= ' [' . implode('] [', (array) key($info['optional arguments'])) . ']';
$command .= ' ['. implode('] [', (array) key($info['optional arguments'])) .']';
}
$output .= '<dt>' . "<code>drush.php $command</code>" . '</dt>';
$output .= '<dd>' . $info["description"] . '</dd>';
$output .= '<dt>'."<code>drush.php $command</code>".'</dt>';
$output .= '<dd>'. $info["description"] .'</dd>';
}
}
$output .= "</dl>";
$output .= '<a name=\'options\'><h3>' . t('Options') . '</h3></a>';
$output .= '<a name=\'options\'><h3>'. t('Options') .'</h3></a>';
$options = module_invoke_all('value_list');
$output .= "<dl>";
foreach ($options as $option => $description) {
$output .= '<dt>' . "<code>--$option</code>" . '</dt>';
$output .= '<dd>' . $description . '</dd>';
$output .= '<dt>'."<code>--$option</code>".'</dt>';
$output .= '<dd>'. $description .'</dd>';
}
$output .= "</dl>";
......@@ -138,7 +139,7 @@ function provision_help_requirements() {
$name = current($service);
$help = module_invoke($module, 'help', 'admin/help/provision#requirements');
if ($name && $help) {
$output .= "<a href='requirements-$module'></a><h3>" . t($name) . '</h3>';
$output .= "<a href='requirements-$module'></a><h3>". t($name) .'</h3>';
$output .= $help;
}
}
......@@ -155,10 +156,10 @@ function _provision_requirements($req, $section = 'all') {
/*
foreach (array('#heading', '#summary', '#suggestion', '#configuration') as $key) {
if (in_array($section, array('all', $key))) {
$item['#' . $key] = PROVISION_HELP_ENABLED;
$item['#'. $key] = PROVISION_HELP_ENABLED;
}
elseif ($section != 'all') {
$item['#' . $key] = ($section == $key) ? PROVISION_HELP_ENABLED : PROVISION_HELP_DISABLED;
$item['#'. $key] = ($section == $key) ? PROVISION_HELP_ENABLED : PROVISION_HELP_DISABLED;
}
}
*/
......@@ -167,7 +168,7 @@ function _provision_requirements($req, $section = 'all') {
}
function provision_get_requirement($req) {
$func = '_provision_' . $req . '_requirements';
$func = '_provision_'. $req .'_requirements';
if (function_exists($func)) {
$help = $func();
}
......@@ -248,7 +249,7 @@ EOF;
*/
function provision_elements() {
$type['requirement_help'] = array(
'#requirement' => null,
'#requirement' => NULL,
'#status' => PROVISION_STATUS_NONE,
'#heading' => PROVISION_HELP_ENABLED,
'#summary' => PROVISION_HELP_ENABLED,
......@@ -282,19 +283,19 @@ function provision_requirement_process(&$element) {
* Can control individual components of the help, for display in various places.
*/
function theme_requirement_help(&$element) {
drupal_add_js(drupal_get_path('module', 'provision') . '/provision.js');
drupal_add_css(drupal_get_path('module', 'provision') . '/provision.css');
drupal_add_js(drupal_get_path('module', 'provision') .'/provision.js');
drupal_add_css(drupal_get_path('module', 'provision') .'/provision.css');
$req = $element['#requirement'];
$help = $element['#help']; // this is just to make it easier to work with.
//place anchor so user can be directed to right page.
$output .= "<a name='provision-help-$req'></a>";
$output .= '<div class="provision-' . form_clean_id($element["#type"]) .
' ' . _provision_status_class($element['#status']) . '">';
$output .= '<div class="provision-'. form_clean_id($element["#type"]) .
' '. _provision_status_class($element['#status']) .'">';
if ($element['#status'] != PROVISION_STATUS_NONE) {
$output .= "<div class='message'>" . (($element['#message']) ? $element['#message'] : $element['#default_messages'][$element['#status']]) . "</div>";
$output .= "<div class='message'>". (($element['#message']) ? $element['#message'] : $element['#default_messages'][$element['#status']]) ."</div>";
}
$components = array('summary', 'suggestion', 'configuration');
......@@ -306,11 +307,11 @@ function theme_requirement_help(&$element) {
// it is simpler if there's only one way to print the component
$help[$key] = array($help[$key]);
}
if ($element["#$key" . '_prefix'] && ($element["#$key"] & _PROVISION_HELP_CAN_COLLAPSE)) {
$output .= '<a href="javascript:void(0)" class="provision-help-toggle">' . $element["#$key" . '_prefix'] . '</a>';
if ($element["#$key".'_prefix'] && ($element["#$key"] & _PROVISION_HELP_CAN_COLLAPSE)) {
$output .= '<a href="javascript:void(0)" class="provision-help-toggle">'. $element["#$key".'_prefix'] .'</a>';
}
$output .= "<div class='provision-help'><p>" . implode("</p><p>", $help[$key]) . "</p></div>";
$output .= "<div class='provision-help'><p>". implode("</p><p>", $help[$key]) ."</p></div>";
$output .= '</div>';
}
}
......
This diff is collapsed.
<?php
// $Id$
/**
* @file Install file for provision module
*/
/**
* Configure the module weights for the core modules, to ensure that the
* hooks always fire in a predictable pattern.
......@@ -41,7 +46,7 @@ function provision_requirements($phase) {
$docroot = $_SERVER['DOCUMENT_ROOT'];
$requirements['docroot']['title'] = $t("Document root");
$requirements['docroot']['value'] = ($is_in_docroot) ? $t('Correct') :
$t("Installed in the @subdir sub directory of @root", array('@root' => rtrim($docroot,'/'), '@subdir' => trim($base_path, '/')));
$t("Installed in the @subdir sub directory of @root", array('@root' => rtrim($docroot, '/'), '@subdir' => trim($base_path, '/')));
if (!$is_in_docroot) {
$requirements['docroot']['value'] = $t("Drupal has been installed in a subdirectory.
You will need to modify your virtual host configuration to point a ServerName directly at the installation path.");
......
<?php
// $Id$
/**
* @file
* Provisioning Framework
......@@ -59,19 +60,19 @@ function provision_init() {
define('PROVISION_DOMAIN', $_SERVER['HTTP_HOST']);
$path = ($docroot) ? $docroot : $_SERVER['DOCUMENT_ROOT'];
define('PROVISION_DOCROOT_PATH', rtrim($path, '/'));
define('PROVISION_SITES_PATH', rtrim($path, '/') . '/sites');
define('PROVISION_SITES_PATH', rtrim($path, '/') .'/sites');
define('PROVISION_DRUSH_PATH', drupal_get_path('module', 'drush') . '/drush.php');
define('PROVISION_DRUSH_PATH', drupal_get_path('module', 'drush') .'/drush.php');
$parts = explode("/", rtrim($path, '/'));
array_pop($parts);
define('PROVISION_PARENT_PATH', rtrim(implode("/" , $parts), '/'));
define('PROVISION_BACKUP_PATH',
variable_get('provision_backup_path', PROVISION_PARENT_PATH . '/backups'));
variable_get('provision_backup_path', PROVISION_PARENT_PATH .'/backups'));
define('PROVISION_CONFIG_PATH',
variable_get('provision_config_path', PROVISION_PARENT_PATH . '/config')) ;
define('PROVISION_VHOST_PATH', PROVISION_CONFIG_PATH . '/vhost.d');
define('PROVISION_DRUSHRC_PATH', PROVISION_CONFIG_PATH . '/drushrc.d');
variable_get('provision_config_path', PROVISION_PARENT_PATH .'/config')) ;
define('PROVISION_VHOST_PATH', PROVISION_CONFIG_PATH .'/vhost.d');
define('PROVISION_DRUSHRC_PATH', PROVISION_CONFIG_PATH .'/drushrc.d');
define('PROVISION_SCRIPT_USER', variable_get('provision_script_user', get_current_user()));
......@@ -87,7 +88,7 @@ function provision_init() {
$command = '/usr/sbin/apachectl'; # a proper default for most of the world
foreach (array('/usr/local/sbin/apachectl', # freebsd
'/usr/sbin/apache2ctl', # debian + apache2
$command) as $test) {
$command) as $test) {
if (is_executable($test)) {
$command = $test;
}
......@@ -97,10 +98,10 @@ function provision_init() {
global $base_url;
define('PROVISION_BASE_URL', $base_url);
define('PROVISION_WEB_DISABLE_URL',
variable_get('provision_web_disable_url', $base_url . '/provision/disabled'));
variable_get('provision_web_disable_url', $base_url .'/provision/disabled'));
define('PROVISION_WEB_MAINTENENCE_URL',
variable_get('provision_web_maintenance_url', $base_url . '/provision/maintenance'));
variable_get('provision_web_maintenance_url', $base_url .'/provision/maintenance'));
}
......@@ -127,7 +128,7 @@ function provision_perm() {
/**
* Implementation of hook_menu().
*/
function provision_menu($may_cache = true) {
function provision_menu($may_cache = TRUE) {
if ($may_cache) {
$items[] = array(
'path' => 'admin/settings/provision',
......@@ -144,7 +145,8 @@ function provision_menu($may_cache = true) {
'callback' => 'provision_help_requirements',
'type' => MENU_CALLBACK
);
} else {
}
else {
$items[] = array(
'path' => 'provision/disabled',
'title' => t('Site disabled'),
......@@ -196,7 +198,7 @@ function provision_configure() {
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#access' => user_access("administer $service provisioning"),
'#tree' => true
'#tree' => TRUE
);
$form[$service] = array_merge($form[$service], module_invoke($module, "provision_configure"));
}
......@@ -211,7 +213,7 @@ function provision_configure() {
function provision_configure_submit($form_id, $values) {
foreach ($values['services'] as $service) {
foreach ($values[$service] as $key => $value) {
variable_set('provision_' . $key, $value);
variable_set('provision_'. $key, $value);
}
}
}
......@@ -324,7 +326,7 @@ function provision_install_cmd($url) {
provision_set_error(PROVISION_FRAMEWORK_ERROR);
provision_output($url, $data);
}
$ops = array('pre_install', 'install', 'post_install'); # these are the provision hooks that will get triggered.
$ops = array('pre_install', 'install', 'post_install'); //these are the provision hooks that will get triggered.
if (_provision_drupal_site_installed($url)) {
provision_set_error(PROVISION_SITE_INSTALLED);
......@@ -414,7 +416,7 @@ function _provision_install($url, &$data) {
function _provision_post_install($url, &$data) {
$rolled_back = provision_invoke("post_install", $url, $data);
if (!$rolled_back) {
$data['site_installed'] = true;
$data['site_installed'] = TRUE;
}
return $rolled_back;
}
......@@ -475,7 +477,7 @@ function _provision_backup($url) {
/**
* Generate a backup tarbal for a site.
*/
function _provision_backup_site($url, &$data, $file = null) {
function _provision_backup_site($url, &$data, $file = NULL) {
// This is the actual drupal provisioning requirements.
if (!is_dir(PROVISION_BACKUP_PATH)) {
provision_log("Backup directory does not exist.");
......@@ -488,18 +490,18 @@ function _provision_backup_site($url, &$data, $file = null) {
provision_set_error(PROVISION_PERM_ERROR);
provision_output($url, $data);
}
$suggested = PROVISION_BACKUP_PATH . "/$url-" . date("Y-m-d",mktime()) . ".tar";
$suggested = PROVISION_BACKUP_PATH ."/$url-". date("Y-m-d", mktime()) .".tar";
// Use format of mysite.com-2008-01-02, if already existing, add number.
while (is_file($suggested . '.gz')) {
while (is_file($suggested .'.gz')) {
$count++;
$suggested = PROVISION_BACKUP_PATH . "/$url-" . date("Y-m-d", mktime()) . "_$count.tar";
$suggested = PROVISION_BACKUP_PATH ."/$url-". date("Y-m-d", mktime()) ."_$count.tar";
}
$data['backup_file'] = (!empty($file)) ? ereg_replace('.gz$', '', $file) : $suggested;
$rolled_back = provision_invoke("backup", $url, $data);
provision_shell_exec("gzip %s", $data['backup_file']);
$data['backup_file'] = $data['backup_file'] . '.gz';
$data['backup_file'] = $data['backup_file'] .'.gz';
}
/**
......@@ -513,7 +515,7 @@ function _provision_backup_site($url, &$data, $file = null) {
* Output of provision_output() function.
* Will exit with a PROVISION_SITE_NOT_FOUND error if the site does not exist.
*/
function _provision_import($url = null) {
function _provision_import($url = NULL) {
$rolled_back = provision_invoke("import", $url, $data);
provision_output($url, $data);
}
......@@ -569,7 +571,7 @@ function _provision_restore($url, $restore_file) {
provision_set_error(PROVISION_SITE_NOT_FOUND);
}
$exists &= provision_path("exists", $restore_file, true,
$exists &= provision_path("exists", $restore_file, TRUE,
t("Restoring site from @path"),
t("Could not find backup file @path"),
PROVISION_FRAMEWORK_ERROR);
......@@ -581,7 +583,7 @@ function _provision_restore($url, $restore_file) {
$phases = array("pre_restore", "restore", "post_restore");
$completed = array();
$rolled_back = false; // initializes to false.
$rolled_back = FALSE; // initializes to FALSE.
foreach ($phases as $phase) {
$rolled_back = provision_invoke($phase, $url, $data, $rolled_back);
......@@ -609,20 +611,20 @@ function _provision_restore($url, $restore_file) {
}
function provision_provision_pre_restore($url, &$data) {
_provision_backup_site($url, $data); # Backup site for posterity, before rolling back.
_provision_backup_site($url, $data); // Backup site for posterity, before rolling back.
provision_path("extract", $data['restore_file'], PROVISION_SITES_PATH . "/$url.restore",
provision_path("extract", $data['restore_file'], PROVISION_SITES_PATH ."/$url.restore",
t('Successfully extracted the contents of @path to @confirm'),
t('Failed to extract the contents of @path to @confirm'),
PROVISION_PERM_ERROR, PROVISION_FRAMEWORK_ERROR);
}
function provision_provision_pre_restore_rollback($url, $data) {
_provision_recursive_delete(PROVISION_SITES_PATH . "/$url.restore");
_provision_recursive_delete(PROVISION_SITES_PATH ."/$url.restore");
}
function provision_provision_post_restore($url, $data) {
_provision_recursive_delete(PROVISION_SITES_PATH . "/$url.restore");
_provision_recursive_delete(PROVISION_SITES_PATH ."/$url.restore");
}
function _provision_disable($url) {
......
<?php
// $Id$
/**
* @defgroup pathhandling Managing paths, permissions and file ownership
*
......@@ -41,7 +41,7 @@
*
* @param confirm
* Confirm that the final value of the file operation matches this value.
* This value defaults to true, which is sufficient for most file operations.
* This value defaults to TRUE, which is sufficient for most file operations.
*
* Certain tasks such as chmod, chown and chgp will attempt to change the
* properties of $path to match the value in $confirm, and then test that
......@@ -67,7 +67,7 @@
* @return
* Returns TRUE if the test against $confirm passed, otherwise returns FALSE.
*/
function provision_path($op, $path, $confirm = true, $succeed_message = null, $fail_message = null, $error_codes = null) {
function provision_path($op, $path, $confirm = TRUE, $succeed_message = NULL, $fail_message = NULL, $error_codes = NULL) {
# The code style is a bit weird here, but it's a bit easier to read this way.
$func = "provision_path_" . $op;
if (function_exists($func)) {
......@@ -134,7 +134,7 @@ function provision_path_group($path) {
}
function provision_path_mkdir($path) {
return mkdir($path, 0770, true);
return mkdir($path, 0770, TRUE);
}
function provision_path_rmdir($path) {
......@@ -199,7 +199,7 @@ function provision_path_chgrp($path, &$group, &$reason) {
function provision_path_switch_paths($path1, &$path2, &$reason) {
//TODO : Add error reasons.
$temp = $path1 . '.tmp';
$temp = $path1 .'.tmp';
if (rename($path1, $temp)) {
if (rename($path2, $path1)) {
if (rename($temp, $path2)) {
......@@ -255,13 +255,13 @@ function provision_path_extract($path, &$target, &$reason) {
* Small helper function for creation of configuration directories.
*/
function _provision_create_dir($path, $name, $perms) {
$exists = provision_path("exists",$path, true ,
$exists = provision_path("exists",$path, TRUE ,
$name . ' ' . t("path exists."),
$name . ' ' . t("path does not exist.")
);
if (!$exists) {
$exists = provision_path("mkdir", $path, true,
$exists = provision_path("mkdir", $path, TRUE,
$name . ' ' . t("path has been created."),
$name . ' ' . t("path could not be created."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
......@@ -278,7 +278,7 @@ function _provision_create_dir($path, $name, $perms) {
$name . ' ' . t("permissions of path could not be changed to @confirm."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR );
$writable = provision_path("writable", $path, true,
$writable = provision_path("writable", $path, TRUE,
$name . ' ' . t("path is writable."),
$name . ' ' . t("path is not writable."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
......
<?php
// $Id$
/**
* @file
* The provisioning framework error code definitions.
......@@ -31,7 +32,7 @@ define('PROVISION_SITE_INSTALLED', 64);
/** Database could not be accessed, or configured */
define('PROVISION_DB_ERROR', 128);
# List of provisioning errors. This is a global so that other modules can reference it.
//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"),
......
<?php
// $Id$
function provision_stats_drush_command() {
$items['provision stats'] = array(
......@@ -17,22 +18,22 @@ function _provision_stats($url) {
$data = provision_get_site_data($url);
$rolled_back = provision_invoke("stats", $url, $data);
#needs to be done on active database
//needs to be done on active database
$modules = module_implements('provision_stats');
drupal_get_messages(); # clear the messages being saved so far.
drupal_get_messages(); //clear the messages being saved so far.
# Change headers and db info, also backs up to restore later
// Change headers and db info, also backs up to restore later
_provision_drupal_switch_active_site($url);
#TODO: add some required modules here, possibly update_status if not enabled.
#Load the modules from the hosted site
//TODO: add some required modules here, possibly update_status if not enabled.
//Load the modules from the hosted site
module_list(TRUE);
$stats['node_count'] = db_result(db_query("select max(nid) from {node}"));
$stats['user_count'] = db_result(db_query("select max(uid) from {users}"));
foreach ($modules as $name) {
$func = $name . "_provision_stats";