[development] low hanging fruit for Drupal 6: variable defaults
Gabor Hojtsy
gabor at hojtsy.hu
Mon May 28 12:07:55 UTC 2007
Gabor Hojtsy wrote:
> A follow up to this is an issue by dww: http://drupal.org/node/145164
> Although he reaches the conclusion that we need a hook_variable() from
> another angle, the goal is the same after all. So people sympathizing /
> against the effort, please use that issue!
And now Jose A. Reyero is at it, and proposing a nice patch, which has
good performance and development-friendliness implications, so I would
encourage people to go and review the patch:
http://drupal.org/node/145164#comment-250759
Performance improvements:
- slightly less code to parse on each page view, as variable defaults
are centralized
- less t() calls to invoke, as not close to every variable_default()
call requires calling that, it only needs to be invoked at most
one time for a value
- less data to load in and unserialize from variable cache, as
default values are not saved
- less updates / cache refreshed on variables table because if
value is unchanged it is not updated in database
- less variables stored because uninstalled modules get their
variables uninstalled automatically
Development convenience improvements:
- no need to repeat variable defaults everytime
- you get your variables removed on uninstall, no need to
write code for that
- because you provide a type for your variable in the variables
hook, you have your common value types automatically validated
(implemented for email addresses and numbers)
PLUS this makes it a lot easier to provide user friendly localization or
translation features for site settings.
Gabor
More information about the development
mailing list