I have just written a patch for module_installer.module that allows it to take arguments from the release manager module. This is necessary for my upcoming (almost finished) patch to make the release manager install packages through the auspices of the module installer. It might have been possible to use the module installer to slip that functionality into the forms created by release.module, and might even have been easy, but I felt it would be more maintainable if I added the functionality into the release.module. Of course, THAT patch might not be accepted, and then I would revert to the old plan. You can see the issue here: http://drupal.org/node/119435
This patch causes the module_installer to take two GET arguments: url and dest. url is of course the url of the module to download. dest is the directory to which it should be installed. This is necessary if you are to be able to update modules in-place because they could be installed to any of three places:
modules/
Users should not be installing modules here, but nonetheless it is a possibility and modules work when they are installed here (As well they should if they are ever going to become a part of core.)
sites/all/modules/
This is where modules which should be available to all sites are supposed to be installed in 5.x.
sites/whatever/modules/
Modules can also be installed site-specifically, and this is how. We should be able to update these modules as well.
Thus I had to be able to pass both a url and a destination. Since the module installer is currently designed without a single function that handles installs (a page does it instead) I had to take this route. I could have redesigned the module_installer, but a) I didn't want to step on too many toes today and b) that was a bigger job. But ideally the module_installer.module would be redesigned to provide a module installing API.
Incidentally, I also patched the module to change the default destination from modules/contrib/ to sites/all/modules/ since that is where they belong. This is not a requirement for my added functionality however, and that could be undone (not difficult.)
Security Considerations: I am not doing any checking of the strings. They could in theory be used to inject bogus HTML. On the other hand, only Administrators should even have the necessary permissions to use any of the module_installer.module pages. Regardless, this could be tuned up quite a bit.
I have tested the necessary functionality. To test, construct a url like
http://example.com/admin/build/modules/install?url=whatever
or
http://example.com/admin/build/modules/install?url=whatever&dest=whatever
The former will install to the default (sites/all/modules) while the latter will install the module to whatever location you say, provided any instance of "whatever" is replaced with a sane value. Dest takes any path drupal can handle, I hope.
Please consider this code, or tell me how I can accomplish the same goal more sanely in a reasonable period of time, and I will take that tack.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | module_installer.arguments_0.patch | 1.62 KB | hyperlogos |
| module_installer.arguments.patch | 1.6 KB | hyperlogos |
Comments
Comment #1
hyperlogos commentedWhoops! I used #value instead of #default_value and then wondered why I couldn't change the values. There's no reason to prevent changing them, and in fact it's very nice to be able to, so I changed this. Patch attached.