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.
To be able to create more powerful install profiles we need to be able to override default tasks. This is a simple API change that provides a default task list for the installer that can be fullly overridden by the install profile.
This will be also important if we provide some alternate install profile that does funny things like retrieving the language list from a server and tries to download it on the fly..
Comment | File | Size | Author |
---|---|---|---|
#14 | hook_install_tasks_alter_3.patch | 3.09 KB | David_Rothstein |
#2 | hook_install_tasks_alter_2.patch | 1.02 KB | David_Rothstein |
#1 | hook_install_tasks_alter.patch | 834 bytes | David_Rothstein |
install_profile_tasks.patch | 3.11 KB | Jose Reyero | |
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedI'd personally prefer something like the attached - it seems to me like having a hook_install_tasks_alter() functionality is both simpler and more flexible.
This still allows profiles to override the whole list of installation tasks if they want to, but it also preserves a simple way for them to add to or slightly alter the list, which I think is much more common.
Comment #2
David_Rothstein CreditAttribution: David_Rothstein commentedOK, and here is a version of the patch that actually works :) The "hook" gets called too early to guarantee that the profile file is always loaded, so we have to explicitly load it.
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedI didn't create a whole profile to test this, but the code is sane.
Comment #4
Jose Reyero CreditAttribution: Jose Reyero commentedPlease, we have enough hooks. I think the original patch is more straight forward.
Comment #5
David_Rothstein CreditAttribution: David_Rothstein commentedThe original patch is optimized for someone who wants to replace Drupal's entire array of installation tasks, which is extremely rare. Everyone else would essentially have to implement their own "alter" method anyway, by calling install_default_tasks(), modifying it, and returning it as their own. In addition, the most common use case (someone who simply wanted to add a new page into the installer, which core currently supports via a very simple method) would require splicing the array and figure out how to insert their task in at the right place. I think this makes things more complex for profile authors.
I don't think adding another hook is a problem -- the pattern of using one hook to add your stuff and another hook to modify other people's stuff is very common in Drupal. Plus this is for install profiles only (and complicated profiles at that) so it's a hook that almost no one will need to worry about. Possibly for consistency, however, instead of having hook_profile_tasks() and hook_install_tasks_alter(), it would be better to modify my patch to make these more similar; e.g., hook_install_tasks() and hook_install_tasks_alter()?
Also, either of these patches probably requires some updates to the hook documentation in system.api.php, but hopefully that could be saved for a followup patch.
Comment #6
webchickLooks like this still needs discussion..?
Comment #7
rickvug CreditAttribution: rickvug commentedFixing tag
Comment #8
adrian CreditAttribution: adrian commentedwhat i have against these patches is that it could make it harder to automate installs.
I'll review this patch properly a bit later
Comment #9
Gábor HojtsyThis kind of feature would be really useful to implement a profile integrating with the new localize.drupal.org service. Since integration on both ends will not be ready on time for the Drupal 7 code freeze, we only have the install profile option. So making that capable of being aligned would be highly useful.
Comment #10
adrian CreditAttribution: adrian commentedI am adding this here for context, as this was what brought up this issue to begin with.
Comment #11
David_Rothstein CreditAttribution: David_Rothstein commentedI don't have a particular fish to fry here (since I doubt that I personally will ever need to use this feature), but this is technically an API change, and it seems like we have a clear use case, plus some simple working code. Does someone want to help push this in before the code freeze? :)
Regarding @adrian's comment, it's already possible to write an install profile that would fail to work with a (generic) automated installer - this would just give a new avenue for doing so. The main issue where that would hurt is #525594: Installation should consist of 2 phases instead of one, but there's no code there yet, so I think this is probably a concern that wouldn't really come up until Drupal 8?
Comment #12
Jose Reyero CreditAttribution: Jose Reyero commentedI agree with David and at this point I don't really mind which version of the patch gets in, both will do the work.
About other concerns here:
@adrian,
You can not try to make profiles 'automatable' by limiting them to just known 'automatable' steps. We need to assume we just won't be able to automate all install profiles.
Moreover, if some version of this patch doesn't get in, next thing we'll see is 'my-install-profile.php' kind of scripts and I can tell you for sure these won't be possible to automate in any way.
Because atm profiles are really limited and they don't support the clear and badly needed use case we've got here (install drupal in other language downloading translations from the server) I think we really need this is for at least letting the door open for that (likely) profile to exist in the future.
However this is just one use case. I can tell you I've worked hard on install profiles lately (for D6) and you feel all the time the temptation of just dropping all of it and provide your own profile-install.php or your db dump. Though D7 profiles have certainly improved (thanks mostly to Adrian's patches) they're still not flexible enough for many tasks. So the options here are these:
Either we make install profiles really flexible enough or otherwise be prepared for seeing many my-dirty-custom-setup.php or my-db-dump.sql kind of installs
Raising the priority for all the reasons mentioned above.
Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedAgreed. This is RTBC.
Comment #14
David_Rothstein CreditAttribution: David_Rothstein commentedOK, but we should definitely change the hook names to be consistent, and update the system.api.php docs as well.
This one should be RTBC.
Comment #15
Gábor HojtsyLooks good to me, agreed.
Comment #16
webchickSorry, thought I'd committed this a long time ago. It pays to glance through the RTBC queue from the back sometimes. :D
This is the final piece in de-WTFIng install profiles. Happily committed to HEAD.
I don't think the concern of "too many hooks" really applies during installation. We're firing... what? Maybe half a dozen hooks at the most there? Gábor's use case is a solid one for this functionality, and I've seen a few myself through the years of writing install profiles as well, but opted for sub-optimal hacks like form_altering in stuff to an already stupidly long form.