[development] low hanging fruit for Drupal 6: variable defaults
msameer at foolab.org
Thu May 3 18:02:40 UTC 2007
On Thu, May 03, 2007 at 05:11:41PM +0200, Gabor Hojtsy wrote:
> Greg Knaddison - GVS wrote:
> >On 5/3/07, Gabor Hojtsy <gabor at hojtsy.hu> wrote:
> >>**We need a central place to define variable defaults**
> >Why can't that central place be the variable table?
> >We could remove the second argument to variable_get and refactor some
> >code to do the variable_set at install time which eliminates the need
> >for the defaults in the variable_get() calls themselves.
> >add1sun recently contributed a patch to pathauto that did this. The
> >reason it's needed in pathauto was the use of variable_get's that
> >involved variable variable names (e.g. variable_get('pathauto_'.
> >$something .'..., '') which had empty defaults and the code did
> >nothing if the variable came back empty. To make sure pathauto worked
> >without submitting the settings page, it now sets variables in
> >Couldn't all modules do that? Then we eliminate the second argument to
> >variable_get, create the centralized place to define variable defaults
> >as you wanted, but need no new hooks and no new module_invoke_all and
> >no new caching of "yet another variable system".
> >>Don't care yet about how this fits into translatable variables, because
> >>we can only follow up on that if this gets done. So someone please grab
> >>this issue and run with it ;)
> >The tasks would be fairly simple:
> >1. Modify variable get to take one argument
> >2. Find all variable_gets and their corresponding default, move the
> >default to an _install
> >3. Document it on the update/modules page
> >4. Rejoice
> >5. Console killes
> >I'd be happy to run with that if people like the approach.
> Indeed, makes a lot of sense to me. I'd be glad if you could run with
> this and submit a patch. But wait for more positive reactions first :)
If we have it as a hook then we don't really need to clean them up in hook_uninstall() because
drupal can invoke the variables defaults hook, get the list of variables and simply delete
them from the "registry". We now only have one problem. hook uninstall runs when the module
is unloaded but then, we can implement the extra hook in the .install file ?
Hope I'm not talking nonsense ;-)
GPG-Key: 0xA3FD0DF7 - 9F73 032E EAC9 F7AD 951F 280E CB66 8E29 A3FD 0DF7
Debian User and Developer.
More information about the development