Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Requires #1861896: Make $type argument of function hosting_available_tasks() optional..
The current hosting_task.module code prevents any other node type from being able to use Tasks. The module hard codes site, platform, server into the logic of hook_menu:
/**
* Implementation of hook_menu().
*/
function hosting_task_menu() {
$items = array();
foreach (array('site', 'platform', 'server') as $type) {
if (!($tasks = hosting_available_tasks($type))) {
// this is to workaround problems in the upgrade path where the
// hook returns nothing (e.g. for server)
continue;
}
foreach ($tasks as $task => $info) {
if (empty($info['hidden'])) {
$path = sprintf("node/%%hosting_%s_node/%s_%s", $type, $type, $task);
$items[$path] = array(
'title' => $info['title'],
'description' => $info['description'],
'page callback' => 'drupal_get_form',
'page arguments' => array('hosting_task_confirm_form', 1, $task),
'access callback' => 'hosting_task_menu_access_csrf',
'access arguments' => array(1, $task),
'type' => MENU_CALLBACK,
);
$items[$path] = array_merge($items[$path], $info);
}
}
}
}
The following patch uses hook_hosting_tasks() to determine which Node Types and which tasks need Ajax. This allows other objects to use the Tasks functionality.
Comment | File | Size | Author |
---|---|---|---|
#8 | hosting-remove_hardcoded_types-1861898-8.patch | 845 bytes | ergonlogic |
#1 | 1861898-hosting-types-in-menu.patch | 85.67 KB | Jon Pugh |
Comments
Comment #1
Jon PughThis patch includes the patch at #1861896: Make $type argument of function hosting_available_tasks() optional.
Comment #2
Steven Jones CreditAttribution: Steven Jones commentedIs this the only place that this is enforced, or are there lots of other places where Aegir asserts that you'll only run task against a site, platform or server?
Comment #3
anarcat CreditAttribution: anarcat commentedI don't know, but it seems like a good start, is this RTBC?
Comment #4
Steven Jones CreditAttribution: Steven Jones commentedThe patch in #1 seems to have a lot of unrelated code changes, was it diffed against the 6.x-2.x branch?
Comment #5
anarcat CreditAttribution: anarcat commentedJon, we need a reroll here. It would also be useful if you published your code as sandboxes instead of patches, which would get rid of errors like this.
Comment #6
ergonlogicThis kind of hardcoded limitation seems like more of a bug than a feature request.
Comment #7
anarcat CreditAttribution: anarcat commentedi'd like to see this in 2.x.
Comment #8
ergonlogicThe relevant bit from #1 appears to be something like the attached patch. From my limited testing, it works just fine.
Comment #9
anarcat CreditAttribution: anarcat commentedthis looks good, but i haven't tested it.
Comment #10
ergonlogicI've tested this quite a bit, and it appears to work well. So I've committed it in 15b6240.