Commit a700e6b3 authored by helmo's avatar helmo

Code cleanup

parent 69929390
<?php <?php
/** /**
* @file * @file
* Provision hooks for the provision backup-delete command. * Provision hooks for the provision backup-delete command.
*/ */
/** /**
* Provision backup-delete command * Provision backup-delete command.
* *
* These are the hooks that will be executed by the drush_invoke function * These are the hooks that will be executed by the drush_invoke function
* when deleting a backup file from the backend. * when deleting a backup file from the backend.
*/ */
function drush_provision_drupal_provision_backup_delete($backup = NULL) {
function drush_provision_drupal_provision_backup_delete($backup = null) { if ($backup) {
if($backup) {
$backups = explode(',', $backup); $backups = explode(',', $backup);
foreach ($backups as $filename) { foreach ($backups as $filename) {
$success = provision_file()->unlink($filename) $success = provision_file()->unlink($filename)
->succeed('Removed backup file @path') ->succeed('Removed backup file @path')
->fail('Could not remove backup file @path'); ->fail('Could not remove backup file @path');
} }
} }
else { else {
...@@ -26,7 +25,7 @@ function drush_provision_drupal_provision_backup_delete($backup = null) { ...@@ -26,7 +25,7 @@ function drush_provision_drupal_provision_backup_delete($backup = null) {
} }
/** /**
* Implementation of drush_hook_post_provision_backup_delete() * Implements drush_hook_post_COMMAND().
* *
* If we have a client name and backups provided, cleanup the backup * If we have a client name and backups provided, cleanup the backup
* symlinks created for that client. * symlinks created for that client.
...@@ -34,7 +33,7 @@ function drush_provision_drupal_provision_backup_delete($backup = null) { ...@@ -34,7 +33,7 @@ function drush_provision_drupal_provision_backup_delete($backup = null) {
* Will not provoke a rollback if there is no symlink, for backward * Will not provoke a rollback if there is no symlink, for backward
* compatibility. * compatibility.
*/ */
function drush_provision_drupal_post_provision_backup_delete($backup = null) { function drush_provision_drupal_post_provision_backup_delete($backup = NULL) {
if ($backup && d()->client_name) { if ($backup && d()->client_name) {
$backup_dir = d()->server->clients_path . '/' . d()->client_name . '/backups'; $backup_dir = d()->server->clients_path . '/' . d()->client_name . '/backups';
$backups = explode(',', $backup); $backups = explode(',', $backup);
......
<?php <?php
/** /**
* @file
* Deploy command implementation * Deploy command implementation
* *
* This command when called will * This command when called will
...@@ -16,11 +17,11 @@ ...@@ -16,11 +17,11 @@
*/ */
/** /**
* Make sure we have a valid site being deployd, and that the file being deployd from exists * Make sure we have a valid site being deployd, and that the file being deployd from exists.
* *
* Implementation of drush_hook_COMMAND_validate(). * Implementation of drush_hook_COMMAND_validate().
*/ */
function drush_provision_drupal_provision_deploy_validate($backup_file = null) { function drush_provision_drupal_provision_deploy_validate($backup_file = NULL) {
$exists = provision_file()->exists($backup_file) $exists = provision_file()->exists($backup_file)
->succeed('Deploying site from @path') ->succeed('Deploying site from @path')
->fail('Could not find backup file @path', 'PROVISION_BACKUP_NOT_FOUND') ->fail('Could not find backup file @path', 'PROVISION_BACKUP_NOT_FOUND')
...@@ -45,16 +46,16 @@ function drush_provision_drupal_provision_deploy_validate($backup_file = null) { ...@@ -45,16 +46,16 @@ function drush_provision_drupal_provision_deploy_validate($backup_file = null) {
} }
/** /**
* Make a backup before making any changes, and add extract the file we are restoring from * Make a backup before making any changes, and add extract the file we are restoring from.
* *
* Implementation of drush_hook_pre_COMMAND(). * Implementats drush_hook_pre_COMMAND().
*/ */
function drush_provision_drupal_pre_provision_deploy($backup_file) { function drush_provision_drupal_pre_provision_deploy($backup_file) {
// the url is likely to have changed in the deployment
$extracted = provision_file()->extract($backup_file, drush_get_option('extract_path')) $extracted = provision_file()->extract($backup_file, drush_get_option('extract_path'))
->succeed('Successfully extracted the contents of @path') ->succeed('Successfully extracted the contents of @path')
->fail('Failed to extract the contents of @path to @target', 'PROVISION_BACKUP_EXTRACTION_FAILED') ->fail('Failed to extract the contents of @path to @target', 'PROVISION_BACKUP_EXTRACTION_FAILED')
->status(); ->status();
if ($extracted) { if ($extracted) {
// Make sure the files in the files directory are accessible by the web server. // Make sure the files in the files directory are accessible by the web server.
provision_file()->chgrp(drush_get_option('extract_path') . '/files', d('@server_master')->web_group, TRUE) provision_file()->chgrp(drush_get_option('extract_path') . '/files', d('@server_master')->web_group, TRUE)
...@@ -67,7 +68,6 @@ function drush_provision_drupal_pre_provision_deploy($backup_file) { ...@@ -67,7 +68,6 @@ function drush_provision_drupal_pre_provision_deploy($backup_file) {
->succeed('Changed group ownership of temp files in <code>@path</code> to @gid') ->succeed('Changed group ownership of temp files in <code>@path</code> to @gid')
->fail('Could not change group ownership of temp files in <code>@path</code> to @gid'); ->fail('Could not change group ownership of temp files in <code>@path</code> to @gid');
if (drush_get_option('deploy_replace_site', FALSE)) { if (drush_get_option('deploy_replace_site', FALSE)) {
$old = d()->site_path . '.restore'; $old = d()->site_path . '.restore';
$new = d()->site_path; $new = d()->site_path;
...@@ -80,7 +80,7 @@ function drush_provision_drupal_pre_provision_deploy($backup_file) { ...@@ -80,7 +80,7 @@ function drush_provision_drupal_pre_provision_deploy($backup_file) {
drush_set_option('site_dirs_swapped', TRUE); drush_set_option('site_dirs_swapped', TRUE);
} }
else { else {
return false; return FALSE;
} }
} }
...@@ -115,8 +115,8 @@ function drush_provision_drupal_pre_provision_deploy($backup_file) { ...@@ -115,8 +115,8 @@ function drush_provision_drupal_pre_provision_deploy($backup_file) {
} }
else { else {
if (($merged_modules[$name]['schema_version'] > 0) && ($module['schema_version'] > $merged_modules[$name]['schema_version'])) { if (($merged_modules[$name]['schema_version'] > 0) && ($module['schema_version'] > $merged_modules[$name]['schema_version'])) {
drush_set_error('PROVISION_SCHEMA_UPGRADE_FAILURE', drush_set_error('PROVISION_SCHEMA_UPGRADE_FAILURE',
dt("The version of the !name module found on this platform (!versionB) has a lower Schema version than the one the site has installed (!versionA)", dt("The version of the !name module found on this platform (!versionB) has a lower Schema version than the one the site has installed (!versionA)",
array('!name' => $name, '!versionA' => $module['schema_version'], '!versionB' => $merged_modules[$name]['schema_version']))); array('!name' => $name, '!versionA' => $module['schema_version'], '!versionB' => $merged_modules[$name]['schema_version'])));
} }
else { else {
...@@ -131,7 +131,7 @@ function drush_provision_drupal_pre_provision_deploy($backup_file) { ...@@ -131,7 +131,7 @@ function drush_provision_drupal_pre_provision_deploy($backup_file) {
} }
/** /**
* Remove the extracted site directory * Remove the extracted site directory.
* *
* Implementation of drush_hook_pre_COMMAND_rollback(). * Implementation of drush_hook_pre_COMMAND_rollback().
*/ */
...@@ -139,26 +139,26 @@ function drush_provision_drupal_pre_provision_deploy_rollback() { ...@@ -139,26 +139,26 @@ function drush_provision_drupal_pre_provision_deploy_rollback() {
if (drush_get_option('deploy_replace_site', FALSE)) { if (drush_get_option('deploy_replace_site', FALSE)) {
if (drush_get_option('site_dirs_swapped', FALSE)) { if (drush_get_option('site_dirs_swapped', FALSE)) {
// swap the site directories back if necessary. // Swap the site directories back if necessary.
$old = d()->site_path . '.restore'; $old = d()->site_path . '.restore';
$new = d()->site_path; $new = d()->site_path;
provision_file()->switch_paths($old, $new) provision_file()->switch_paths($old, $new)
->succeed('Swapping out the @path1 and @path2 directories was successful.') ->succeed('Swapping out the @path1 and @path2 directories was successful.')
->fail('Swapping the @path1 and @path2 directories has failed.', 'DRUSH_PERM_ERROR'); ->fail('Swapping the @path1 and @path2 directories has failed.', 'DRUSH_PERM_ERROR');
_provision_drupal_create_settings_file(); _provision_drupal_create_settings_file();
provision_save_site_data(); provision_save_site_data();
} }
} }
if (provision_file()->exists(drush_get_option('extract_path'))->status()) { if (provision_file()->exists(drush_get_option('extract_path'))->status()) {
_provision_recursive_delete(drush_get_option('extract_path')); _provision_recursive_delete(drush_get_option('extract_path'));
} }
} }
/** /**
* Implementation of drush_hook_COMMAND(). * Implements drush_hook_COMMAND().
*/ */
function drush_provision_drupal_provision_deploy() { function drush_provision_drupal_provision_deploy() {
_provision_drupal_maintain_aliases(); _provision_drupal_maintain_aliases();
...@@ -166,10 +166,10 @@ function drush_provision_drupal_provision_deploy() { ...@@ -166,10 +166,10 @@ function drush_provision_drupal_provision_deploy() {
} }
/** /**
* Implementation of drush_hook_post_COMMAND(). * Implements drush_hook_post_COMMAND().
*/ */
function drush_provision_drupal_post_provision_deploy() { function drush_provision_drupal_post_provision_deploy() {
// call the drush updatedb command. // Call the drush updatedb command.
provision_backend_invoke(d()->name, 'updatedb'); provision_backend_invoke(d()->name, 'updatedb');
// We should be able to fully load Drupal now. // We should be able to fully load Drupal now.
if (drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL)) { if (drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
...@@ -177,17 +177,17 @@ function drush_provision_drupal_post_provision_deploy() { ...@@ -177,17 +177,17 @@ function drush_provision_drupal_post_provision_deploy() {
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site'); drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
_provision_drupal_rebuild_caches(); _provision_drupal_rebuild_caches();
// rebuild the node access tables only if necessary // Rebuild the node access tables only if necessary.
if (!function_exists("node_access_needs_rebuild") || node_access_needs_rebuild()) { if (!function_exists("node_access_needs_rebuild") || node_access_needs_rebuild()) {
node_access_rebuild(); node_access_rebuild();
drush_log(dt('Rebuilt node access table')); drush_log(dt('Rebuilt node access table'));
} }
} else { }
else {
drush_log("could not bootstrap drupal after updatedb"); drush_log("could not bootstrap drupal after updatedb");
} }
// Remove the restore directory.
// remove the restore directory
if (!drush_get_error() && drush_get_option('deploy_replace_site', FALSE)) { if (!drush_get_error() && drush_get_option('deploy_replace_site', FALSE)) {
_provision_recursive_delete(drush_get_option('extract_path')); _provision_recursive_delete(drush_get_option('extract_path'));
} }
......
<?php <?php
/** /**
* Provision verify command * @file
* Code related to verify tasks.
*/
/**
* Provision verify command.
* *
* Disable an enabled and installed site * Disable an enabled and installed site
*/ */
...@@ -20,7 +25,7 @@ function drush_provision_drupal_provision_verify_validate() { ...@@ -20,7 +25,7 @@ function drush_provision_drupal_provision_verify_validate() {
/** /**
* implementation of provision_verify * Implements drush_hook_pre_COMMAND().
*/ */
function drush_provision_drupal_pre_provision_verify() { function drush_provision_drupal_pre_provision_verify() {
if (d()->type === 'server') { if (d()->type === 'server') {
...@@ -34,7 +39,7 @@ function drush_provision_drupal_pre_provision_verify() { ...@@ -34,7 +39,7 @@ function drush_provision_drupal_pre_provision_verify() {
provision_file()->create_dir(d()->include_path, dt('Provision PHP configuration'), 0711); provision_file()->create_dir(d()->include_path, dt('Provision PHP configuration'), 0711);
if (!provision_file()->exists(d()->include_path . '/global.inc')->succeed('Global configuration file exists')->status()) { if (!provision_file()->exists(d()->include_path . '/global.inc')->succeed('Global configuration file exists')->status()) {
// Create an empty global.inc so the include doesn't fail with // Create an empty global.inc so the include doesn't fail with
// open_basedir restrictions // open_basedir restrictions.
$config = new Provision_Config_Global_Settings(d()->name); $config = new Provision_Config_Global_Settings(d()->name);
$config->write(); $config->write();
} }
...@@ -46,12 +51,12 @@ function drush_provision_drupal_pre_provision_verify() { ...@@ -46,12 +51,12 @@ function drush_provision_drupal_pre_provision_verify() {
} }
} }
elseif (d()->type === 'platform') { elseif (d()->type === 'platform') {
// create a platform from a makefile, if it doesnt already exist and the makefile does. // Create a platform from a makefile, if it doesnt already exist and the makefile does.
if (!provision_file()->exists(d()->root)->status() && !empty(d()->makefile)) { if (!provision_file()->exists(d()->root)->status() && !empty(d()->makefile)) {
drush_log(dt("Platform path does not exist, fetching from drush makefile")); drush_log(dt("Platform path does not exist, fetching from drush makefile"));
$arguments = array(); $arguments = array();
$options = array(); $options = array();
// propagate working-copy args downward // Propagate working-copy args downward.
if (drush_get_option('working-copy') || !empty(d()->make_working_copy)) { if (drush_get_option('working-copy') || !empty(d()->make_working_copy)) {
$options[] = '--working-copy'; $options[] = '--working-copy';
} }
...@@ -71,7 +76,7 @@ function drush_provision_drupal_pre_provision_verify() { ...@@ -71,7 +76,7 @@ function drush_provision_drupal_pre_provision_verify() {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_ROOT); drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_ROOT);
// If we couldn't bootstrap, there's no sense in continuing past this point. // If we couldn't bootstrap, there's no sense in continuing past this point.
if(drush_get_error()) { if (drush_get_error()) {
return drush_set_error("DRUSH_INVALID_DRUPAL_ROOT", return drush_set_error("DRUSH_INVALID_DRUPAL_ROOT",
"Drush could not bootstrap this platform. Please check the platform directory exists and is readable."); "Drush could not bootstrap this platform. Please check the platform directory exists and is readable.");
} }
...@@ -113,7 +118,7 @@ function drush_provision_drupal_pre_provision_verify() { ...@@ -113,7 +118,7 @@ function drush_provision_drupal_pre_provision_verify() {
} }
/** /**
* Implementation of hook_provision_post_verify * Implements drush_hook_provision_post_COMMAND().
*/ */
function drush_provision_drupal_post_provision_verify() { function drush_provision_drupal_post_provision_verify() {
if (d()->type === 'site') { if (d()->type === 'site') {
...@@ -124,4 +129,3 @@ function drush_provision_drupal_post_provision_verify() { ...@@ -124,4 +129,3 @@ function drush_provision_drupal_post_provision_verify() {
drush_include_engine('drupal', 'cron_key'); drush_include_engine('drupal', 'cron_key');
} }
} }
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