In modules/hosting/task.hosting.inc
, function drush_hosting_task() hard codes which Task Types must call provision-save
before running the primary task. Only task types "install", "verify", and "import" do this. I have a task in devshop_projects.module that creates a new "context" type in Aegir, but it is blocked by this hard coding.
Current Code From: drush_hosting_task(), modules/hosting/task.hosting.inc:
// On install/verify, save the named context
if ($task->task_type === 'install' || $task->task_type === 'verify' || $task->task_type === 'import') {
//...
$output = drush_invoke_process('@none', 'provision-save', array('@' . $task->ref->hosting_name), $task->context_options, array('method' => $mode));
}
This patch changes the above to:
// On install/verify, save the named context
if (!empty($task->task_info['provision_save'])) {
//...
$output = drush_invoke_process('@none', 'provision-save', array('@' . $task->ref->hosting_name), $task->context_options, array('method' => $mode));
}
The following patch changes the logic behind determining what tasks to call provision-save
for. Instead of a hard coded fixed list, hook_hosting_tasks() is used to set a $task->provision_save
boolean whether or not the task requires this.
Patched version of 'install' task from hosting_site_hosting_tasks()
:
$tasks['site']['install'] = array(
'title' => t('Install'),
'description' => t('Install a site'),
'hidden' => TRUE,
'provision_save' => TRUE,
);
I'd love some feedback to see if this is the right direction, then I will patch against 1.x and 2.x
Comment | File | Size | Author |
---|---|---|---|
#6 | 1760962-hosting-task-provision-save-1.9--2.patch | 6.39 KB | Jon Pugh |
#1 | 1760962-hosting-task-provision-save-1.9.patch | 3.51 KB | Jon Pugh |
Comments
Comment #0.0
Jon Pughadding information
Comment #1
Jon PughPatch Attached
ROLLED AGAINST 1.9. I need this for DevShop... once I can confirm from an aegir core dev this is the right direction we will target 2.x and 1.x
Comment #2
Jon PughComment #2.0
Jon Pughmarkup cleaning
Comment #3
Jon PughThis patch applied cleanly to the 2.x branch as well!
Would love some review...
Comment #4
Steven Jones CreditAttribution: Steven Jones commentedThanks for the hard work and the patch, we really should get this in 2.x, and it could possibly get into 1.x roo really, as the change is internal.
The patch looks great, a few little whitespace bits in there, but nothing too major.
This needs some documentation adding to the
hook_hosting_tasks()
function, so that we know we can use this flag!Comment #5
Jon PughNo problem! I'm working on this now... Thanks so much for the review!
Comment #6
Jon PughNew Patch attached!
- Whitespace Fixed
- Docs for hook_hosting_TASK_OBJECT_context_options() updated.
- Docs for hook_hosting_tasks() updated.
- Added @see links to important hooks. in drush_hosting_task_validate()
- Added a
str_replace('-', '_', $task->ref->type)
for the invocation ofhook_hosting_TASK_OBJECT_context_options
the that I found. I know this is for context object types, but my feeling is, if you are looking for a function, it should always be converted to underscores.- Cleaned up comments in drush_hosting_task and I added empty lines above some comments for readability. This is a very tricky piece of code and I thought it might help.
Let me know if I went to far with these additional changes!
Thanks for the review!
Comment #7
Steven Jones CreditAttribution: Steven Jones commentedThanks so much for this patch. Seems to be working really well, so I've pushed it plus some minor tweaks to 6.x-2.x.
We don't need to convert '-' to '_' in the task reference type, because those types are node types, which aren't allowed to contain '-' anyway!
We should get these commits backported to 1.x, which should be easy.
Comment #8
Steven Jones CreditAttribution: Steven Jones commentedAnd now pushed this into 6.x-1.x. Thanks so much for the work!
Comment #9.0
(not verified) CreditAttribution: commentedadding "after" code