Since hosting_get_profiles() returns only the profiles that have status=1 and the hostmaster/hostslave profiles have kludges in verify to be "disabled" (status = 0), we cannot even *edit* the hostmaster site (which would be useful to change ports, add SSL or things like that).
// Kludge to hide the hostmaster and hostslave profiles
if (($type == 'profile')
&& in_array($short_name, array('hostslave', 'hostmaster'))) {
$package->status = 0;
}
else {
$package->status = 1;
}
In turn, hosting_get_profiles() is this:
function hosting_get_profiles($platform = NULL) {
$profiles = array();
if (!is_null($platform)) {
$instances = hosting_package_instances_load(array(
'rid' => $platform, 'package_type' => 'profile',
'n.status' => 1));
Basically, I think that hosting_get_profiles() *should* return the hostmaster profiles, but other access control mechanisms should disable access to it. It *is* a profile, and a valid one, for *one* site (or many, once we start self-hosting). But it's understandable that it needs to be controled.
So i'm not proposing to ditch the status right away. I would suggest however to replace it with proper access control, a bit like the work mig5 is doing on platforms.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | profile.png | 30.89 KB | mig5 |
| #6 | 599758.patch | 3.04 KB | mig5 |
| #2 | 599758.patch | 2.19 KB | mig5 |
Comments
Comment #1
Anonymous (not verified) commentedI have a fix for this.
Please clone or add my git repo as a remote
git://git.mig5.net/drupal/profiles/hostmaster/
The branch is 599758_edit_main_aegir_site
Or just cherry pick this (I need to clean up my dirty git):
http://git.mig5.net/?p=profiles/hostmaster/.git;a=commitdiff;h=abbb298a8...
Comment #2
Anonymous (not verified) commentedReverted hosting_get_profiles to still check if node's status = 1, even though it doesn't matter anymore because the logic is done in hosting_site_form(). However, we may want to check on the status of a profile package down the track (so it's just in case).
So I now add a hook_update to set status = 1 for any hostmaster or hostslave package in this commit and also added a check for whether a profile is hostslave and not just hostmaster (for ancient systems) in this commit
Overall patch for the lazy attached
Comment #3
acworks against DRUPAL-6--0-4-ALPHA3
Comment #4
Anonymous (not verified) commentedThanks! Fixed in git.
Comment #5
Anonymous (not verified) commentedSo as usual, my attempt here caused a nice new regressive bug that prevented sites being created on platforms that only had one profile.
Somehow this caused platforms with, say, only the 'default' profile, to get nuked somehow?? even though I could var_dump it and see it.. on submission of the site form, hook_validate threw 'Please fill in a valid profile'. Provisioning a site on the main aegir platform didn't, i.e it nuked the hostmaster profile but left 'default' hidden in the form.
Tried to find a fix but I don't understand why it isn't working.
So, reverted yet another regression on my part. Sorry everyone.
Comment #6
Anonymous (not verified) commentedIf I var_dump the form when there's only one profile on that platform, it shows the default profile..
If I submit the form and var_dump in hook_validate, $node->profile is null !! and hence the exception
So if I add a #value to the form when the number of profiles is <= 1, it works.. can someone explain this to me?
Attached is a patch where it's working..
The annoying thing is when there is *more* than 1 profile and neither of them are hostmaster or hostslave, and the default_value is key($profiles) in both versions of the profile form, the default platform is no longer the one selected by default.. I don't understand this either, probably did something wrong. screenshot of that attached. I thought it might've been alphabetical or something, but then i cloned my mig5_net profile to zmig5_net and it was still mig5_net selected by default!
At least the form submits now with this patch. But I really wish I understood the rest above, and why #value is needed where it wasn't before, just because of doing an unset in the array
Comment #7
Anonymous (not verified) commentedToo spooked to commit to HEAD now. So there's a branch on g.a.o, 599758_edit_main_site
Comment #8
anarcat commentedNot sure why this is necessary, but you shouldn't loop on a select, but UPDATE on a WHERE instead... like this:
... or something like that.
keep whitespace changes out of regular commits please
i think you just need #value here and that,s the key fix here: that's why things broke when there was only one profile... this code probably never worked!
I'm on crack. Are you, too?
Comment #9
Anonymous (not verified) commentedI have no idea why I didn't do it so simple like that. I think *I* am the one on crack.
The reason the hook_update is necessary is to set status = 1 for those profiles since the logic for 'ignoring' those profiles is now done in the hosting_site_form().
I'll reroll soon.
Comment #10
Anonymous (not verified) commentedAfter that patch above, 'Please select a valid install profile' error is not seen when:
1 x main aegir platform with default + hostmaster profiles
or
1 x main aegir platform with default + hostmaster profiles
1 x drupal-6.14 platform with just default profile
But *is* seen with:
1 x main aegir platform with default + hostmaster profiles
1 x drupal-6.14 platform with default + some other profile
1 x another drupal-6.14 platform with just default profile
when the third platform there, with only default, is chosen as the platform for a new site.
I have no idea.
Comment #11
Anonymous (not verified) commentedI've pushed some changes to that branch on git.aegirproject.org, fixing the hook_update and removing the whitespace.
The profile section of hosting_site_form actually works now too, in all cases that I can find, except that it's messy and there's some duplication, because I seem to have to account twice for the potential for the number of profiles to be no more than 1 (once if there is already only one profile, and again if there were more than one but unsetting the hostmaster/hostslave options has dropped it down to one).
Tried other more sensible combinations of this but was having no luck!
And I suppose it needs a check for the edge case of a platform with *only* the hostmaster or hostslave profile, and unsetting it dropping it to 0.. although the hook_validate might be enough to take care of that anyway.
Kind of at a wall with this one, sorry.
Comment #12
Anonymous (not verified) commentedI think I've finally fixed this stupid bug
Comment #13
tema commentedIt's working for me. Many thanks!