After the first few rounds of downloading and evaluating modules, I've seen something easy that's missing.
Why isn't there a hook script that runs once on startup when you enable a module?
Each custom module either has to create a database table, or check a couple of other module dependancies, or both. Some of the smarter modules do a little bit of look-ahead, but they do it each time!
Others can be badly-behaved enough to break your entire system if the SQL hasn't been inserted properly yet.
I know it's not really too much to ask to read the readme - which usually sorts it out (this is actually remarkable, readmes that work) but it would be just that more graceful for a module, when its checkbox is first checked, to bootstrap itself and say:
I need to create a database, lets run
drupal_get_file('module','mymodule','mymodule.sql');
and then check
if(!module_exists('supportmodule')){
drupal_set_message('module mymodule needs supportmodule installed to work correctly','error');
}
And then, possibly say
drupal_set_message('mymodule has now been enabled, please see admin/help/mymodule for more info, or admin/mymodule for configuration');
I realize it's up to the developers to actually USE this sort of utility, but the example code I give here is really boilerplate that would be so easy to use.
For niceness, an 'uninstall' cleanup would be possible, but probably more dangerous than it's worth.
Just an idea. I've been patching most of my evaluation modules to do this sort of thing anyway, as I've got several servers, staging, dev, live, backup, to deploy to soon.
.dan.
Comments
Comment #1
kurkuma commentedGood idea. I like the posibility to uninstall the module, but this should be specifically asked when uninstalling a module. Actually, modules could be installed/uninstalled and active/disabled.
Another question springs to my mind: how to control broken dependencies when uninstalling a module that is necessary for another still running in the system? There should be a table with dependencies information to avoid breaking the system when uninstalling modules... Could it get more complicated?
Anyway +1 for it.
One step closer to a proper installing system for Drupal ;-)
Comment #2
dman commentedI believe the proposed Install system should take care of this, eventually. I still believe that a module should have an optional hook to run its own code that can be triggered by the install process.
I'm using the approach I outlined above in my own modules anyway, but in light of other work in progress, I'll take this off the board.
Here's hoping the install system will deliver as promised.
.dan.